Repository navigation
test(broker-v2): race N concurrent starters, assert exactly one singleton survivor (soldr#2361 Phase 1) - #899
Conversation
…eton survivor Closes the gap between the existing is_already_bound_error unit tests (error-classification only) and soldr#2363's testing invariant: N concurrent broker-v2 starters on the same program/user must yield exactly one bound survivor, with every other starter exiting EX_TEMPFAIL (75) cleanly. Runs against the host's real transport (named pipes on Windows, unix sockets elsewhere) with no cfg gate needed -- the bind/refuse code path in main() is identical on every platform. Stable across repeated local runs. The single-instance enforcement itself already existed in running-process-broker-v2::main; this only adds the missing process-level race test. Co-Authored-By: Claude Fable 5 <[email protected]>
…ket on startup CI on running-process#899 caught the real bug the new singleton race test was written to catch: 5 concurrent broker-v2 starters on Linux all reported 'bound at' and the test's own assertion (exactly one survivor) failed with left=5, right=1. Root cause: on Unix, main() unconditionally ran 'let _ = std::fs::remove_file(&socket_path);' before every bind attempt, regardless of whether the path was actually stale (orphaned by a crashed process) or live (another starter's active listener). Under a real concurrent-start race each of the N starters, in turn, deleted the current winner's live socket file out from under it and rebound over the freed path -- so every starter observed a successful bind. Fix: never unlink up front. Attempt bind first. Only on an already-bound-classified failure, connect-probe the path (unix_socket_path_is_stale): ConnectionRefused/NotFound means orphaned and safe to remove + retry once; a successful connect (or anything else) means a live peer owns it, so leave it alone and report the already-bound refusal as before. Windows is unaffected -- the named pipe namespace is kernel-managed and was never touched by this cleanup step. Also bumps platform_compliance_baseline.toml's RP-RAW-STDIO-014 debt allowance for broker_v2_scaffold_accepts_connection.rs (9 -> 11) to cover the 2 new Stdio uses in the singleton race test the guard flagged on the same CI run. Co-Authored-By: Claude Fable 5 <[email protected]>
|
The concurrent-starter race test (this PR) caught a real bug on Linux/macOS/musl CI, not test flakiness: all 5 starters reported Root cause: Fixed in the latest commit: bind is attempted first with no pre-emptive unlink; only on an already-bound failure does a connect-probe ( Windows is unaffected — the named pipe namespace never had this cleanup step. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
What this is
Closes a testing gap for zackees/soldr#2361 Phase 1 / soldr#2363: the single-instance (singleton-per-user-session) enforcement in
running-process-broker-v2::mainalready existed — bind failure classified viais_already_bound_errorrefuses startup withEX_TEMPFAIL (75)— but only the error-classification helper had unit tests. #2363's testing invariants ask for it to be race-tested (N concurrent starters → exactly one survivor), which this PR adds.What it does
Spawns 5 real
running-process-broker-v2child processes concurrently with the same--programname (same user session), then classifies each by whether it printedbound aton stdout (winner) or exitedEX_TEMPFAIL(75)(loser). Asserts exactly 1 winner and 4 losers.No
cfggate: the bind/refuse code path inmain()is identical on every platform (interprocess crate abstracts Windows named pipes vs. unix sockets underneath), so this runs against the host's real transport everywhere.Stable across 4 repeated local runs (Windows).
Testing