Skip to content

fix(testing): make wait deadline tests deterministic - #10738

Merged
ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:rb-fix-wait-until-deadline
Aug 21, 2026
Merged

ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:rb-fix-wait-until-deadline

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Aug 21, 2026 •

Copy link
Copy Markdown
Member

Closes #10728

The reported failure occurred because the 25 ms test budget could expire before the first predicate invocation under CI load, so the test sometimes skipped the predicate-crossing path it intended to verify.

This change routes the helper's monotonic timestamps, deadline cancellation, and retry delays through an internal TimeProvider seam while production continues to use TimeProvider.System. The deadline tests use FakeTimeProvider plus explicit predicate barriers to cover completion immediately before the deadline, completion at the deadline, legacy predicate settlement, and deadline-token propagation.

The resulting invariant is deterministic: a predicate completion succeeds only while elapsed monotonic time is strictly less than the configured timeout.

Microsoft Reviewers: Open in CodeFlow

Copilot AI lite review requested due to automatic review settings August 21, 2026 08:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 fixes a flaky deadline-boundary test in Orleans’ TestingUtils timing helpers by making the deadline logic testable with a deterministic clock, while keeping production behavior on TimeProvider.System.

Changes:

  • Introduces an internal TimeProvider seam in TestingUtils.WaitUntilAsync/WaitUntilSucceededAsync to drive monotonic timestamps, deadline cancellation, and retry delays.
  • Rewrites the deadline-focused tests to use FakeTimeProvider plus explicit predicate barriers to deterministically validate “success only when elapsed < timeout”.
  • Grants the test assembly access to the new internal overloads via InternalsVisibleTo and adds the required testing package reference.
Show a summary per file
File Description
test/TestInfrastructure/Orleans.TestingHost.Tests/TestingUtilsTests.cs Reworks deadline tests to use FakeTimeProvider and explicit barriers for deterministic boundary coverage.
test/TestInfrastructure/Orleans.TestingHost.Tests/Orleans.TestingHost.Tests.csproj Adds Microsoft.Extensions.TimeProvider.Testing dependency for FakeTimeProvider.
src/Orleans.TestingHost/Utils/TestingUtils.cs Routes elapsed-time measurement, deadline CTS, and retry delays through an internal TimeProvider parameter (defaulting to TimeProvider.System).
src/Orleans.TestingHost/Orleans.TestingHost.csproj Adds InternalsVisibleTo for Orleans.TestingHost.Tests so tests can call internal overloads.

Review details

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

  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

@ReubenBond
ReubenBond merged commit 96c047f into dotnet:main Aug 21, 2026
73 checks passed
@ReubenBond
ReubenBond deleted the rb-fix-wait-until-deadline branch August 21, 2026 12:32
This was referenced Aug 28, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: WaitUntilSucceededAsync accepts a predicate crossing the deadline

2 participants