commit 5a4304006707470fa37d4bf797a46adc0a0216ea from: Christian Weisgerber date: Sun May 12 14:34:13 2024 UTC regress: make server tests more robust against race hazard Add a delay after starting the server background process to keep server and client from racing against each other, which would lead to failures when the client ran before the server. ok op commit - 50ccbcd9a6e4786d4eb726ac8bc3e8565fd7aa48 commit + 5a4304006707470fa37d4bf797a46adc0a0216ea blob - 0f044fa5e9f2d09e6ac1d9c134d217185fe3fb57 blob + 87b2d0ee33cba60718822df7626b15b93e0b09ba --- regress/gotd/email_notification.sh +++ regress/gotd/email_notification.sh @@ -44,6 +44,8 @@ test_file_changed() { (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \ | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) & + sleep 1 # server starts up + got send -b main -q -r $testroot/repo-clone ret=$? if [ $ret -ne 0 ]; then @@ -124,6 +126,8 @@ test_many_commits_not_summarized() { (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \ | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) & + sleep 1 # server starts up + got send -b main -q -r $testroot/repo-clone ret=$? if [ $ret -ne 0 ]; then @@ -211,6 +215,8 @@ test_many_commits_summarized() { (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \ | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) & + sleep 1 # server starts up + got send -b main -q -r $testroot/repo-clone ret=$? if [ $ret -ne 0 ]; then @@ -286,6 +292,8 @@ test_branch_created() { (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \ | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) & + + sleep 1 # server starts up got send -b newbranch -q -r $testroot/repo-clone ret=$? @@ -350,6 +358,8 @@ test_branch_removed() { (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \ | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) & + sleep 1 # server starts up + local commit_id=`git_show_branch_head $testroot/repo-clone newbranch` local short_commit_id=`trim_obj_id 28 $commit_id` @@ -413,6 +423,8 @@ test_tag_created() { (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \ | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) & + + sleep 1 # server starts up got send -t 1.0 -q -r $testroot/repo-clone ret=$? @@ -493,6 +505,8 @@ test_tag_changed() { (printf "220\r\n250\r\n250\r\n250\r\n354\r\n250\r\n221\r\n" \ | timeout 5 nc -l "$GOTD_TEST_SMTP_PORT" > $testroot/stdout) & + sleep 1 # server starts up + got send -f -t 1.0 -q -r $testroot/repo-clone ret=$? if [ $ret -ne 0 ]; then blob - 4e84724b805fce88a8e881e5700e1c71b5b4fd5b blob + d3b27ff7a41130bee6fe4caab834d5f8a3f31319 --- regress/gotd/http_notification.sh +++ regress/gotd/http_notification.sh @@ -47,6 +47,8 @@ test_file_changed() { timeout 5 ./http-server -a $AUTH -p $GOTD_TEST_HTTP_PORT \ > $testroot/stdout & + sleep 1 # server starts up + got send -b main -q -r $testroot/repo-clone ret=$? if [ $ret -ne 0 ]; then @@ -116,6 +118,8 @@ test_file_changed() { timeout 5 ./http-server -a $AUTH -p $GOTD_TEST_HTTP_PORT \ > $testroot/stdout & + sleep 1 # server starts up + git -C $testroot/repo-clone push -q origin main ret=$? if [ $ret -ne 0 ]; then @@ -205,6 +209,8 @@ test_bad_utf8() { timeout 5 ./http-server -a $AUTH -p $GOTD_TEST_HTTP_PORT \ > $testroot/stdout & + sleep 1 # server starts up + got send -b main -q -r $testroot/repo-clone ret=$? if [ $ret -ne 0 ]; then @@ -298,6 +304,8 @@ test_many_commits_not_summarized() { timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \ > $testroot/stdout & + sleep 1 # server starts up + got send -b main -q -r $testroot/repo-clone ret=$? if [ $ret -ne 0 ]; then @@ -402,6 +410,8 @@ test_many_commits_summarized() { timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \ > $testroot/stdout & + + sleep 1 # server starts up got send -b main -q -r $testroot/repo-clone ret=$? @@ -484,6 +494,8 @@ test_branch_created() { timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \ > $testroot/stdout & + sleep 1 # server starts up + got send -b newbranch -q -r $testroot/repo-clone ret=$? if [ $ret -ne 0 ]; then @@ -569,6 +581,8 @@ test_branch_removed() { timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \ > $testroot/stdout & + + sleep 1 # server starts up local commit_id=`git_show_branch_head $testroot/repo-clone newbranch` @@ -626,6 +640,8 @@ test_tag_created() { timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \ >$testroot/stdout & + sleep 1 # server starts up + got send -t 1.0 -q -r $testroot/repo-clone ret=$? if [ $ret -ne 0 ]; then @@ -703,6 +719,8 @@ test_tag_changed() { timeout 5 ./http-server -a $AUTH -p "$GOTD_TEST_HTTP_PORT" \ > $testroot/stdout & + sleep 1 # server starts up + got send -f -t 1.0 -q -r $testroot/repo-clone ret=$? if [ $ret -ne 0 ]; then