test: deflake two timing-dependent tests#235
Conversation
Both tests intermittently failed under full-suite concurrency / coverage instrumentation and passed in isolation. shutdown::wait_for_signal_or_trigger_returns_on_internal_trigger relied on two real wall-clock timeouts: a 10ms window to prove the wait was still pending, and a 1s window for it to resolve after the trigger. Under load the 1s bound could be exceeded by a starved task. Replace the 10ms check with a single deterministic poll (no-op waker) — the first poll subscribes the receiver and registers the signal handlers, so with neither fired the future is provably Pending — and await the triggered future directly instead of racing a timeout. events::test_process_rejects_future_notification_rumor dated the event only +1s beyond the future-skew tolerance. process() re-reads Timestamp::now() (1-second granularity) when validating freshness, so a whole-second tick between building the event and that read collapsed the margin onto the exact threshold (> became ==) and spuriously accepted the event. Widen the margin to +1h; there is no injectable clock at the check site, so a drift-proof margin is the deterministic fix without a production API change. Verified 20/20 each under cargo llvm-cov; full suite 647 pass. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
Ready to review this PR? Stage has broken it down into 3 individual chapters for you:
Chapters generated by Stage for commit d252e27 on Jul 5, 2026 2:31pm UTC. |
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 46 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. WalkthroughTwo unit tests are modified to reduce timing-based flakiness: one widens the clock-skew offset used in a future-notification-rumor test, and the other replaces a wall-clock timeout assertion with deterministic polling using a noop waker. ChangesDeterministic Test Timing Fixes
Estimated code review effort: 1 (Trivial) | ~5 minutes Related Issues: None specified Related PRs: None specified Suggested labels: tests, flaky-test-fix Suggested reviewers: None specified Poem: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
✅ Code Coverage Report
View detailed coverageDownload the Or run locally: cargo llvm-cov --html
open target/llvm-cov/html/index.html |
The matches!(poll, Poll::Pending) form introduced an implicit non-matching wildcard arm that the always-Pending poll never exercises, a new uncovered region that tripped the fail-on-any-decrease coverage gate by ~0.0002pp. Use Poll::is_pending() (same assert-on-bool shape as the wall-clock assertion it replaced), which has no uncovered arm. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
name() renders the operator-facing signal label in shutdown logs but was entirely uncovered — it is only invoked inside warn!/info! field expressions, which tracing skips when tests run without a subscriber. A direct unit test covers both match arms, and offsets the coverage the deterministic-poll rewrite removed with the wall-clock assertions (the fail-on-any-decrease gate tripped on the net removal of covered lines, not on the logic change). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
Fixes the two pre-existing intermittent flakes surfaced during the root-cause refactor program (both pass in isolation, fail occasionally under full-suite concurrency / coverage instrumentation).
shutdown::wait_for_signal_or_trigger_returns_on_internal_triggerrelied on two real wall-clock timeouts — a 10ms window to prove the wait was still pending, and a 1s window for it to resolve after the trigger (exceedable when a starved task isn't polled within 1s under load). Now: a single deterministic poll with a no-op waker provesPending(the first poll subscribes the receiver and registers the signal handlers, so with neither fired the future is provably pending), and the triggered future is awaited directly. No wall-clock remains.events::test_process_rejects_future_notification_rumordated the event only+1sbeyond the future-skew tolerance.validate_notification_freshnessre-readsTimestamp::now()(1-second granularity) at process time, so a whole-second tick between building the event and that read collapsed the+1margin onto the exact threshold (>became==) and spuriously accepted the event. Widened to+1h; there's no injectable clock at the check site, so a drift-proof margin is the deterministic fix without a production API change. No assertion weakened — it still exercises thecreated_at > now + skewrejection path.Verified: 20/20 each under
cargo llvm-cov(the instrumentation that surfaced the flakes), full suite 647 pass, clippy-D warningsclean.🤖 Generated with Claude Code
Summary by CodeRabbit