test(mtconnect): wait on ReconnectAttempts itself, not a sample-call proxy (#661)

Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
Joseph Doherty
2026-10-09 06:02:24 -04:00
parent 98c00904e7
commit 480b000f53
@@ -995,6 +995,14 @@ public sealed class MTConnectSubscribeTests
client.SampleCallCount.ShouldBe(3);
}
private static async Task WaitForReconnectAttemptsAboveAsync(MTConnectDriver driver, int floor)
{
while (driver.ReconnectAttempts <= floor)
{
await Task.Delay(5).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 +1023,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).WaitAsync(Watchdog, Ct);
early.ShouldBeGreaterThanOrEqualTo(2);
driver.ReconnectAttempts.ShouldBeGreaterThan(early);
@@ -1065,7 +1077,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).WaitAsync(Watchdog, Ct);
early.ShouldBeGreaterThanOrEqualTo(2);
driver.ReconnectAttempts.ShouldBeGreaterThan(early);