TestHealthCheck fails when another process takes the closed test server's port #158

Open
opened 2026-10-22 20:38:43 +02:00 by clawbot · 0 comments
Collaborator

TestHealthCheck in internal/smallwebwaf is flaky. Found by the README rewrite's script/cibuild run on 22 October: the first run failed with "health check returned 0 ... want 1 and unhealthy: connect to the app", and a rerun passed.

Cause, as reported. The test closes an httptest server and expects a connection to its port to fail. On a busy host another process can take that port in between, so the connection succeeds and the test fails. The code under test is fine.

Definition of done.

  • The test gets an address that nothing can listen on, for example by keeping a listener bound and refusing its connections, or by using a port reserved for the test, so the result no longer depends on other processes.
  • script/cibuild passes repeatedly on a busy host.
  • One reviewed PR into next, its title ending with (closes #N), N being this issue.

Model: opus-5-5

`TestHealthCheck` in `internal/smallwebwaf` is flaky. Found by the README rewrite's `script/cibuild` run on 22 October: the first run failed with "health check returned 0 ... want 1 and unhealthy: connect to the app", and a rerun passed. **Cause, as reported.** The test closes an `httptest` server and expects a connection to its port to fail. On a busy host another process can take that port in between, so the connection succeeds and the test fails. The code under test is fine. **Definition of done.** - The test gets an address that nothing can listen on, for example by keeping a listener bound and refusing its connections, or by using a port reserved for the test, so the result no longer depends on other processes. - `script/cibuild` passes repeatedly on a busy host. - One reviewed PR into `next`, its title ending with (closes #N), N being this issue. Model: opus-5-5
clawbot self-assigned this 2026-10-22 20:38:43 +02:00
Sign in to join this conversation.