All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] t/lib-http.sh: Restructure finding of default httpd location
@ 2009-11-20  1:22 Tarmigan Casebolt
  2009-11-20  1:22 ` [PATCH 2/2] t/lib-http.sh: Enable httpd tests by default Tarmigan Casebolt
  2009-11-20  3:14 ` [PATCH 1/2] t/lib-http.sh: Restructure finding of default httpd location Jay Soffian
  0 siblings, 2 replies; 10+ messages in thread
From: Tarmigan Casebolt @ 2009-11-20  1:22 UTC (permalink / raw)
  To: git; +Cc: peff, jaysoffian, drizzd, gitster, spearce, Tarmigan Casebolt

On my machine with CentOS, httpd is located at /usr/sbin/httpd, and
the modules are located at /usr/lib64/httpd/modules.  To enable easy
testing of httpd, we would like those locations to be detected
automatically.

uname might not be the best way to determine the default location for
httpd since different Linux distributions apparently put httpd in
different places, so we test a couple different locations for httpd,
and use the first one that we come across.  We do the same for the
modules directory.

Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>
---

Would any machines have httpd or the modules/ directory in several of
these locations?

Also I don't really know shell scripting, so while this Works For Me,
it may be completely wrong.

 t/lib-httpd.sh |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index 6765b08..6b86353 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -12,16 +12,23 @@ fi
 
 HTTPD_PARA=""
 
+for DEFAULT_HTTPD_PATH in '/usr/sbin/httpd' '/usr/sbin/apache2'
+do
+	test -x "$DEFAULT_HTTPD_PATH" && break
+done
+
+for DEFAULT_HTTPD_MODULE_PATH in '/usr/libexec/apache2' \
+                                 '/usr/lib/apache2/modules' \
+                                 '/usr/lib64/httpd/modules' \
+                                 '/usr/lib/httpd/modules'
+do
+	test -d "$DEFAULT_HTTPD_MODULE_PATH" && break
+done
+
 case $(uname) in
 	Darwin)
-		DEFAULT_HTTPD_PATH='/usr/sbin/httpd'
-		DEFAULT_HTTPD_MODULE_PATH='/usr/libexec/apache2'
 		HTTPD_PARA="$HTTPD_PARA -DDarwin"
 	;;
-	*)
-		DEFAULT_HTTPD_PATH='/usr/sbin/apache2'
-		DEFAULT_HTTPD_MODULE_PATH='/usr/lib/apache2/modules'
-	;;
 esac
 
 LIB_HTTPD_PATH=${LIB_HTTPD_PATH-"$DEFAULT_HTTPD_PATH"}
-- 
1.6.5.52.g35487

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/2] t/lib-http.sh: Enable httpd tests by default.
  2009-11-20  1:22 [PATCH 1/2] t/lib-http.sh: Restructure finding of default httpd location Tarmigan Casebolt
@ 2009-11-20  1:22 ` Tarmigan Casebolt
  2009-11-20  8:03   ` Junio C Hamano
  2009-11-20  3:14 ` [PATCH 1/2] t/lib-http.sh: Restructure finding of default httpd location Jay Soffian
  1 sibling, 1 reply; 10+ messages in thread
From: Tarmigan Casebolt @ 2009-11-20  1:22 UTC (permalink / raw)
  To: git; +Cc: peff, jaysoffian, drizzd, gitster, spearce, Tarmigan Casebolt

With smart http, git over http is likely to become much more common.
To increase testing of smart http, enable the http tests by default.

If we cannot detect httpd, we still skip these tests, so it should not
cause problems on platforms where we cannot run the tests.

Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>
---
 t/lib-httpd.sh |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index 6b86353..db537b4 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -3,11 +3,12 @@
 # Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
 #
 
-if test -z "$GIT_TEST_HTTPD"
+if test -n "$NO_GIT_TEST_HTTPD"
 then
-	say "skipping test, network testing disabled by default"
-	say "(define GIT_TEST_HTTPD to enable)"
+	say "Skipping http tests because NO_GIT_TEST_HTTPD is defined"
 	test_done
+else
+	say "Define NO_GIT_TEST_HTTPD to disable http testing"
 fi
 
 HTTPD_PARA=""
-- 
1.6.5.52.g35487

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] t/lib-http.sh: Restructure finding of default httpd  location
  2009-11-20  1:22 [PATCH 1/2] t/lib-http.sh: Restructure finding of default httpd location Tarmigan Casebolt
  2009-11-20  1:22 ` [PATCH 2/2] t/lib-http.sh: Enable httpd tests by default Tarmigan Casebolt
