Skip to content

test: fix flaky TestAddModuleWorkerViaAdminApi - #2605

Merged
alexandre-daubois merged 2 commits into
mainfrom
fix/flaky-worker-admin-api-test
Aug 16, 2026
Merged

test: fix flaky TestAddModuleWorkerViaAdminApi#2605
alexandre-daubois merged 2 commits into
mainfrom
fix/flaky-worker-admin-api-test

Conversation

@dunglas

@dunglas dunglas commented Aug 15, 2026

Copy link
Copy Markdown
Member

Summary

TestAddModuleWorkerViaAdminApi POSTs a full config to the admin /load endpoint, which swaps the HTTP listener for the new config, then immediately GETs the newly added worker. A request racing that listener swap can hit a reset connection (EOF) before the worker ever sees it — seen on CI in php/frankenphp#2604 (job 94991854286), and matches the same class of flake fixed for the sibling autoscale tests in #2413 (which references this test too, on #2412/#2381).

Retry only on connection-level errors (err != nil from http.Get), not on the request/response itself: once a request actually reaches the worker it always increments its counter, so retrying past a successful connection would break the requests:1 assertion.

Test plan

  • ./go.sh -C caddy test ./... passes
  • ./go.sh -C caddy test ./... -run TestAddModuleWorkerViaAdminApi -count=5 passes

The test POSTs a full config to the admin /load endpoint, which swaps
the HTTP listener for the new config, then immediately GETs the newly
added worker. A request racing that swap can hit a reset connection
(EOF) before the worker ever sees it, as seen on CI
(#2604 CI run, and previously on #2412/#2381 per #2413
for the sibling autoscale tests).

Retry only on connection-level errors, not on the request itself: once
a request reaches the worker it always increments its counter, so
retrying past that point would break the "requests:1" assertion.
Comment thread caddy/admin_test.go Outdated
Comment on lines +356 to +362
for i := 0; i < 20; i++ {
getResp, err = http.Get(workerURL)
if err == nil {
break
}
time.Sleep(50 * time.Millisecond)
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use require.Eventually

Matches the existing retry idiom used elsewhere in this codebase
(frankenphp_test.go, finishrequest_realserver_test.go,
worker_internal_test.go, caddy/watcher_test.go, caddy/caddy_test.go)
instead of a bespoke for-loop.
@alexandre-daubois
alexandre-daubois merged commit 3122341 into main Aug 16, 2026
32 checks passed
@alexandre-daubois
alexandre-daubois deleted the fix/flaky-worker-admin-api-test branch August 16, 2026 10:40
@alexandre-daubois

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants