Skip to content

test(wedge): make wedge_detection_returns_wedged_on_recv_timeout deterministic (#717) - #730

Merged
zackees merged 1 commit into
mainfrom
fix/717-wedge-test-deterministic
Jun 14, 2026
Merged

zackees merged 1 commit into
mainfrom
fix/717-wedge-test-deterministic

Conversation

@zackees

@zackees zackees commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

The flaky test (#717) measured std::time::Instant::elapsed() against a 3 s wall-clock bound after a 1 s wedge budget. On loaded CI runners the post-timeout return path crossed the 2 s margin and tripped the assert (observed three times on PRs #713 and #716, passing on rerun each time).

Switch to #[tokio::test(start_paused = true)] + tokio::time::Instant so the fake's sleep(budget) auto-advances tokio-virtual time the moment no other tasks are ready. Elapsed is now deterministic — exactly the configured budget regardless of host load — so the assertion can test fail-fast behaviour with both lower and upper bounds (1 s ≤ elapsed < 1.1 s).

tokio/test-util is added as a dev-dependency feature on the zccache crate (dev-only — does not bloat production builds).

Changes

  • crates/zccache/src/cli/commands/wrap/ipc.rs: pause tokio time in the wedge-timeout test; measure with tokio::time::Instant; tighten elapsed bound to [1 s, 1.1 s).
  • crates/zccache/Cargo.toml: add tokio = { workspace = true, features = ["test-util"] } to [dev-dependencies].

Test plan

  • soldr cargo test -p zccache --lib cli::commands::wrap::ipc::tests::wedge — 4/4 pass locally (Windows)
  • soldr cargo clippy -p zccache --all-targets -- -D warnings — clean
  • soldr cargo fmt --all --check — clean
  • CI on this PR (Linux + macOS + Windows)

Closes #717

🤖 Generated with Claude Code

…rministic

The flaky test (#717) measured `std::time::Instant::elapsed()` against a
3 s wall-clock bound after a 1 s wedge budget. On loaded CI runners the
post-timeout return path crossed the 2 s margin and tripped the assert
(observed three times on PRs #713 and #716, passing on rerun each time).

Switch to `#[tokio::test(start_paused = true)]` + `tokio::time::Instant`
so the fake's `sleep(budget)` auto-advances tokio-virtual time the
moment no other tasks are ready. Elapsed is now deterministic — exactly
the configured budget regardless of host load — so the assertion can
test fail-fast behaviour with both lower and upper bounds.

`tokio/test-util` is added as a dev-dependency feature on the `zccache`
crate (dev-only — does not bloat production builds).

Closes #717

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees merged commit f0a2b14 into main Jun 14, 2026
26 checks passed
@zackees
zackees deleted the fix/717-wedge-test-deterministic branch June 14, 2026 05:50
zackees added a commit that referenced this pull request Jun 14, 2026
Ships four PRs that landed on top of 1.12.2:

- #730 — test(wedge): deterministic `wedge_detection_returns_wedged_on_recv_timeout`
- #731 — diagnostics(persist): enrich the `os error 2` WARN with src/dst/errno/exists/size/gap_ms (#728 criterion 1)
- #732 — fix(meson): allowlist configure outputs, skip-persist on no-op, purge meson-configure on clear (closes #710, KEY_DOMAIN_TAG v2->v3)
- #733 — test(daemon): synthetic burst-link reproducer for #726 (closes #729)

Closes #710, #729 (already closed on merge); ships the #728/#731 diagnostics so the next FastLED `all-with-examples` repro can capture rich logs for criteria #2–#3.

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request Jun 14, 2026
#745) (#746)

* test(wedge): plumb wedge budget as parameter to eliminate env-var race (#745)

The four `wedge_detection_*` unit tests in `wrap::ipc::tests` each
mutated the process-global `ZCCACHE_WEDGE_RECV_TIMEOUT_SECS` env var
to inject a 1 s or 0 s budget. `cargo test` runs them in parallel, so
when one test called `remove_var` between another test's `set_var`
and the recv, `wedge_recv_timeout()` fell through to its 180 s default.
Under `#[tokio::test(start_paused = true)]` virtual time then advanced
180 s during the fake's `sleep(budget)` and the assertion's upper bound
(`elapsed < 1.1 s`) tripped — symptom seen on PR #744's Windows runner.

PR #730 made the elapsed measurement deterministic against the configured
budget, but did not address the env-var race that made the configured
budget itself non-deterministic.

Fix: refactor `compile_recv_with_wedge_detection` to take an explicit
`Option<Duration>` budget parameter. Production callers (`cmd_compile`,
`cmd_compile_ephemeral`, `cmd_link_ephemeral`) pass `wedge_recv_timeout()`
so the `ZCCACHE_WEDGE_RECV_TIMEOUT_SECS` knob still works for users.
Tests pass a constant `Some(Duration::from_secs(1))` (or `None` for the
disabled path) directly — no env mutation, no race.

Renames `wedge_detection_disabled_when_env_is_zero` →
`wedge_detection_disabled_when_budget_is_none` since the test no longer
exercises the env var.

Closes #745
Refs #717, #730, #666

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* style(cache_ops): inline format literal in cache list header

Drive-by clippy fix to unblock CI on #745. The new `zccache cache list`
header (#742) had a trailing "path" literal as a format arg; clippy's
`print_literal` lint wants it inlined. Pure mechanical refactor.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

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.

flaky test: wedge_detection_returns_wedged_on_recv_timeout (timing-sensitive recv_timeout)

1 participant