From edd2e23b7a33d28fda3f4d26bc1dd01246075b78 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Thu, 22 Oct 2026 16:35:34 -0400 Subject: [PATCH] test(mtconnect): de-race the raised-count step-back test The one-shot /sample failure was enqueued while the FIRST enumeration could still be before its own one-shot check (the fake releases the call-count waiter first), so under suite load the failure hit the first stream instead of the raised one (intermittent). It is now enqueued after the first stream has consumed a chunk. Refs #743 Claude-Session: https://claude.ai/code/session_01Ub9hGmYLQvn9XETzw7CMsT --- .../MTConnectSampleLagTests.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.MTConnect.Tests/MTConnectSampleLagTests.cs b/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.MTConnect.Tests/MTConnectSampleLagTests.cs index 517a95de..15b4dbfc 100644 --- a/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.MTConnect.Tests/MTConnectSampleLagTests.cs +++ b/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.MTConnect.Tests/MTConnectSampleLagTests.cs @@ -130,8 +130,11 @@ public sealed class MTConnectSampleLagTests try { // The NEXT enumeration (the raised one) is refused the way a real Agent refuses a count above its buffer. + // Enqueued only once the first stream has consumed a chunk — i.e. is past its own one-shot-failure check — + // so the failure can only ever hit the raised stream (enqueueing earlier raced the first enumeration). + await client.PumpAsync(Chunk(Primed, 2, last: 900)).WaitAsync(Watchdog, Ct); client.SampleFailures.Enqueue(new InvalidDataException("MTConnectError: INVALID_REQUEST count too large")); - for (var i = 0; i < 3; i++) + for (var i = 1; i < 3; i++) await client.PumpAsync(Chunk(Primed + (2 * i), 2, last: 900)).WaitAsync(Watchdog, Ct); await client.WaitForSampleCallsAsync(3).WaitAsync(Watchdog, Ct);