Skip to content

Commit aedeaaf

Browse files
committed
t/lib-httpd: try harder to find a port for apache
When running multiple builds concurrently, tests which run daemons, like apache httpd, sometimes conflict with each other, leading to spurious failures: ++ /usr/sbin/httpd -d '/tmp/git-t.ck9I/trash directory.t9118-git-svn-funky-branch-names/httpd' \ -f /builddir/build/BUILD/git-2.37.2/t/lib-httpd/apache.conf -DDAV -DSVN -c 'Listen 127.0.0.1:9118' \ -k start (98)Address already in use: AH00072: make_sock: could not bind to address 127.0.0.1:9118 no listening sockets available, shutting down AH00015: Unable to open logs ++ test 1 -ne 0 Try a bit harder to find an open port to use to avoid these intermittent failures. If we fail to start httpd, increment the port number and try again. By default, we make 3 attempts. This may be overridden by setting GIT_TEST_START_HTTPD_TRIES to a different value. Helped-by: Ondřej Pohořelský <opohorel@redhat.com> Signed-off-by: Todd Zullinger <tmz@pobox.com>
1 parent 07ee72d commit aedeaaf

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

t/lib-httpd.sh

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,19 +175,26 @@ prepare_httpd() {
175175
}
176176

177177
start_httpd() {
178-
prepare_httpd >&3 2>&4
179-
180178
test_atexit stop_httpd
181179

182-
"$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
183-
-f "$TEST_PATH/apache.conf" $HTTPD_PARA \
184-
-c "Listen 127.0.0.1:$LIB_HTTPD_PORT" -k start \
185-
>&3 2>&4
186-
if test $? -ne 0
187-
then
188-
cat "$HTTPD_ROOT_PATH"/error.log >&4 2>/dev/null
189-
test_skip_or_die GIT_TEST_HTTPD "web server setup failed"
190-
fi
180+
i=0
181+
while test $i -lt ${GIT_TEST_START_HTTPD_TRIES:-3}
182+
do
183+
i=$(($i + 1))
184+
prepare_httpd >&3 2>&4
185+
say >&3 "Starting httpd on port $LIB_HTTPD_PORT"
186+
"$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
187+
-f "$TEST_PATH/apache.conf" $HTTPD_PARA \
188+
-c "Listen 127.0.0.1:$LIB_HTTPD_PORT" -k start \
189+
>&3 2>&4
190+
test $? -eq 0 && return
191+
LIB_HTTPD_PORT=$(($LIB_HTTPD_PORT + 1))
192+
export LIB_HTTPD_PORT
193+
# clean up modules symlink, prepare_httpd will re-create it
194+
rm -f "$HTTPD_ROOT_PATH/modules"
195+
done
196+
cat "$HTTPD_ROOT_PATH"/error.log >&4 2>/dev/null
197+
test_skip_or_die GIT_TEST_HTTPD "web server setup failed"
191198
}
192199

193200
stop_httpd() {

0 commit comments

Comments
 (0)