Skip to content

test(daemon): synthetic spawn-storm reproducer for #691 - #738

Merged
zackees merged 1 commit into
mainfrom
feat/691-spawn-coordination
Jun 14, 2026
Merged

zackees merged 1 commit into
mainfrom
feat/691-spawn-coordination

Conversation

@zackees

@zackees zackees commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

Refs #691.

What the test does

parallel_wrappers_must_share_one_daemon fires N=16 (tunable via ZCCACHE_SPAWN_STORM_N) zccache <echo_shim> invocations against a single fresh ZCCACHE_CACHE_DIR, sync'd on a std::sync::Barrier so they race the daemon-spawn decision together. After all complete and the daemon is explicitly stopped, asserts:

  1. Exactly one daemon-spawn-*.log lands in logs/.
  2. Exactly one event:\"spawn\" line lands in daemon-lifecycle.log.

This is the invariant the coordination fix from #691 should establish (named-mutex on Windows / flock on Unix gating ensure_daemon).

Modeled on:

How to run

ZCCACHE_RUN_REPRO_691=1 ./test --integration -- daemon_spawn_storm

Expected outcome on main today: FAIL — multiple spawn-attempt events fire in the racing window before the post-spawn dedup (#640) catches them, and on loaded runners multiple spawn events can land before sibling daemons probe and exit.

Expected outcome after the spawn-coordination fix: PASS with one spawn and one spawn-attempt.

Once the fix lands, drop the ZCCACHE_RUN_REPRO_691 gate so the test joins the standard integration suite as a permanent regression test.

Test plan

  • CI green for the diff (file is pure-additive integration test; unit suite untouched).
  • Manual local run with the gate set, on Windows and Linux, will be performed in the follow-up PR that lands the spawn-coordination fix — the reproducer itself is shipped here so the fix PR can flip the assertion direction.

Note: I could not run soldr cargo check locally in this iteration — the managed zccache 1.11.20 named pipe was saturated by concurrent agents working on adjacent PRs (#736 / #737). The test mirrors cli_single_daemon_per_session.rs very closely and only adds stdlib imports (Arc/Barrier/thread/Instant); risk of a compile error is low.

🤖 Generated with Claude Code

Adds `crates/zccache/tests/daemon_spawn_storm_test.rs` so the #691
spawn-storm class becomes regression-testable without depending on a
heavy parallel rustc workload on a runner. One test:

- `parallel_wrappers_must_share_one_daemon` (#[ignore], integration):
  fires N=16 (tunable via ZCCACHE_SPAWN_STORM_N) parallel zccache
  wrapper invocations against a fresh ZCCACHE_CACHE_DIR, sync'd on a
  std::sync::Barrier so they race the daemon-spawn decision together.
  Asserts exactly one daemon-spawn-*.log lands in logs/ and exactly
  one event:"spawn" line lands in daemon-lifecycle.log. This is the
  invariant the coordination fix from #691 should establish.

Gated on ZCCACHE_RUN_REPRO_691=1 in addition to #[ignore], so it is
a no-op under both `cargo test` (unit) and `cargo test -- --ignored`
(./test --integration). Opt in with:

    ZCCACHE_RUN_REPRO_691=1 ./test --integration -- daemon_spawn_storm

On main today the test is expected to FAIL — multiple spawn-attempt
events fire in the racing window before the post-spawn dedup (#640)
catches them, and on loaded runners multiple spawn events can land.
Once the spawn-coordination fix lands, drop the env-var gate so the
test joins the standard integration suite as a permanent regression.

Modeled on cli_single_daemon_per_session.rs (#323 regression test;
same helpers, same log-inspection pattern) and on the synthetic
daemon_burst_link_test.rs precedent from #729 / #733.

Refs #691.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant