fix(testing): make wait deadline tests deterministic - #10738
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
TimeProviderseam inTestingUtils.WaitUntilAsync/WaitUntilSucceededAsyncto drive monotonic timestamps, deadline cancellation, and retry delays. - Rewrites the deadline-focused tests to use
FakeTimeProviderplus explicit predicate barriers to deterministically validate “success only when elapsed < timeout”. - Grants the test assembly access to the new internal overloads via
InternalsVisibleToand 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
This was referenced Aug 28, 2026
Merged
Merged
This was referenced Sep 4, 2026
This was referenced Sep 8, 2026
Closed
This was referenced Sep 16, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
TimeProviderseam while production continues to useTimeProvider.System. The deadline tests useFakeTimeProviderplus 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