fix(testing): wait for async cleanup timer rearm - #10348
Open
ReubenBond wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes test flakiness in AsyncEnumerableGrainCallTests by making fake-time advances wait for the async-enumerator cleanup timer to be re-armed after each observed cleanup, ensuring subsequent fake-time advances don’t occur before the next one-shot timer tick is scheduled.
Changes:
- Track timer
Change(...)calls in aTrackingFakeTimeProviderwrapper aroundFakeTimeProvidertimers. - Capture the async-enumerable cleanup timer instance via diagnostics and expose it on the test listener.
- After each cleanup observation, wait for the corresponding timer re-arm (
ChangeCountincrement) before advancing time again.
Show a summary per file
| File | Description |
|---|---|
| test/Orleans.DefaultCluster.Tests/AsyncEnumerableGrainCallTests.cs | Adds fake-time timer rearm tracking and updates the async-enumerable cleanup advancement logic to wait for rearm deterministically. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 1
Comment on lines
+731
to
+739
| private readonly ConcurrentDictionary<object, TrackingTimer> _timers = new(ReferenceEqualityComparer.Instance); | ||
|
|
||
| public override ITimer CreateTimer(TimerCallback callback, object? state, TimeSpan dueTime, TimeSpan period) | ||
| { | ||
| var timer = new TrackingTimer(base.CreateTimer(callback, state, dueTime, period)); | ||
| if (state is not null) | ||
| { | ||
| _timers[state] = timer; | ||
| } |
Track the cleanup grain timer's successful Change calls in the fake time provider and wait for rearm after each cleanup notification. This prevents a subsequent fake-time advance from racing the timer callback while preserving the eviction assertions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
ReubenBond
force-pushed
the
reubenbond-stabilize-async-cleanup
branch
from
August 7, 2026 01:12
4c085dd to
a97af5e
Compare
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The async enumerable cleanup diagnostic is emitted before the grain timer callback returns and rearms its one-shot timer. A second fake-time advance could therefore occur too early and miss the next cleanup tick.
Track successful timer rearm operations in the test fake time provider and wait for the specific cleanup timer to rearm after each observed cleanup. This keeps the existing slow-consumer eviction assertions deterministic without changing production behavior or extending timeouts.