commit 417c56da5e451e4c04b12d9a17cb2215e13b95aa from: Stefan Sperling via: Thomas Adam date: Fri Jan 10 22:29:14 2025 UTC try to improve http-server startup/teardown in regress Let tests fail if http-server fails to start up within 5 seconds. Make http-server report its process ID in its log file such that tests can kill it by PID. Prompted by semi-regular failures on my arm64 regress builder. commit - 705e365cc30a9ee94c203029b7020c7c55bc74b8 commit + 417c56da5e451e4c04b12d9a17cb2215e13b95aa blob - 5b5d598956947ffeb1771fbde75a8c7183a12fe5 blob + 184a0cab35d28783c255c1494d78b1695189a105 --- regress/cmdline/clone.sh +++ regress/cmdline/clone.sh @@ -869,12 +869,24 @@ test_clone_basic_http() { timeout 20 ./http-server -p $GOT_TEST_HTTP_PORT $testroot \ > $testroot/http-server.log & - trap "kill %1" HUP INT QUIT PIPE TERM - while ! grep -q 'ready' $testroot/http-server.log; do - sleep 1 # server starts up + sleep 1 # server starts up + for i in 1 2 3 4; do + if grep -q ': ready' $testroot/http-server.log; then + break + fi + if [ $i -eq 4 ]; then + echo "http-server startup timeout" >&2 + test_done "$testroot" "1" + # timeout(1) will kill the server eventually + return 1 + fi + sleep 1 # server is still starting up done + http_pid=`head -n 1 $testroot/http-server.log | cut -d ':' -f1` + trap "kill -9 $http_pid; wait $http_pid" HUP INT QUIT PIPE TERM + # Test our custom HTTP server with git clone. Should succeed. git clone -q $testurl/repo $testroot/repo-clone-with-git ret=$? @@ -893,8 +905,8 @@ test_clone_basic_http() { return 1 fi - kill %1 - wait %1 # wait for http-server + kill $http_pid + wait $http_pid got log -l0 -p -r $testroot/repo > $testroot/log-repo ret=$? blob - 8bdfcdaf1365dd164ba1f07cefa4d99235dbce45 blob + 9bda4d3b425e3cfc1eaf1893388d1c2ad82c2065 --- regress/cmdline/fetch.sh +++ regress/cmdline/fetch.sh @@ -2027,12 +2027,24 @@ test_fetch_basic_http() { timeout 20 ./http-server -p $GOT_TEST_HTTP_PORT $testroot \ > $testroot/http-server.log & - trap "kill %1" HUP INT QUIT PIPE TERM - while ! grep -q 'ready' $testroot/http-server.log; do - sleep 1 # server starts up + sleep 1 # server starts up + for i in 1 2 3 4; do + if grep -q ': ready' $testroot/http-server.log; then + break + fi + if [ $i -eq 4 ]; then + echo "http-server startup timeout" >&2 + test_done "$testroot" "1" + # timeout(1) will kill the server eventually + return 1 + fi + sleep 1 # server is still starting up done + http_pid=`head -n 1 $testroot/http-server.log | cut -d ':' -f1` + trap "kill -9 $http_pid; wait $http_pid" HUP INT QUIT PIPE TERM + got clone -q $testurl/repo $testroot/repo-clone ret=$? if [ $ret -ne 0 ]; then @@ -2062,8 +2074,8 @@ test_fetch_basic_http() { return 1 fi - kill %1 - wait %1 # wait for http-server + kill $http_pid + wait $http_pid echo -n > $testroot/stdout.expected blob - f9d3ac17c027bb490d3b70f0ad1a4ab11df5dad4 blob + 4df26ceeeac4eee7baae1c6190fc2ecdd40a5f30 --- regress/cmdline/http-server +++ regress/cmdline/http-server @@ -154,7 +154,7 @@ sub handle_post { } STDOUT->autoflush(1); -printf "ready\n"; +printf "$$: ready\n"; while (1) { my $client = $server->accept();