From 1e1443dcd9689ff969ef398556f3fc98374d6b2e Mon Sep 17 00:00:00 2001 From: Reuben Bond Date: Tue, 17 Feb 2026 06:43:27 -0800 Subject: [PATCH] Fix flaky stuck grain forwarding test Track the queued NonBlockingCall tasks and await their completion instead of polling GetNonBlockingCallCounter, which can observe a reset counter after activation forwarding. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../OrleansRuntime/StuckGrainTests.cs | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/test/TesterInternal/OrleansRuntime/StuckGrainTests.cs b/test/TesterInternal/OrleansRuntime/StuckGrainTests.cs index a642af405b0..67b5cc2f010 100644 --- a/test/TesterInternal/OrleansRuntime/StuckGrainTests.cs +++ b/test/TesterInternal/OrleansRuntime/StuckGrainTests.cs @@ -83,9 +83,11 @@ public async Task StuckGrainTest_StuckDetectionAndForward() // Should timeout await Assert.ThrowsAsync(() => task.WaitAsync(TimeSpan.FromSeconds(1))); - for (var i = 0; i < 3; i++) + var calls = new Task[3]; + for (var i = 0; i < calls.Length; i++) { var call = stuckGrain.NonBlockingCall(); + calls[i] = call; await Task.WhenAny(call, Task.Delay(TimeSpan.FromMilliseconds(500))); } @@ -95,20 +97,8 @@ public async Task StuckGrainTest_StuckDetectionAndForward() // No issue on this one await stuckGrain.NonBlockingCall(); - // All 4 otherwise stuck calls should have been forwarded to a new activation - await TestingUtils.WaitUntilAsync( - async lastTry => - { - var count = await stuckGrain.GetNonBlockingCallCounter(); - if (lastTry) - { - Assert.Equal(4, count); - } - - return count == 4; - }, - TimeSpan.FromSeconds(10), - TimeSpan.FromMilliseconds(200)); + // All otherwise stuck calls should have been forwarded to a new activation. + await Task.WhenAll(calls).WaitAsync(TimeSpan.FromSeconds(10)); } [Fact, TestCategory("Functional"), TestCategory("ActivationCollection")]