Skip to content

fix(test): wait up to 5s for HTTP server startup - #1482

Open
UchihaIthachi wants to merge 1 commit into
containers:mainfrom
UchihaIthachi:test/http-startup-wait
Open

UchihaIthachi wants to merge 1 commit into
containers:mainfrom
UchihaIthachi:test/http-startup-wait

Conversation

@UchihaIthachi

@UchihaIthachi UchihaIthachi commented Oct 8, 2026 •

Copy link
Copy Markdown

Fixes #1445

As noted in the issue, the test HTTP server was sometimes still starting
when tests connected to it. WaitForServer only waited ~500ms (10 × 50ms);
it now polls until a 5s deadline and returns the last dial error on timeout.

httpContext.beforeEach had its own copy of the same loop and continued
silently if the server never started. It now uses the shared helper, dials
127.0.0.1 (which reaches the server for every bind address the tests use),
and fails if the server doesn't come up.

Testing:

  • make build
  • go test -race -count=3 ./internal/test/ ./pkg/http/ ./pkg/kubernetes-mcp-server/cmd/
  • go test -count=20 -run 'TestWellknown|TestBindAddress' ./pkg/http/

Developed with AI assistance; I reviewed and tested all changes.

Comment thread internal/test/test_test.go Outdated
@@ -0,0 +1,37 @@
package test

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

let's not add a test file to test our internal testing helpers....

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Makes sense, removed it. The existing pkg/http tests already exercise WaitForServer

WaitForServer gave up after 10 x 50ms, which is too short on slow
runners such as macos-15-intel. Poll until a 5s deadline instead.

httpContext had its own copy of the same loop and continued silently
if the server never started; use the shared helper and fail instead.

Fixes containers#1445

Signed-off-by: UchihaIthachi <2020thlf@gmail.com>
@UchihaIthachi
UchihaIthachi force-pushed the test/http-startup-wait branch from e684541 to ca77f0f Compare October 8, 2026 13:42
@UchihaIthachi
UchihaIthachi requested a review from Cali0707 October 8, 2026 13:50
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.

Build on macos-15-intel is flaky

2 participants