Merge hw5-661 (#661 MTConnect reconnect test waits on ReconnectAttempts, cancellable)
v2-ci / build (push) Successful in 4m49s
v2-ci / unit-tests (push) Failing after 23m38s

Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
Joseph Doherty
2026-10-09 07:10:59 -04:00
@@ -995,6 +995,16 @@ public sealed class MTConnectSubscribeTests
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>
/// …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
@@ -1015,7 +1025,11 @@ public sealed class MTConnectSubscribeTests
await client.WaitForSampleCallsAsync(3).WaitAsync(Watchdog, Ct);
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);
driver.ReconnectAttempts.ShouldBeGreaterThan(early);
@@ -1065,7 +1079,11 @@ public sealed class MTConnectSubscribeTests
await client.WaitForSampleCallsAsync(3).WaitAsync(Watchdog, Ct);
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);
driver.ReconnectAttempts.ShouldBeGreaterThan(early);