From 3f78887e3a919bc589a84bd9ef9f7b178a89f087 Mon Sep 17 00:00:00 2001 From: mhx Date: Fri, 31 Jul 2026 19:26:47 +0200 Subject: [PATCH] :bug: e2e: do not fail a scenario on a single slow response The new -m 1 is right for the polling helpers, where a timed out request is just another attempt, but the assertions and the mock control plane have no retry: one request that takes over a second on a loaded runner fails the scenario, and since common.sh runs under set -euo pipefail a timed out lapi_add_decision aborts it before the decision even exists. Bound the connect at 1s instead and give the whole request 5s in the seven places that get a single attempt. Nothing waits longer on the happy path. --- tests/e2e/mock/lib/common.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/e2e/mock/lib/common.sh b/tests/e2e/mock/lib/common.sh index 7699c6d..1e7142f 100644 --- a/tests/e2e/mock/lib/common.sh +++ b/tests/e2e/mock/lib/common.sh @@ -76,6 +76,8 @@ ensure_mock() { } # Poll a URL until it returns the expected status code, or fail. +# The tight -m is free here: a timed out request is just another attempt. The one shot +# assertions below use a larger one, where a single slow response fails the test. # Usage: wait_for_status URL CODE [TIMEOUT_SECONDS] [curl args...] wait_for_status() { local url="$1" expected="$2" timeout="${3:-15}" @@ -119,7 +121,7 @@ assert_status() { local url="$1" expected="$2" shift 2 || true local got - got=$(curl -s -m 1 -o /dev/null -w '%{http_code}' "$@" "$url") + got=$(curl -s --connect-timeout 1 -m 5 -o /dev/null -w '%{http_code}' "$@" "$url") if [[ "$got" != "$expected" ]]; then echo "assert_status: $url expected $expected, got $got" >&2 return 1 @@ -132,7 +134,7 @@ assert_header() { local url="$1" header="$2" expected="$3" shift 3 || true local got - got=$(curl -s -m 1 -D - -o /dev/null "$@" "$url" | tr -d '\r' \ + got=$(curl -s --connect-timeout 1 -m 5 -D - -o /dev/null "$@" "$url" | tr -d '\r' \ | awk -v h="${header,,}" -F': ' 'tolower($1) == h { print $2; exit }') if [[ "$got" != "$expected" ]]; then echo "assert_header: $url header $header expected \"$expected\", got \"$got\"" >&2 @@ -146,7 +148,7 @@ assert_body_contains() { local url="$1" needle="$2" shift 2 || true local body - body=$(curl -s -m 1 "$@" "$url") + body=$(curl -s --connect-timeout 1 -m 5 "$@" "$url") if ! grep -q "$needle" <<<"$body"; then echo "assert_body_contains: $url expected to contain \"$needle\", got:" >&2 echo "$body" >&2 @@ -158,20 +160,20 @@ assert_body_contains() { lapi_add_decision() { local ip="$1" type="${2:-ban}" duration="${3:-4h}" - curl -sS -m 1 -X POST "http://127.0.0.1:${LAPI_PORT}/admin/decisions?ip=${ip}&type=${type}&duration=${duration}" >/dev/null + curl -sS --connect-timeout 1 -m 5 -X POST "http://127.0.0.1:${LAPI_PORT}/admin/decisions?ip=${ip}&type=${type}&duration=${duration}" >/dev/null } lapi_delete_decision() { local ip="$1" - curl -sS -m 1 -X DELETE "http://127.0.0.1:${LAPI_PORT}/admin/decisions?ip=${ip}" >/dev/null + curl -sS --connect-timeout 1 -m 5 -X DELETE "http://127.0.0.1:${LAPI_PORT}/admin/decisions?ip=${ip}" >/dev/null } lapi_set_stream_fail() { - curl -sS -m 1 -X POST "http://127.0.0.1:${LAPI_PORT}/admin/stream-fail" >/dev/null + curl -sS --connect-timeout 1 -m 5 -X POST "http://127.0.0.1:${LAPI_PORT}/admin/stream-fail" >/dev/null } lapi_clear_stream_fail() { - curl -sS -m 1 -X DELETE "http://127.0.0.1:${LAPI_PORT}/admin/stream-fail" >/dev/null + curl -sS --connect-timeout 1 -m 5 -X DELETE "http://127.0.0.1:${LAPI_PORT}/admin/stream-fail" >/dev/null } # --- stack lifecycle ---------------------------------------------------------