fix(tests): stop parallel tests colliding (release run 3309) #49

Merged
whitlocktech merged 1 commits from fix/live-shard-test-race into main 2026-11-27 22:13:59 -06:00
Member

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 no v0.8.2 tag 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:

  1. The live-launch test's shell forked. sh -c 'sleep 30; :' ServUO.exe forks a child to run sleep. Until that child execs, it is a copy of sh with the same argv (which names ServUO.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 the read builtin on a stdin pipe the test holds, so it never forks.
  2. The empty-tree test could see that child mid-exit. nothing_is_running_out_of_an_empty_tree could catch it after its cmdline was read but after its cwd was gone, which classifies as an Unknown match. Both tests that scan the real process table now take a shared lock.
  3. TempDir names collided. Directory names were pid + nanoseconds, created with create_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, and expect(rel) panics). A per-process counter now makes the name unique, and create_dir fails rather than silently sharing a directory that already exists.

Production behaviour is unchanged. find_running is untouched, and the only effect on real installs is that TempDir names 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:

    build runs red runs failing tests
    main 100 3 overlay ×3
    fix 1 only 100 5 overlay ×5
    fixes 1 + 2 100 3 overlay ×3
    1–3 (this PR) 200 0 —

    One 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

  • I have read CONTRIBUTING.md.
  • The change builds and existing tests/checks pass locally.
  • I have added or updated tests/docs where it makes sense. (Test-only plus an internal scratch-dir name; no operator-facing docs change.)
  • My commits are reasonably scoped with clear messages.

AI-assisted contributions (required)

  • No AI tools were used to produce this contribution.
  • AI tools were used. Tool(s): Claude Code (Claude Opus 5.5). I have reviewed and understand
    every change, and take responsibility for it. AI-authored commits are
    marked with a Co-Authored-By / Assisted-By trailer.

License

  • I agree that my contribution is licensed under this project's 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

## 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 no `v0.8.2` tag 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: 1. **The live-launch test's shell forked.** `sh -c 'sleep 30; :' ServUO.exe` forks a child to run `sleep`. Until that child execs, it is a copy of `sh` with the same argv (which names `ServUO.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 the `read` builtin on a stdin pipe the test holds, so it never forks. 2. **The empty-tree test could see that child mid-exit.** `nothing_is_running_out_of_an_empty_tree` could catch it after its cmdline was read but after its cwd was gone, which classifies as an `Unknown` match. Both tests that scan the real process table now take a shared lock. 3. **`TempDir` names collided.** Directory names were pid + nanoseconds, created with `create_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`, and `expect(rel)` panics). A per-process counter now makes the name unique, and `create_dir` fails rather than silently sharing a directory that already exists. Production behaviour is unchanged. `find_running` is untouched, and the only effect on real installs is that `TempDir` names 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: | build | runs | red runs | failing tests | |---|---|---|---| | `main` | 100 | 3 | overlay ×3 | | fix 1 only | 100 | 5 | overlay ×5 | | fixes 1 + 2 | 100 | 3 | overlay ×3 | | 1–3 (this PR) | 200 | **0** | — | One 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 - [x] I have read [CONTRIBUTING.md](CONTRIBUTING.md). - [x] The change builds and existing tests/checks pass locally. - [x] I have added or updated tests/docs where it makes sense. (Test-only plus an internal scratch-dir name; no operator-facing docs change.) - [x] My commits are reasonably scoped with clear messages. ## AI-assisted contributions (required) - [ ] No AI tools were used to produce this contribution. - [x] AI tools were used. Tool(s): `Claude Code (Claude Opus 5.5)`. I have reviewed and understand every change, and take responsibility for it. AI-authored commits are marked with a `Co-Authored-By` / `Assisted-By` trailer. ## License - [x] I agree that my contribution is licensed under this project's license (**GNU GPL v3.0 or later**), and I have the right to contribute it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_014HJEmd5sBSpNXicS4gmT1t
wtclaude added 1 commit 2026-11-27 22:11:37 -06:00
fix(tests): stop parallel tests colliding (release run 3309)
All checks were successful
PR Checks / rust-gates (pull_request) Successful in 1m49s
5322d0dd5c
Release run 3309 went red on a_live_relative_launch_from_the_root_is_found_by_its_pid
(left 5085, right 5028). Three races between tests running in parallel, none in the
installer's behaviour:

- The live-launch test's `sh -c 'sleep 30; :'` forks to run sleep. Until it execs, the
  fork is a copy of sh with the same argv (naming ServUO.exe) and cwd - a genuine second
  match the scan could report first. The shell now waits in the `read` builtin on a stdin
  pipe the test holds, so it never forks.
- nothing_is_running_out_of_an_empty_tree could catch that child mid-exit (cmdline read,
  cwd gone) as an Unknown match. Both process-table tests now take a shared lock.
- TempDir named directories pid + nanoseconds and used create_dir_all, so two parallel
  tests with one prefix could share a directory and delete each other's files (the overlay
  tests' intermittent failures). A per-process counter now makes the name unique, and
  create_dir fails rather than sharing a directory that already exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014HJEmd5sBSpNXicS4gmT1t
whitlocktech approved these changes 2026-11-27 22:13:54 -06:00
whitlocktech merged commit 5aac40da5d into main 2026-11-27 22:13:59 -06:00
whitlocktech deleted branch fix/live-shard-test-race 2026-11-27 22:14:00 -06:00
Sign in to join this conversation.
No description provided.