Skip to content

test(log): take the second server's port when it binds it - #301

Merged
EdmondDantes merged 1 commit into
mainfrom
log-tests-late-second-port
Aug 25, 2026
Merged

EdmondDantes merged 1 commit into
mainfrom
log-tests-late-second-port

Conversation

@EdmondDantes

Copy link
Copy Markdown
Contributor

core/014-log-emit-on-start-stop and core/015-log-multipart-debug each start a second server after the first has run its whole lifecycle. Both took tas_free_port_span(2) up front and gave the second server $port + 1. A span reserves by binding and closing, so that port is owned by nobody for the hundreds of milliseconds the first phase takes, and under -j4 another test claims it. The second start() then throws Failed to acquire TCP listener for 127.0.0.1:58864 (bind).

This hid behind run-tests' retry: usleep( in a FILE section makes is_flaky() true, so the test is retried on any first-attempt failure and the report says only "passed on retry attempt". The first attempt's output is never shown, which is why the two tests read as timing noise for as long as they did.

Each server now calls tas_free_port() at the point it binds.

Evidence: the FILE section of 015 extracted and run in a loop beside a full -j4 suite fails on the second copy against main with that bind error, and survives 181 copies with this change, the suite alongside it reporting 0 warned and 0 failed.

Both tests reserved two ports with `tas_free_port_span(2)`, ran a whole
server lifecycle on the first, and only then bound the second. A span
reserves by binding and closing, so `$port + 1` is unowned for the
hundreds of milliseconds in between, and under `-j4` another test takes
it: `Failed to acquire TCP listener for 127.0.0.1:58864 (bind)` out of
`$server2->start()`.

The failure was invisible because `usleep(` in the FILE section makes
run-tests treat the test as flaky and retry it, and the retry reports
only "passed on retry attempt" — the first attempt's output is gone.

Each server now takes its port from `tas_free_port()` where it binds it.
Evidence: 015 run in a loop beside a full `-j4` suite fails on the
second copy before the change and survives 181 copies after it, with
the suite itself reporting no warned and no failed tests.
@github-actions

Copy link
Copy Markdown
Contributor

Coverage

Total lines: 83.00% → 82.94% (-0.06 pp)

File Baseline Current Δ Touched
src/core/http_connection.c 81.47% 81.31% -0.16 pp
src/http1/http_parser.c 84.05% 83.68% -0.38 pp
src/http3/http3_callbacks.c 84.39% 84.07% -0.32 pp
src/http3/http3_listener.c 77.36% 77.06% -0.30 pp
src/http3/http3_packet.c 90.43% 85.22% -5.22 pp
src/http3/http3_static_response.c 75.42% 76.67% +1.25 pp
src/http_server_class.c 74.09% 74.05% -0.04 pp
src/websocket/ws_session.c 90.41% 90.04% -0.37 pp

@EdmondDantes
EdmondDantes merged commit 471af17 into main Aug 25, 2026
7 of 8 checks passed
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.

1 participant