Skip to content

Commit

Permalink
Try a different, less complex approach
Browse files Browse the repository at this point in the history
Just swap out the HTTP response script on the fly, rather than
restarting `nc` and trying to get the same IP.
  • Loading branch information
thockin committed Jun 13, 2024
1 parent d4d411c commit 29ee9bc
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions test_e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2364,17 +2364,24 @@ function e2e::webhook_success() {
# Test webhook fail-retry
##############################################
function e2e::webhook_fail_retry() {
HITLOG="$WORK/hitlog"
local HITLOG="$WORK/hitlog"
local SCRIPT="$WORK/http_resp.sh"
touch "$SCRIPT"
chmod 755 "$SCRIPT"

# First sync - return a failure to ensure that we try again
cat /dev/null > "$HITLOG"
cat > "$SCRIPT" << __EOF__
#!/bin/sh
read X
echo "HTTP/1.1 500 Internal Server Error"
echo
__EOF__
CTR=$(docker_run \
-v "$HITLOG":/var/log/hits \
-v "$SCRIPT":/http_resp.sh \
e2e/test/ncsvr \
80 'read X
echo "HTTP/1.1 500 Internal Server Error"
echo
')
80 '/http_resp.sh')
IP=$(docker_ip "$CTR")

GIT_SYNC \
Expand All @@ -2392,16 +2399,13 @@ function e2e::webhook_fail_retry() {
assert_file_lines_ge "$HITLOG" 1

# Now return 200, ensure that it gets called
docker_kill "$CTR"
cat /dev/null > "$HITLOG"
CTR=$(docker_run \
--ip="$IP" \
-v "$HITLOG":/var/log/hits \
e2e/test/ncsvr \
80 'read X
echo "HTTP/1.1 200 OK"
echo
')
cat > "$SCRIPT" << __EOF__
#!/bin/sh
read X
echo "HTTP/1.1 200 OK"
echo
__EOF__
sleep 2 # webhooks are async
assert_file_lines_eq "$HITLOG" 1
}
Expand Down

0 comments on commit 29ee9bc

Please sign in to comment.