fix: eliminate port TOCTOU race and framed test compile failure breaking CI (#767)#774
Conversation
…dr from start() Two test failures on macOS CI, both introduced by switching to nextest (#761): 1. diagnostics.rs — free_port() + TEST_LOCK failed because nextest runs each test as its own process: the static AtomicU16 resets to 19100 per process, so concurrent tests pick the same starting port → 'Address already in use'. Fix: DiagnosticsServer::start() now returns (JoinHandle<()>, SocketAddr). Tests use "127.0.0.1:0" and read the OS-assigned port from the result. Removes free_port(), TEST_LOCK, and all per-test port management. 2. framed.rs — FormatProcessor::Passthrough became a struct variant in #755 but 3 EOF-flush tests were not updated → test compile failure on master. Fix: use FormatProcessor::passthrough(stats.clone()). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThe pull request updates Possibly related PRs
Comment |
Summary
Fixes two test failures on macOS/Linux CI introduced by the nextest switch in #761:
1.
diagnostics.rs—Address already in useon macOSfree_port()+TEST_LOCKassumed shared process state, but nextest runs each test as its own process. Thestatic AtomicU16resets to 19100 per process, so concurrent test processes pick the same starting port.Fix:
DiagnosticsServer::start()now returns(JoinHandle<()>, SocketAddr)so the actual OS-assigned port is available without a separate probe step. Tests use"127.0.0.1:0"and extract the port from the returnedSocketAddr. Removesfree_port(),TEST_LOCK, and all per-test port management — no more TOCTOU window.2.
framed.rs— test compile failureFormatProcessor::Passthroughbecame a struct variant in #755 but 3 EOF-flush tests were not updated. Tests now useFormatProcessor::passthrough(stats.clone()).Test plan
cargo test -p logfwd-iopasses locally (previously failed to compile)DiagnosticsServerAPI is internal to the binary🤖 Generated with Claude Code