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

+39 -7
View File
@@ -7,6 +7,7 @@ setup() {
dokku nginx:stop
dokku haproxy:set --global letsencrypt-server https://acme-staging-v02.api.letsencrypt.org/directory
dokku haproxy:set --global letsencrypt-email
dokku haproxy:set --global refresh-conf 2
dokku haproxy:start
create_app
}
@@ -15,6 +16,7 @@ teardown() {
global_teardown
destroy_app
dokku haproxy:stop
dokku haproxy:set --global refresh-conf
dokku nginx:start
}
@@ -32,6 +34,42 @@ teardown() {
assert_output "$help_output"
}
@test "(haproxy) refresh-conf" {
run /bin/bash -c "dokku haproxy:set $TEST_APP refresh-conf 2"
echo "output: $output"
echo "status: $status"
assert_failure
assert_output_contains "can only be set globally"
run /bin/bash -c "dokku haproxy:set --global refresh-conf 5"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku haproxy:report --global --haproxy-refresh-conf"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "5"
run /bin/bash -c "dokku haproxy:show-config"
echo "output: $output"
echo "status: $status"
assert_success
assert_output_contains "EASYHAPROXY_REFRESH_CONF=5"
run /bin/bash -c "dokku haproxy:set --global refresh-conf"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku haproxy:report --global --haproxy-refresh-conf"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "10"
}
@test "(haproxy) log-level" {
run /bin/bash -c "dokku haproxy:set --global log-level DEBUG"
echo "output: $output"
@@ -60,11 +98,7 @@ teardown() {
echo "status: $status"
assert_success
run /bin/bash -c "curl --silent $(dokku url $TEST_APP)"
echo "output: $output"
echo "status: $status"
assert_success
assert_output_contains "python/http.server"
assert_http_localhost_response_contains "http" "$TEST_APP.$DOKKU_DOMAIN" "80" "/" "python/http.server"
}
@test "(haproxy) multiple domains" {
@@ -88,8 +122,6 @@ teardown() {
echo "status: $status"
assert_success
sleep 5
run /bin/bash -c "dokku logs $TEST_APP"
echo "output: $output"
echo "status: $status"