@ 2009-11-20  3:14 ` Jay Soffian
  2009-11-20  3:30   ` Tarmigan
  1 sibling, 1 reply; 10+ messages in thread
From: Jay Soffian @ 2009-11-20  3:14 UTC (permalink / raw)
  To: Tarmigan Casebolt; +Cc: git, peff, drizzd, gitster, spearce

On Thu, Nov 19, 2009 at 8:22 PM, Tarmigan Casebolt
<tarmigan+git@gmail.com> wrote:
> uname might not be the best way to determine the default location for
> httpd since different Linux distributions apparently put httpd in
> different places, so we test a couple different locations for httpd,
> and use the first one that we come across.  We do the same for the
> modules directory.

Perhaps testing the distribution and looking in the known location for
that distribution then? That said, going through a list of well known
locations should work too.

> +for DEFAULT_HTTPD_PATH in '/usr/sbin/httpd' '/usr/sbin/apache2'
> +do
> +       test -x "$DEFAULT_HTTPD_PATH" && break
> +done

Unfortunately this leaves DEFAULT_HTTPD_PATH as the last item in the
list even if the test does not pass. You can add an empty item to the
end of the list if you want to do this way.

> +for DEFAULT_HTTPD_MODULE_PATH in '/usr/libexec/apache2' \
> +                                 '/usr/lib/apache2/modules' \
> +                                 '/usr/lib64/httpd/modules' \
> +                                 '/usr/lib/httpd/modules'
> +do
> +       test -d "$DEFAULT_HTTPD_MODULE_PATH" && break
> +done

Ditto.

j.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] t/lib-http.sh: Restructure finding of default httpd  location
  2009-11-20  3:14 ` [PATCH 1/2] t/lib-http.sh: Restructure finding of default httpd location Jay Soffian
@ 2009-11-20  3:30   ` Tarmigan
  2010-01-02 22:04     ` [PATCH v2] " Tarmigan Casebolt
  0 siblings, 1 reply; 10+ messages in thread
From: Tarmigan @ 2009-11-20  3:30 UTC (permalink / raw)
  To: Jay Soffian; +Cc: git, peff, drizzd, gitster, spearce

On Thu, Nov 19, 2009 at 7:14 PM, Jay Soffian <jaysoffian@gmail.com> wrote:
> On Thu, Nov 19, 2009 at 8:22 PM, Tarmigan Casebolt
> <tarmigan+git@gmail.com> wrote:
>> uname might not be the best way to determine the default location for
>> httpd since different Linux distributions apparently put httpd in
>> different places, so we test a couple different locations for httpd,
>> and use the first one that we come across.  We do the same for the
>> modules directory.
>
> Perhaps testing the distribution and looking in the known location for
> that distribution then? That said, going through a list of well known
> locations should work too.

Is there a nice way to test the distribution?  Seems to me like doing
that might be more complicated and also more fragile.

>> +for DEFAULT_HTTPD_PATH in '/usr/sbin/httpd' '/usr/sbin/apache2'
>> +do
>> +       test -x "$DEFAULT_HTTPD_PATH" && break
>> +done
>
> Unfortunately this leaves DEFAULT_HTTPD_PATH as the last item in the
> list even if the test does not pass. You can add an empty item to the
> end of the list if you want to do this way.

Yes.  I think this is how it was before though too, and it is caught
later in the script with the LIB_HTTPD_PATH setting and testing.

>> +for DEFAULT_HTTPD_MODULE_PATH in '/usr/libexec/apache2' \
>> +                                 '/usr/lib/apache2/modules' \
>> +                                 '/usr/lib64/httpd/modules' \
>> +                                 '/usr/lib/httpd/modules'
>> +do
>> +       test -d "$DEFAULT_HTTPD_MODULE_PATH" && break
>> +done
>
> Ditto.

Yes.  Again, this is still more thorough than before, but in this case
the script does not check later.  Perhaps the script should test this
value and test_done if it's not a directory?

Thanks,
Tarmigan

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] t/lib-http.sh: Enable httpd tests by default.
  2009-11-20  1:22 ` [PATCH 2/2] t/lib-http.sh: Enable httpd tests by default Tarmigan Casebolt
