Skip to content

test: make waiter deadline regressions deterministic - #269

Merged
smiggleworth merged 2 commits into
mainfrom
test/deterministic-waiter-deadlines
Sep 1, 2026
Merged

test: make waiter deadline regressions deterministic#269
smiggleworth merged 2 commits into
mainfrom
test/deterministic-waiter-deadlines

Conversation

@smiggleworth

Copy link
Copy Markdown
Contributor

Summary

Replace real sleeps in two cloud waiter deadline regressions with explicit registration instants. A test-only response-router seam preserves the production registration path while allowing the tests to represent one expired waiter and one live waiter deterministically.

Production routing, deadline, durability, and cloud behavior are unchanged.

Why are you making this contribution?

Final-main Platform CI run https://github.com/cntryl/midge/actions/runs/33530091023 passed Windows but failed macOS after scheduler overshoot caused both nominally live waiters to expire in two unit tests. The tests used a 200 ms runtime timeout plus 150 ms and 75 ms sleeps, leaving no scheduling margin on a loaded macOS runner.

Linked issues

No issue: this is a test-only follow-up to the red final-main macOS Platform attempt after PR #268.

Acceptance audit

  • Criterion: Deadline regressions represent expired and live waiters without relying on wall-clock sleeps or scheduler timing.
    Evidence: should_use_latest_surviving_waiter_deadline_given_older_waiter_already_expired and should_preserve_later_segment_waiter_when_earlier_gap_waiter_expired each passed 50 of 50 focused repetitions, and the full all-features workspace suite passed.
    Production entry point: ResponseRouter::register still records Instant::now; the injected registration time is compiled only for tests and exercises the same pending-request state.
    Resolution: Register the old waiters six seconds in the past and the live waiters 250 ms in the past against a five-second timeout.

Risk and compatibility

Low risk. The shipping registration method delegates to an unchanged private implementation using Instant::now. The only exposed seam is cfg(test), and no persistence format, public API, runtime protocol, or production deadline behavior changes.

Verification

  • cargo test --workspace --all-features
  • should_use_latest_surviving_waiter_deadline_given_older_waiter_already_expired: 50 of 50 focused repetitions passed
  • should_preserve_later_segment_waiter_when_earlier_gap_waiter_expired: 50 of 50 focused repetitions passed
  • cargo clippy --workspace --all-targets --all-features -- -D warnings -D clippy::pedantic
  • cargo fmt --check
  • cntryl-tools validate-tests: 2579 of 2579 tests compliant
  • git diff --cached --check

Tool assistance disclosure

  • AI or another generative tool materially assisted this contribution.

Codex inspected the hosted macOS failure, reproduced and stress-ran the affected tests, implemented the test-only timing seam, and ran the reported verification.

Contributor responsibility

  • I understand the complete change and can explain or revise it.
  • I reviewed the complete diff.
  • I reported validation accurately and did not claim checks I did not run.
  • I disclosed material generated assistance.
  • I have the right to submit this work under the repository license.

Copilot AI lite review requested due to automatic review settings September 1, 2026 16:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes two cloud waiter deadline regression tests deterministic by removing real sleep calls and instead controlling the router’s registration instant in test builds. It adds a small cfg(test) seam to ResponseRouter while keeping the production registration path (Instant::now()) unchanged.

Changes:

  • Refactor ResponseRouter::register to delegate to a shared register_at(...) implementation.
  • Add ResponseRouter::register_at_for_test(...) (test-only) to allow deterministic waiter age modeling in unit tests.
  • Update two cloud integration unit tests to remove wall-clock sleeps and use explicit registered_at instants (expired vs live waiter).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/runtime/router.rs Introduces an internal register_at helper and a cfg(test) test seam for injecting registration instants without changing production behavior.
src/runtime/event_loop/cloud_integration/tests.rs Replaces timing sleeps with deterministic registration instants to model expired/live waiters reliably.
Suppressed comments (1)

src/runtime/event_loop/cloud_integration/tests.rs:6678

  • runtime_response_timeout is increased from 200ms to 5s here as well. Even though the test no longer sleeps, a 5s timeout can significantly slow CI feedback if a regression causes the waiter routing to hang/timeout. Consider keeping a shorter timeout (consistent with the rest of this module) and adjusting the synthetic registered_at offsets accordingly.
    el.runtime_response_timeout = Duration::from_secs(5);
    append_cloud_async_put(&mut el)?;
    let (first_segment, first_max_sequence) = seal_segment_without_remote_proof_for_test(&mut el)?;
    append_cloud_async_put(&mut el)?;
    let (second_segment, second_max_sequence) =

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/runtime/event_loop/cloud_integration/tests.rs Outdated
@smiggleworth
smiggleworth merged commit 115bf31 into main Sep 1, 2026
4 checks passed
@smiggleworth
smiggleworth deleted the test/deterministic-waiter-deadlines branch September 1, 2026 16:41
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.

2 participants