From c709fbc1c453f5b07661f4f22da40bb67fd77bac Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Tue, 24 Nov 2026 14:59:01 -0500 Subject: [PATCH] =?UTF-8?q?test(grpc-data):=20A2=20review=20N5=20=E2=80=94?= =?UTF-8?q?=20the=20waiter=20test=20counts=20condition-queue=20waits=20onl?= =?UTF-8?q?y=20(red=20on=20revert:=2019=20vs=20=E2=89=A4=201)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataConnections/DataSubscriptionSession.Conditions.cs | 4 ++-- .../DataConnections/GrpcDataConditionStreamTests.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/DataSubscriptionSession.Conditions.cs b/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/DataSubscriptionSession.Conditions.cs index 7911ec200..c09756647 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/DataSubscriptionSession.Conditions.cs +++ b/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/DataSubscriptionSession.Conditions.cs @@ -237,13 +237,13 @@ internal sealed partial class DataSubscriptionSession private Task StartWait(ChannelReader reader, CancellationToken token) { - Interlocked.Increment(ref _conditionWaitsStarted); + if (!ReferenceEquals(reader, _outbound.Reader)) Interlocked.Increment(ref _conditionWaitsStarted); return reader.WaitToReadAsync(token).AsTask(); } private int _conditionWaitsStarted; - /// Test seam (N5): how many channel waits the delivery loop has registered. + /// Test seam (N5): how many waits on the CONDITION queue the delivery loop has registered. internal int ConditionWaitsStartedForTests => Volatile.Read(ref _conditionWaitsStarted); /// Test seam: the stream has processed its Open. diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/DataConnections/GrpcDataConditionStreamTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/DataConnections/GrpcDataConditionStreamTests.cs index f9e89f9f6..b78739672 100644 --- a/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/DataConnections/GrpcDataConditionStreamTests.cs +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/DataConnections/GrpcDataConditionStreamTests.cs @@ -274,8 +274,8 @@ public sealed class GrpcDataConditionStreamTests await stream.Session.EnqueueValueProbeForTests(); (await next).ShouldNotBeNull(); } - // Each value wakes the loop once; the idle condition wait must be reused, not re-registered every pass. - (stream.Session.ConditionWaitsStartedForTests - before).ShouldBeLessThan(50); + // Values wake the loop; the idle condition queue's wait must be reused, not re-registered on every pass. + (stream.Session.ConditionWaitsStartedForTests - before).ShouldBeLessThanOrEqualTo(1); } [Fact]