@ 2009-11-20  8:03   ` Junio C Hamano
  2009-11-20 19:03     ` Tarmigan
  0 siblings, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2009-11-20  8:03 UTC (permalink / raw)
  To: Tarmigan Casebolt; +Cc: git, peff, jaysoffian, drizzd, gitster, spearce

Tarmigan Casebolt <tarmigan+git@gmail.com> writes:

> With smart http, git over http is likely to become much more common.
> To increase testing of smart http, enable the http tests by default.

Sorry, but no test that listens to network ports should be enabled by
default; otherwise it will break automated, unattended tests people have
already set up randomly, depending on when the port happens to be
available for use by the tests.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] t/lib-http.sh: Enable httpd tests by default.
  2009-11-20  8:03   ` Junio C Hamano
@ 2009-11-20 19:03     ` Tarmigan
  2009-11-20 20:11       ` Clemens Buchacher
  2009-11-20 20:54       ` Junio C Hamano
  0 siblings, 2 replies; 10+ messages in thread
From: Tarmigan @ 2009-11-20 19:03 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, peff, jaysoffian, drizzd, spearce

On Fri, Nov 20, 2009 at 12:03 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Tarmigan <tarmigan+git@gmail.com> writes:
>
>> With smart http, git over http is likely to become much more common.
>> To increase testing of smart http, enable the http tests by default.
>
> Sorry, but no test that listens to network ports should be enabled by
> default; otherwise it will break automated, unattended tests people have
> already set up randomly, depending on when the port happens to be
> available for use by the tests.

Is this the only concern or are there security or other issues as well?

If that is the only concern, we could have the tests automatically
fall back to listening on a different port.  Even if we didn't, if
httpd cannot startup because it can't bind to the port, the http tests
say
* skipping test, web server setup failed
and exit with test_done before any of the tests actually fail.

Here's a patch (cut-n-paste so it will probably be munged) for
discussion of the port-fallback idea.  If httpd cannot bind to 5541,
it tries 15541 etc.  You can test this by running "nc -l 5541 &"
before the test.  If this approach might be acceptable, I can send a
properly formatted patch.

Comments?

Thanks,
Tarmigan

diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index 797a2d6..a8eb6fa 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -77,7 +77,7 @@ prepare_httpd() {

        if test -n "$LIB_HTTPD_SSL"
        then
-               HTTPD_URL=https://127.0.0.1:$LIB_HTTPD_PORT
+               HTTPD_URL=https://127.0.0.1

                RANDFILE_PATH="$HTTPD_ROOT_PATH"/.rnd openssl req \
                        -config "$TEST_PATH/ssl.cnf" \
@@ -88,7 +88,7 @@ prepare_httpd() {
                export GIT_SSL_NO_VERIFY
                HTTPD_PARA="$HTTPD_PARA -DSSL"
        else
-               HTTPD_URL=http://127.0.0.1:$LIB_HTTPD_PORT
+               HTTPD_URL=http://127.0.0.1
        fi

        if test -n "$LIB_HTTPD_DAV" -o -n "$LIB_HTTPD_SVN"
@@ -109,16 +109,29 @@ start_httpd() {

        trap 'code=$?; stop_httpd; (exit $code); die' EXIT

-       "$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
-               -f "$TEST_PATH/apache.conf" $HTTPD_PARA \
-               -c "Listen 127.0.0.1:$LIB_HTTPD_PORT" -k start \
-               >&3 2>&4
-       if test $? -ne 0
-       then
-               say "skipping test, web server setup failed"
-               trap 'die' EXIT
-               test_done
-       fi
+       while true
+       do
+               "$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
+                       -f "$TEST_PATH/apache.conf" $HTTPD_PARA \
+                       -c "Listen 127.0.0.1:$LIB_HTTPD_PORT" -k start \
+                       >&3 2>&4
+               if test $? -ne 0
+               then
+                       if test $LIB_HTTPD_PORT -gt 40000
+                       then
+                               say "skipping test, web server setup failed"
+                               trap 'die' EXIT
+                               test_done
+                       fi
+                       LIB_HTTPD_PORT=$(($LIB_HTTPD_PORT + 10000))
+                       say "trying port $LIB_HTTPD_PORT"
+                       continue
+               else
+                       break
+               fi
+       done
+
+       HTTPD_URL="$HTTPD_URL:$LIB_HTTPD_PORT"
 }

 stop_httpd() {

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] t/lib-http.sh: Enable httpd tests by default.
  2009-11-20 19:03     ` Tarmigan
@ 2009-11-20 20:11       ` Clemens Buchacher
  2009-11-20 20:56         ` Junio C Hamano
  2009-11-20 20:54       ` Junio C Hamano
  1 sibling, 1 reply; 10+ messages in thread
From: Clemens Buchacher @ 2009-11-20 20:11 UTC (permalink / raw)
  To: Tarmigan; +Cc: Junio C Hamano, git, peff, jaysoffian, spearce

On Fri, Nov 20, 2009 at 11:03:13AM -0800, Tarmigan wrote:

> Here's a patch (cut-n-paste so it will probably be munged) for
> discussion of the port-fallback idea.  If httpd cannot bind to 5541,
> it tries 15541 etc.

I would prefer if we skip the test right away. If we really want to try
different ports, we should first check that the port really is the problem.
Otherwise, the test will uselessly retry several times. Apache 2 writes

 (98)Address already in use: make_sock: could not bind to address
 127.0.0.1:5541

to stderr, which we could use to detect that error condition. But other web
servers are bound to behave differently.

Clemens

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] t/lib-http.sh: Enable httpd tests by default.
  2009-11-20 19:03     ` Tarmigan
  2009-11-20 20:11       ` Clemens Buchacher
@ 2009-11-20 20:54       ` Junio C Hamano
  1 sibling, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2009-11-20 20:54 UTC (permalink / raw)
  To: Tarmigan; +Cc: git, peff, jaysoffian, drizzd, spearce

Tarmigan <tarmigan+git@gmail.com> writes:

> On Fri, Nov 20, 2009 at 12:03 AM, Junio C Hamano <gitster@pobox.com> wrote:
>> Tarmigan <tarmigan+git@gmail.com> writes:
>>
>>> With smart http, git over http is likely to become much more common.
>>> To increase testing of smart http, enable the http tests by default.
>>
>> Sorry, but no test that listens to network ports should be enabled by
>> default; otherwise it will break automated, unattended tests people have
>> already set up randomly, depending on when the port happens to be
>> available for use by the tests.
>
> Is this the only concern or are there security or other issues as well?

I thought security was too obvious to mention.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] t/lib-http.sh: Enable httpd tests by default.
  2009-11-20 20:11       ` Clemens Buchacher
@ 2009-11-20 20:56         ` Junio C Hamano
  0 siblings, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2009-11-20 20:56 UTC (permalink / raw)
  To: Clemens Buchacher; +Cc: Tarmigan, git, peff, jaysoffian, spearce

Clemens Buchacher <drizzd@aon.at> writes:

> On Fri, Nov 20, 2009 at 11:03:13AM -0800, Tarmigan wrote:
>
>> Here's a patch (cut-n-paste so it will probably be munged) for
>> discussion of the port-fallback idea.  If httpd cannot bind to 5541,
>> it tries 15541 etc.
>
> I would prefer if we skip the test right away.

Retrying is a different issue, and when tests are enabled I think it is Ok
to retry all you want.

But I don't want to see them enabled unless the user explicitly told us
to.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2] t/lib-http.sh: Restructure finding of default httpd location
  2009-11-20  3:30   ` Tarmigan
@ 2010-01-02 22:04     ` Tarmigan Casebolt
  0 siblings, 0 replies; 10+ messages in thread
From: Tarmigan Casebolt @ 2010-01-02 22:04 UTC (permalink / raw)
  To: gitster; +Cc: git, Tarmigan Casebolt, Jay Soffian

On CentOS 5, httpd is located at /usr/sbin/httpd, and the modules are
located at /usr/lib64/httpd/modules.  To enable easy testing of httpd,
we would like those locations to be detected automatically.

uname might not be the best way to determine the default location for
httpd since different Linux distributions apparently put httpd in
different places, so we test a couple different locations for httpd,
and use the first one that we come across.  We do the same for the
modules directory.

cc: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>
---
Jay was concerned about the final fallthrough cases for testing these
lists.  I have added a test for the modules directory and the existing
tests later in the script already test that the apache executable
exists.  If either cannot be found, we do test_done.

Would any machines have httpd or the modules/ directory in several of
these locations?
---
 t/lib-httpd.sh |   30 ++++++++++++++++++++++++------
 1 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index 6765b08..27b466b 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -12,16 +12,29 @@ fi
 
 HTTPD_PARA=""
 
+for DEFAULT_HTTPD_PATH in '/usr/sbin/httpd' '/usr/sbin/apache2'
+do
+	if test -x "$DEFAULT_HTTPD_PATH"
+	then
+	        break
+	fi
+done
+
+for DEFAULT_HTTPD_MODULE_PATH in '/usr/libexec/apache2' \
+                                 '/usr/lib/apache2/modules' \
+                                 '/usr/lib64/httpd/modules' \
+                                 '/usr/lib/httpd/modules'
+do
+        if test -d "$DEFAULT_HTTPD_MODULE_PATH"
+	then
+	        break
+	fi
+done
+
 case $(uname) in
 	Darwin)
-		DEFAULT_HTTPD_PATH='/usr/sbin/httpd'
-		DEFAULT_HTTPD_MODULE_PATH='/usr/libexec/apache2'
 		HTTPD_PARA="$HTTPD_PARA -DDarwin"
 	;;
-	*)
-		DEFAULT_HTTPD_PATH='/usr/sbin/apache2'
-		DEFAULT_HTTPD_MODULE_PATH='/usr/lib/apache2/modules'
-	;;
 esac
 
 LIB_HTTPD_PATH=${LIB_HTTPD_PATH-"$DEFAULT_HTTPD_PATH"}
@@ -49,6 +62,11 @@ then
 			say "skipping test, at least Apache version 2 is required"
 			test_done
 		fi
+		if ! test -d "$DEFAULT_HTTPD_MODULE_PATH"
+		then
+			say "Apache module directory not found.  Skipping tests."
+			test_done
+		fi
 
 		LIB_HTTPD_MODULE_PATH="$DEFAULT_HTTPD_MODULE_PATH"
 	fi
-- 
1.6.6.236.gc56f3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-01-02 22:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-20  1:22 [PATCH 1/2] t/lib-http.sh: Restructure finding of default httpd location Tarmigan Casebolt
2009-11-20  1:22 ` [PATCH 2/2] t/lib-http.sh: Enable httpd tests by default Tarmigan Casebolt
2009-11-20  8:03   ` Junio C Hamano
2009-11-20 19:03     ` Tarmigan
2009-11-20 20:11       ` Clemens Buchacher
2009-11-20 20:56         ` Junio C Hamano
2009-11-20 20:54       ` Junio C Hamano
2009-11-20  3:14 ` [PATCH 1/2] t/lib-http.sh: Restructure finding of default httpd location Jay Soffian
2009-11-20  3:30   ` Tarmigan
2010-01-02 22:04     ` [PATCH v2] " Tarmigan Casebolt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.