fix: deflake haproxy bats tests

The byjg/easy-haproxy image polls Docker for label changes every 10
seconds by default, which races with the haproxy bats suite and
intermittently produces curl exit 7. Expose `refresh-conf` as a
global-only haproxy property that maps to `EASYHAPROXY_REFRESH_CONF`,
lower it to 2 seconds in the bats setup, and wrap the localhost HTTP
assertions in a retry loop so checks wait for haproxy to converge
rather than failing on the first attempt.
This commit is contained in:
Jose Diaz-Gonzalez committed 2026-04-30 18:40:57 -04:00
1 parent 8f8a23aac3
commit 53ef8c7780
7 files changed
+81 -13

No files matched your search

+16 -2
View File
@@ -249,10 +249,17 @@ assert_http_success() {
assert_http_localhost_response() {
local scheme="$1" domain="$2" port="${3:-80}" path="${4:-}" content="${5:-}" status_code="${6:-200}"
run curl --connect-to "$domain:$port:localhost:$port" -kSso /dev/null -w "%{http_code}" "$scheme://$domain:$port$path"
local retries="${HTTP_ASSERT_RETRIES:-30}" attempt=1
while [[ "$attempt" -lt "$retries" ]]; do
run curl --connect-to "$domain:$port:localhost:$port" -kSso /dev/null -w "%{http_code}" "$scheme://$domain:$port$path"
[[ "$output" == "$status_code" ]] && break
sleep 1
attempt=$((attempt + 1))
done
echo "curl: curl --connect-to $domain:$port:localhost:$port -kSso /dev/null -w %{http_code} $scheme://$domain:$port$path"
echo "output: $output"
echo "status: $status"
echo "attempts: $attempt"
assert_output "$status_code"
if [[ -n "$content" ]]; then
@@ -265,10 +272,17 @@ assert_http_localhost_response() {
assert_http_localhost_response_contains() {
local scheme="$1" domain="$2" port="${3:-80}" path="${4:-}" content="${5:-}" status_code="${6:-200}"
run curl --connect-to "$domain:$port:localhost:$port" -kSso /dev/null -w "%{http_code}" "$scheme://$domain:$port$path"
local retries="${HTTP_ASSERT_RETRIES:-30}" attempt=1
while [[ "$attempt" -lt "$retries" ]]; do
run curl --connect-to "$domain:$port:localhost:$port" -kSso /dev/null -w "%{http_code}" "$scheme://$domain:$port$path"
[[ "$output" == "$status_code" ]] && break
sleep 1
attempt=$((attempt + 1))
done
echo "curl: curl --connect-to $domain:$port:localhost:$port -kSso /dev/null -w %{http_code} $scheme://$domain:$port$path"
echo "output: $output"
echo "status: $status"
echo "attempts: $attempt"
assert_output "$status_code"
if [[ -n "$content" ]]; then