Flaky: proposal_apply_tests aborts a plain cargo test run intermittently, truncating the suite #82
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Context
Found while verifying the #53 follow-up (PR #81). Pre-existing — it reproduces on
main@37c8101, which predates the follow-up work.tests/proposal_apply_tests.rs::every_step_applied_marks_the_proposal_applied_and_replays_under_the_same_keyintermittently aborts a plaincargo testrun instead of failing an assertion.Evidence
main@37c8101: 8/10 green on the affected binary; the same loop on the PR head gave 9/10 — i.e. the flake is not introduced by that PR.--no-fail-fast).mainat1dfffa8: the summed pass count came out at 632 instead of the true 782, because cargo's default fail-fast stops the remaining test binaries once one fails. The re-run with a clean machine reported 782 passed / 0 failed, exit 0.Why it matters
A flake that aborts rather than fails is worse than an ordinary flaky assertion:
cargo teststops early, so unrelated suites never run in that invocation.What to investigate
nix develop --command cargo test --test proposal_apply_tests) and record the failure rate, then loop the single test.busy/lock timeout, or a tokio runtime shutdown racing an in-flight task) rather than a plain assertion.Root cause (found and fixed)
The test helper regenerated the approval body for every call, and that body's
approval.reviewed_atis formatted with second precision (Utc::now().to_rfc3339_opts(SecondsFormat::Secs, true)). When the initial apply and the same-key replay straddled a second boundary, the body — and therefore the request fingerprint — changed, so the service correctly answered 409idempotency_conflict. The test panicked attests/proposal_apply_tests.rs:1035; cargo's default fail-fast then stopped the remaining test binaries, which is why a summed count read 632 instead of the true total. My original "abort" framing was wrong and the reviewer reconciled it: it was a panic (binary exit 101) causing truncation, not a signal, and no residual nondeterminism remains.Reproduction: 100% failure (exit 101) when a ≥1.0 s delay forces the second boundary to be crossed; naturally 8–9 runs in 10 green.
Fix (tests-only, PR #84): reuse the exact approval bytes across the replay instead of regenerating them — a new
Env::apply_with_approvalhelper used by all three replay tests. The clock is not frozen globally, sothe_same_key_with_a_changed_request_is_an_idempotency_conflictstill constructs a genuinely divergent body and still gets its 409. No assertion weakened; no production code touched.Verified: reviewer's own 20/20 consecutive green runs of
cargo test --test proposal_apply_tests(21 passed each), plus a plaincargo testcompleting the full suite (798 passed, exit 0) — the truncation failure mode is gone.Acceptance criteria
cargo test(no--no-fail-fast) reports the full suite total, so a truncated run can no longer be mistaken for a green one.