diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests/ConfigPublishCoordinatorTimeoutTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests/ConfigPublishCoordinatorTimeoutTests.cs index 42fc744b..0490eece 100644 --- a/tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests/ConfigPublishCoordinatorTimeoutTests.cs +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests/ConfigPublishCoordinatorTimeoutTests.cs @@ -22,11 +22,11 @@ public sealed class ConfigPublishCoordinatorTimeoutTests : ControlPlaneActorTest var dbFactory = NewInMemoryDbFactory(); var deploymentId = SeedDispatchingDeployment(dbFactory); - // Short deadline so we can drive it deterministically in the test. - var actor = Sys.ActorOf(ConfigPublishCoordinator.Props(dbFactory, TimeSpan.FromMilliseconds(150))); - - // Seed a NodeDeploymentState row so the coordinator doesn't see "zero expected acks" - // and short-circuit to Sealed. We pretend a driver node exists in the cluster. + // Seed the NodeDeploymentState row BEFORE the actor is spawned. PreStart reads + // NodeDeploymentStates to recover the expected-ack set, and it runs as soon as Sys.ActorOf + // schedules the actor — so seeding afterwards is a race: if PreStart wins, the coordinator + // sees zero expected acks and can short-circuit straight to Sealed, and the assertion below + // never sees TimedOut. We pretend a driver node exists in the cluster. using (var db = dbFactory.CreateDbContext()) { db.NodeDeploymentStates.Add(new Configuration.Entities.NodeDeploymentState @@ -38,6 +38,13 @@ public sealed class ConfigPublishCoordinatorTimeoutTests : ControlPlaneActorTest db.SaveChanges(); } + // Deliberately un-hittable wall-clock deadline (matching the other tests in this class). + // The apply deadline is a real Akka timer: a short one can self-fire under load and race + // the explicit DeadlineElapsed below, so the test would sometimes be measuring the timer + // rather than the message handler. Five minutes guarantees the ONLY deadline signal the + // coordinator ever receives is the one this test sends. + var actor = Sys.ActorOf(ConfigPublishCoordinator.Props(dbFactory, TimeSpan.FromMinutes(5))); + // Drive the deadline ourselves rather than waiting for the cluster's empty driver-set // bypass. Tell the actor the deadline elapsed for this id. actor.Tell(new ConfigPublishCoordinator.DeadlineElapsed(deploymentId));