Skip to content

fix(testing): wait for async cleanup timer rearm - #10348

Merged
ReubenBond merged 3 commits into
dotnet:mainfrom
ReubenBond:reubenbond-stabilize-async-cleanup
Aug 7, 2026
Merged

ReubenBond merged 3 commits into
dotnet:mainfrom
ReubenBond:reubenbond-stabilize-async-cleanup

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Aug 7, 2026 •

Copy link
Copy Markdown
Member

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.

Copilot AI review requested due to automatic review settings August 7, 2026 00:53

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 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 a TrackingFakeTimeProvider wrapper around FakeTimeProvider timers.
  • 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 (ChangeCount increment) 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 thread test/Orleans.DefaultCluster.Tests/AsyncEnumerableGrainCallTests.cs Outdated
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>
Copilot AI review requested due to automatic review settings August 7, 2026 01:12
@ReubenBond
ReubenBond force-pushed the reubenbond-stabilize-async-cleanup branch from 4c085dd to a97af5e Compare August 7, 2026 01:12

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.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new

Remove tracked fake-time timer entries during synchronous and asynchronous disposal so the collection fixture does not retain disposed grain timers.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f882b77b-b8ac-433e-ae07-7d16dc531cbc
Move fake-time timer change tracking into shared timer test infrastructure and wait for self-disposing timers to be armed before advancing time. This closes the creation-event race which could miss the first one-shot tick.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f882b77b-b8ac-433e-ae07-7d16dc531cbc
@ReubenBond
ReubenBond merged commit 8515e6d into dotnet:main Aug 7, 2026
66 of 67 checks passed
@ReubenBond
ReubenBond deleted the reubenbond-stabilize-async-cleanup branch August 7, 2026 15:41
This was referenced Aug 28, 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.

2 participants