fix(tests): stop parallel tests colliding (release run 3309) #49
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/live-shard-test-race"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What & why
Release run 3309 (
v0.8.2) went red on one test,servuo::tests::a_live_relative_launch_from_the_root_is_found_by_its_pid(left: 5085, right: 5028). Nothing was tagged or released: there is nov0.8.2tag on origin. Merging this re-triggers the release, which recomputes 0.8.2.The failure comes from three races between tests running in parallel. The installer's own behaviour is not involved:
sh -c 'sleep 30; :' ServUO.exeforks a child to runsleep. Until that child execs, it is a copy ofshwith the same argv (which namesServUO.exe) and the same cwd. That is a genuine second match, and the scan's HashMap order sometimes reports it first. The shell now waits in thereadbuiltin on a stdin pipe the test holds, so it never forks.nothing_is_running_out_of_an_empty_treecould catch it after its cmdline was read but after its cwd was gone, which classifies as anUnknownmatch. Both tests that scan the real process table now take a shared lock.TempDirnames collided. Directory names were pid + nanoseconds, created withcreate_dir_all. Two parallel tests with one prefix could read the same nanosecond, share the directory, and delete each other's files. This caused the overlay tests' intermittent failures (left: 6, right: 7, andexpect(rel)panics). A per-process counter now makes the name unique, andcreate_dirfails rather than silently sharing a directory that already exists.Production behaviour is unchanged.
find_runningis untouched, and the only effect on real installs is thatTempDirnames gain the counter.How it was tested
Windows (native):
cargo fmt --check,cargo clippy --locked --all-targets -- -D warnings,cargo test --locked. All clean; 188 + 9 pass.Linux (WSL2 Ubuntu 24.04, dash as
sh, the same shell as CI): the same three commands, all clean, 192 + 9 pass.Stress on Linux: full lib suite, every core busy with spin loops:
mainOne earlier run with fix 1 alone failed
nothing_is_running_out_of_an_empty_tree, which led to fix 2.Not reproduced locally: the exact 3309 failure (the forked-child pid mismatch) did not show up in these runs. Fix 1 rests on the CI log plus reading the code: the only process that can match that root under a different pid is the shell's own pre-exec fork. A new regression test (
temp_dirs_made_at_once_on_many_threads_never_share_a_path) covers fix 3.Checklist
AI-assisted contributions (required)
Claude Code (Claude Opus 5.5). I have reviewed and understandevery change, and take responsibility for it. AI-authored commits are
marked with a
Co-Authored-By/Assisted-Bytrailer.License
(GNU GPL v3.0 or later), and I have the right to contribute it.
🤖 Generated with Claude Code
https://claude.ai/code/session_014HJEmd5sBSpNXicS4gmT1t