Merge hw5-661 (#661 MTConnect reconnect test waits on ReconnectAttempts, cancellable)
Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
@@ -995,6 +995,16 @@ public sealed class MTConnectSubscribeTests
|
|||||||
client.SampleCallCount.ShouldBe(3);
|
client.SampleCallCount.ShouldBe(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static async Task WaitForReconnectAttemptsAboveAsync(MTConnectDriver driver, int floor, CancellationToken ct)
|
||||||
|
{
|
||||||
|
using var watchdog = CancellationTokenSource.CreateLinkedTokenSource(ct);
|
||||||
|
watchdog.CancelAfter(Watchdog);
|
||||||
|
while (driver.ReconnectAttempts <= floor)
|
||||||
|
{
|
||||||
|
await Task.Delay(5, watchdog.Token).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// …and the counter still accumulates when nothing is delivered, which is the case the
|
/// …and the counter still accumulates when nothing is delivered, which is the case the
|
||||||
/// backoff exists for. Asserted as monotonic growth rather than an exact value, because the
|
/// backoff exists for. Asserted as monotonic growth rather than an exact value, because the
|
||||||
@@ -1015,7 +1025,11 @@ public sealed class MTConnectSubscribeTests
|
|||||||
await client.WaitForSampleCallsAsync(3).WaitAsync(Watchdog, Ct);
|
await client.WaitForSampleCallsAsync(3).WaitAsync(Watchdog, Ct);
|
||||||
var early = driver.ReconnectAttempts;
|
var early = driver.ReconnectAttempts;
|
||||||
|
|
||||||
await client.WaitForSampleCallsAsync(6).WaitAsync(Watchdog, Ct);
|
// Wait on the counter itself, not on a sample-call count: the pump advances it AFTER a
|
||||||
|
// call fails, and `early` may have been read late (already past the 6th call) under load,
|
||||||
|
// so a call-count barrier can observe the counter unchanged. The failure is sticky, so a
|
||||||
|
// working backoff keeps growing it; a frozen one never satisfies this within the watchdog.
|
||||||
|
await WaitForReconnectAttemptsAboveAsync(driver, early, Ct);
|
||||||
|
|
||||||
early.ShouldBeGreaterThanOrEqualTo(2);
|
early.ShouldBeGreaterThanOrEqualTo(2);
|
||||||
driver.ReconnectAttempts.ShouldBeGreaterThan(early);
|
driver.ReconnectAttempts.ShouldBeGreaterThan(early);
|
||||||
@@ -1065,7 +1079,11 @@ public sealed class MTConnectSubscribeTests
|
|||||||
await client.WaitForSampleCallsAsync(3).WaitAsync(Watchdog, Ct);
|
await client.WaitForSampleCallsAsync(3).WaitAsync(Watchdog, Ct);
|
||||||
var early = driver.ReconnectAttempts;
|
var early = driver.ReconnectAttempts;
|
||||||
|
|
||||||
await client.WaitForSampleCallsAsync(6).WaitAsync(Watchdog, Ct);
|
// Wait on the counter itself, not on a sample-call count: the pump advances it AFTER a
|
||||||
|
// call fails, and `early` may have been read late (already past the 6th call) under load,
|
||||||
|
// so a call-count barrier can observe the counter unchanged. The failure is sticky, so a
|
||||||
|
// working backoff keeps growing it; a frozen one never satisfies this within the watchdog.
|
||||||
|
await WaitForReconnectAttemptsAboveAsync(driver, early, Ct);
|
||||||
|
|
||||||
early.ShouldBeGreaterThanOrEqualTo(2);
|
early.ShouldBeGreaterThanOrEqualTo(2);
|
||||||
driver.ReconnectAttempts.ShouldBeGreaterThan(early);
|
driver.ReconnectAttempts.ShouldBeGreaterThan(early);
|
||||||
|
|||||||
Reference in New Issue
Block a user