Repository navigation
test(reminders): harden lifecycle synchronization - #10891
Conversation
There was a problem hiding this comment.
Copilot review overview
Review tier: Lite
Findings: 2
New issues introduced by this change (3)
| Severity | Finding |
|---|---|
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… |
|
test/Orleans.Reminders.Tests/TimerTests/ReminderTestsBase.cs — ExecuteCleanupAsync continues running subsequent cleanup phases even after its timeout token has… |
|
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
ReminderLifecycleHarnessto 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.
There was a problem hiding this comment.
Copilot review overview
Review tier: Lite
Findings: None
Issues resolved since last review (3)
| Severity | Finding |
|---|---|
test/Orleans.Reminders.Tests/TimerTests/ReminderLifecycleHarness.cs — WaitForServicesReadyAsync converts any OperationCanceledException into a TimeoutException, which… View resolved comment |
|
test/Orleans.Reminders.Tests/TimerTests/ReminderTestsBase.cs — ExecuteCleanupAsync continues running subsequent cleanup phases even after its timeout token has… View resolved comment |
|
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 |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
e8a98a5 to
06769cf
Compare
There was a problem hiding this comment.
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();
|
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 |


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