Skip to content

test(reminders): harden lifecycle synchronization - #10891

Merged
ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:rb-harden-reminder-lifecycle-harness
Aug 28, 2026
Merged

ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:rb-harden-reminder-lifecycle-harness

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Aug 28, 2026 •

Copy link
Copy Markdown
Member

Problem

Reminder provider suites rely on several independently composed diagnostic waits and test-only service hooks. Their synchronous per-test cleanup is tied to test cancellation, can leave local reminder state behind, and activation-local counter waits can strand a clock driver when an activation is replaced. Lifecycle edge cases around partial startup and failed or superseded range reads also lack focused regression coverage.

Solution

Introduce a cohesive reminder lifecycle harness for service readiness, topology reconciliation, schedule arming, activation-independent tick completion, sequential refresh, and global quiescence. Convert the shared reminder suite base to asynchronous disposal using an independent bounded cleanup token, clear storage through the grain proxy, refresh every active service in order, and always dispose diagnostics. Preserve the in-memory and SQL Server pre-clear behavior and route Azure Table startup synchronization through the same harness.

Add controlled regressions for activation replacement, current and obsolete reconciliation failures, stalled partial startup cleanup, and cleanup after test cancellation.

Rationale

Centralizing phase barriers makes provider tests express lifecycle intent without rebuilding synchronization from low-level hooks. Cleanup now establishes both persistent and local-state isolation even when the test token is canceled. Tick completion uses the activation-independent diagnostic event emitted after reminder delivery, matching the approach in #10855 without copying its test-grain cleanup; whichever PR merges second can resolve the small shared-base overlap while retaining this harness.

Microsoft Reviewers: Open in CodeFlow

Copilot AI lite review requested due to automatic review settings August 28, 2026 04: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.

Copilot review overview

Review tier: Lite
Findings: 2 Medium severity · 1 Low severity

New issues introduced by this change (3)
Severity Finding
Low severity test/​Orleans.Reminders.Tests/​TimerTests/​ReminderTestsBase.cs — observer is now a get-only property but uses a lower-cased name, which is inconsistent with the…
Medium severity test/​Orleans.Reminders.Tests/​TimerTests/​ReminderTestsBase.cs — ExecuteCleanupAsync continues running subsequent cleanup phases even after its timeout token has…
Medium severity test/​Orleans.Reminders.Tests/​TimerTests/​ReminderLifecycleHarness.cs — WaitForServicesReadyAsync converts any OperationCanceledException into a TimeoutException, which…
What changed in this PR

This PR hardens Orleans reminder provider test suites by introducing a centralized lifecycle/synchronization harness and improving cleanup so tests leave both persistent reminder state and local in-memory state quiescent, even under cancellation and activation churn.

Changes:

  • Add ReminderLifecycleHarness to coordinate reminder service readiness, topology reconciliation, schedule arming, tick completion, refresh sequencing, and global quiescence.
  • Convert shared reminder test base cleanup to async disposal with a bounded, independent cleanup token and broaden lifecycle regression coverage.
  • Extend diagnostics with a global-quiescence wait and update provider-specific suites (Azure Table, ADO.NET) to use the new harness.
File Description
test/​Orleans.Testing.Reminders/​ReminderDiagnosticObserver.cs Adds a global-quiescence waiter and releases it when all local reminders have stopped.
test/​Orleans.Reminders.Tests/​TimerTests/​ReminderTestsBase.cs Switches to async cleanup via the lifecycle harness; updates tick synchronization to be activation-independent.
test/​Orleans.Reminders.Tests/​TimerTests/​ReminderTests_TableGrain.cs Updates startup synchronization to use the harness; adds an activation-replacement tick completion regression test.
test/​Orleans.Reminders.Tests/​TimerTests/​ReminderLifecycleHarnessTests.cs Adds unit tests for cleanup token independence and partial-startup cleanup behavior.
test/​Orleans.Reminders.Tests/​TimerTests/​ReminderLifecycleHarness.cs Introduces the harness which encapsulates reminder lifecycle phase barriers and partial-startup cleanup logic.
test/​Orleans.Reminders.Tests/​TimerTests/​LocalReminderServiceTests.cs Updates startup wait usage and adds regression tests around range-change reconciliation failure propagation/obsolescence.
test/​Extensions/​Orleans.Azure.Tests/​Reminder/​ReminderTests_AzureTable.cs Routes Azure Table reminder service startup synchronization through the harness.
test/​Extensions/​Orleans.AdoNet.Tests/​Reminders/​ReminderTests_AdoNet_SqlServer.cs Uses shared base cleanup path to clear reminder storage via the grain proxy.

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

Copilot AI review requested due to automatic review settings August 28, 2026 05:50

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 review overview

Review tier: Lite
Findings: None

Issues resolved since last review (3)
Severity Finding
Medium severity test/​Orleans.Reminders.Tests/​TimerTests/​ReminderLifecycleHarness.cs — WaitForServicesReadyAsync converts any OperationCanceledException into a TimeoutException, which… View resolved comment
Medium severity test/​Orleans.Reminders.Tests/​TimerTests/​ReminderTestsBase.cs — ExecuteCleanupAsync continues running subsequent cleanup phases even after its timeout token has… View resolved comment
Low severity test/​Orleans.Reminders.Tests/​TimerTests/​ReminderTestsBase.cs — observer is now a get-only property but uses a lower-cased name, which is inconsistent with the… View resolved comment

@ReubenBond
ReubenBond force-pushed the rb-harden-reminder-lifecycle-harness branch from e8a98a5 to 06769cf Compare August 28, 2026 07:10
Copilot AI review requested due to automatic review settings August 28, 2026 07:10

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 review overview

Review tier: Lite
Findings: None

Suppressed comments (1)

test/Orleans.Testing.Reminders/ReminderDiagnosticObserver.cs:607

  • ReminderDiagnosticObserver.Dispose() only disposes subscriptions/connections and does not complete or fault any pending waiter tasks (including the newly added global quiescence waiters). If the observer is disposed while a caller is awaiting a WaitFor* task with a non-canceled token, that task can hang indefinitely and the CancellationToken registrations can keep the observer rooted longer than intended.
    public void Dispose()
    {
        _storageSubscription.Dispose();
        _connection.Dispose();
        _serviceConnection.Dispose();

@ReubenBond

Copy link
Copy Markdown
Member Author

Current CI is blocked by a deterministic branch build error: est/Orleans.Runtime.Tests/CallbackDataTests.cs(296,37) triggers xUnit1051 because a method accepting CancellationToken is called without TestContext.Current.CancellationToken. This fails the build across the matrix before tests run. Failed run: https://github.com/dotnet/orleans/actions/runs/33143148156

@ReubenBond
ReubenBond merged commit c0cfe18 into dotnet:main Aug 28, 2026
136 of 138 checks passed
@ReubenBond
ReubenBond deleted the rb-harden-reminder-lifecycle-harness branch August 28, 2026 13:43
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 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