Repository navigation
test(cli): wait for the server's own listening line and retry on a port race - #402
Merged
Merged
Conversation
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fix the intermittent
tole servetest failures ("serve never became healthy") by making the spawn helpers race-free.Why
serve_http_hardeningfailed about 1 run in 6 on develop. Reproduced and captured: the harness picks a port by binding127.0.0.1:0and closing it; beforetole servebinds it, the same ephemeral port can be taken by another test's client socket. The server then exits withbinding 127.0.0.1:52603 (in use? change --port): Address already in useand the health poll times out. The same pattern sits in four harnesses;serve_approvalsalso used fixed ports.Changes
tests/common/mod.rs(new):spawn_listeningbuilds the command for a candidate port, pipes its stderr, waits for the server's own "listening on" line (proof this process bound the port, not a stranger answering on it) and, if the process exits first, retries on a fresh port (5 attempts). Stderr is forwarded so it still appears in failure reports.serve_http_hardening,mcp_http_hardening,serve_approvals(no more fixed ports) andserve_session_canceluse it.Testing
serve_http_hardening+mcp_http_hardening15 times in a row: 0 failures (before: about 1 in 6).serve_approvals+serve_session_cancel3 times: green.