git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] t/lib-http.sh: Enable httpd tests by default.

From
TTarmigan <tarmigan+git@gmail.com>
Date
Nov 20, 2009, 19:03 UTC
Message-ID
<905315640911201103w6d1da86duf41a53537672be8e@mail.gmail.com>
In-Reply-To
<7vd43d7hdo.fsf@alter.siamese.dyndns.org>
On Fri, Nov 20, 2009 at 12:03 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 9 quoted lines
> 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() {
Previous: Junio C HamanoNext: Clemens Buchacher
Message 4 of 10 in “t/lib-http.sh: Restructure finding of default httpd location”
  1. 1/2 t/lib-http.sh: Restructure finding of default httpd locationTarmigan Casebolt, Nov 20, 2009
  2. 2/2 t/lib-http.sh: Enable httpd tests by default.Tarmigan Casebolt, Nov 20, 2009
  3. Junio C HamanoNov 20, 2009
  4. TarmiganNov 20, 2009
  5. Clemens BuchacherNov 20, 2009
  6. Junio C HamanoNov 20, 2009
  7. Junio C HamanoNov 20, 2009
  8. Jay SoffianNov 20, 2009
  9. TarmiganNov 20, 2009
  10. t/lib-http.sh: Restructure finding of default httpd locationTarmigan Casebolt, Jan 2, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.