From 4128d9c3136673200b39f9d61283285a3036a2b7 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Thu, 8 Oct 2026 17:10:55 -0400 Subject: [PATCH] test(runtime): de-flake Rediscovery_flag_persists (vacuous AwaitAssert, no publish trigger) The AwaitAssert lambdas returned bool into an Action, so they never waited; the test raced the rediscovery publish (5-22% failure on base too). Make the asserts real and drive the republish with a short health poll interval. Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe --- .../Drivers/DriverInstanceActorRediscoverySignalTests.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/Drivers/DriverInstanceActorRediscoverySignalTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/Drivers/DriverInstanceActorRediscoverySignalTests.cs index 00292ba5..88dc0024 100644 --- a/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/Drivers/DriverInstanceActorRediscoverySignalTests.cs +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/Drivers/DriverInstanceActorRediscoverySignalTests.cs @@ -95,19 +95,20 @@ public sealed class DriverInstanceActorRediscoverySignalTests : RuntimeActorTest var publisher = new RecordingHealthPublisher(); var parent = CreateTestProbe(); parent.IgnoreMessages(_ => true); - var actor = parent.ChildActorOf(DriverInstanceActor.Props(driver, healthPublisher: publisher)); + var actor = parent.ChildActorOf(DriverInstanceActor.Props(driver, healthPublisher: publisher, + healthPollInterval: TimeSpan.FromMilliseconds(200))); actor.Tell(new DriverInstanceActor.InitializeRequested("{}")); AwaitAssert(() => publisher.Published.Count.ShouldBeGreaterThan(0), TimeSpan.FromSeconds(3)); driver.RaiseRediscovery("agent-instance-changed"); AwaitAssert( - () => publisher.Published.Any(p => p.RediscoveryNeededUtc is not null), + () => publisher.Published.Any(p => p.RediscoveryNeededUtc is not null).ShouldBeTrue(), TimeSpan.FromSeconds(3)); // Force a further publish by changing something else about the driver's health. driver.SetLastError("transient read failure"); AwaitAssert( - () => publisher.Published.Any(p => p.LastError == "transient read failure"), + () => publisher.Published.Any(p => p.LastError == "transient read failure").ShouldBeTrue(), TimeSpan.FromSeconds(3)); var latest = publisher.Published[^1];