From 78360eb6a7c923671d1a2996f3a5804ca1d364cf Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Fri, 19 Jun 2026 01:04:36 -0400 Subject: [PATCH] =?UTF-8?q?test(dcl):=20strengthen=20DCL002=20derace=20?= =?UTF-8?q?=E2=80=94=2030s=20AwaitCondition=20+=20non-parallel=20collectio?= =?UTF-8?q?n=20for=20full-suite=20load=20(#234)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataConnectionManagerActorCollection.cs | 12 ++++++++++++ .../DataConnectionManagerActorTests.cs | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 tests/ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests/DataConnectionManagerActorCollection.cs diff --git a/tests/ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests/DataConnectionManagerActorCollection.cs b/tests/ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests/DataConnectionManagerActorCollection.cs new file mode 100644 index 00000000..ec3bde8c --- /dev/null +++ b/tests/ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests/DataConnectionManagerActorCollection.cs @@ -0,0 +1,12 @@ +namespace ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests; + +/// +/// Marks DataConnectionManagerActorTests as non-parallel with any other tests in the +/// same collection. This prevents CPU-contention-induced timing flakiness in DCL002 +/// (and neighbours) where actor message dispatch + async I/O must complete before an +/// AwaitCondition deadline. xUnit runs all tests in the same [Collection] sequentially +/// within the assembly; the generous 30 s AwaitCondition ceiling handles cross-assembly +/// contention when the full solution test suite runs in parallel. +/// +[CollectionDefinition("DataConnectionManagerActor", DisableParallelization = true)] +public class DataConnectionManagerActorCollection { } diff --git a/tests/ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests/DataConnectionManagerActorTests.cs b/tests/ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests/DataConnectionManagerActorTests.cs index 093f0ccf..039f72aa 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests/DataConnectionManagerActorTests.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests/DataConnectionManagerActorTests.cs @@ -12,6 +12,7 @@ namespace ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests; /// /// WP-34: Tests for DataConnectionManagerActor routing and lifecycle. /// +[Collection("DataConnectionManagerActor")] public class DataConnectionManagerActorTests : TestKit { private readonly IDataConnectionFactory _mockFactory; @@ -108,7 +109,7 @@ public class DataConnectionManagerActorTests : TestKit // completes under CPU contention. AwaitCondition( () => mockAdapter.ReceivedCalls().Any(c => c.GetMethodInfo().Name == "ConnectAsync"), - TimeSpan.FromSeconds(5)); + TimeSpan.FromSeconds(30)); // Register a subscription. manager.Tell(new SubscribeTagsRequest("c1", "inst1", "conn1", ["tag1"], DateTimeOffset.UtcNow)); @@ -122,7 +123,7 @@ public class DataConnectionManagerActorTests : TestKit // actor processes the message under CPU load. AwaitCondition( () => mockAdapter.ReceivedCalls().Any(c => c.GetMethodInfo().Name == "WriteAsync"), - TimeSpan.FromSeconds(5)); + TimeSpan.FromSeconds(30)); // After the crash the subscription state must survive: the health report // still shows the subscribed/resolved tag. With Restart it would be 0.