Skip to content

Commit

Permalink
e2e: Fix ncsvr to wait for input on HTTP
Browse files Browse the repository at this point in the history
This caused occasional e2e flakes when the server responded before the
client request had been sent.
  • Loading branch information
thockin committed Jul 6, 2022
1 parent c2d0a9d commit 5063149
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
6 changes: 5 additions & 1 deletion _test_tools/ncsvr/ncsvr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ if [ -z "$1" -o -z "$2" ]; then
exit 1
fi

F="/tmp/fifo.$RANDOM"

while true; do
sh -c "$2" | nc -l -p "$1" -N -w0 >/dev/null
rm -f "$F"
mkfifo "$F"
cat "$F" | sh -c "$2" 2>&1 | nc -l -p "$1" -N -w1 > "$F"
date >> /var/log/hits
done
32 changes: 23 additions & 9 deletions test_e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ function e2e::auth_askpass_url_wrong_password() {
CTR=$(docker_run \
-v "$HITLOG":/var/log/hits \
e2e/test/test-ncsvr \
80 '
80 'read X
echo "HTTP/1.1 200 OK"
echo
echo "username=my-username"
Expand Down Expand Up @@ -969,7 +969,7 @@ function e2e::auth_askpass_url_correct_password() {
CTR=$(docker_run \
-v "$HITLOG":/var/log/hits \
e2e/test/test-ncsvr \
80 '
80 'read X
echo "HTTP/1.1 200 OK"
echo
echo "username=my-username"
Expand Down Expand Up @@ -1022,7 +1022,7 @@ function e2e::auth_askpass_url_flaky() {
CTR=$(docker_run \
-v "$HITLOG":/var/log/hits \
e2e/test/test-ncsvr \
80 '
80 'read X
echo "HTTP/1.1 200 OK"
echo
if [ -f /tmp/flag ]; then
Expand Down Expand Up @@ -1209,7 +1209,9 @@ function e2e::webhook_success() {
CTR=$(docker_run \
-v "$HITLOG":/var/log/hits \
e2e/test/test-ncsvr \
80 'echo "HTTP/1.1 200 OK"')
80 'read X
echo "HTTP/1.1 200 OK"
')
IP=$(docker_ip "$CTR")
echo "$FUNCNAME 1" > "$REPO"/file
git -C "$REPO" commit -qam "$FUNCNAME 1"
Expand Down Expand Up @@ -1255,7 +1257,9 @@ function e2e::webhook_fail_retry() {
CTR=$(docker_run \
-v "$HITLOG":/var/log/hits \
e2e/test/test-ncsvr \
80 'echo "HTTP/1.1 500 Internal Server Error"')
80 'read X
echo "HTTP/1.1 500 Internal Server Error"
')
IP=$(docker_ip "$CTR")
echo "$FUNCNAME 1" > "$REPO"/file
git -C "$REPO" commit -qam "$FUNCNAME 1"
Expand Down Expand Up @@ -1284,7 +1288,9 @@ function e2e::webhook_fail_retry() {
--ip="$IP" \
-v "$HITLOG":/var/log/hits \
e2e/test/test-ncsvr \
80 'echo "HTTP/1.1 200 OK"')
80 'read X
echo "HTTP/1.1 200 OK"
')
sleep 2
HITS=$(cat "$HITLOG" | wc -l)
if [[ "$HITS" < 1 ]]; then
Expand All @@ -1303,7 +1309,10 @@ function e2e::webhook_success_once() {
CTR=$(docker_run \
-v "$HITLOG":/var/log/hits \
e2e/test/test-ncsvr \
80 'sleep 3 && echo "HTTP/1.1 200 OK"')
80 'read X
sleep 3
echo "HTTP/1.1 200 OK"
')
IP=$(docker_ip "$CTR")
echo "$FUNCNAME 1" > "$REPO"/file
git -C "$REPO" commit -qam "$FUNCNAME 1"
Expand Down Expand Up @@ -1338,7 +1347,10 @@ function e2e::webhook_fail_retry_once() {
CTR=$(docker_run \
-v "$HITLOG":/var/log/hits \
e2e/test/test-ncsvr \
80 'sleep 3 && echo "HTTP/1.1 500 Internal Server Error"')
80 'read X
sleep 3
echo "HTTP/1.1 500 Internal Server Error"
')
IP=$(docker_ip "$CTR")
echo "$FUNCNAME 1" > "$REPO"/file
git -C "$REPO" commit -qam "$FUNCNAME 1"
Expand Down Expand Up @@ -1373,7 +1385,9 @@ function e2e::webhook_fire_and_forget() {
CTR=$(docker_run \
-v "$HITLOG":/var/log/hits \
e2e/test/test-ncsvr \
80 'echo "HTTP/1.1 404 Not Found"')
80 'read X
echo "HTTP/1.1 404 Not Found"
')
IP=$(docker_ip "$CTR")

# First sync
Expand Down

0 comments on commit 5063149

Please sign in to comment.