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
This commit is contained in:
+4
-3
@@ -95,19 +95,20 @@ public sealed class DriverInstanceActorRediscoverySignalTests : RuntimeActorTest
|
|||||||
var publisher = new RecordingHealthPublisher();
|
var publisher = new RecordingHealthPublisher();
|
||||||
var parent = CreateTestProbe();
|
var parent = CreateTestProbe();
|
||||||
parent.IgnoreMessages(_ => true);
|
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("{}"));
|
actor.Tell(new DriverInstanceActor.InitializeRequested("{}"));
|
||||||
AwaitAssert(() => publisher.Published.Count.ShouldBeGreaterThan(0), TimeSpan.FromSeconds(3));
|
AwaitAssert(() => publisher.Published.Count.ShouldBeGreaterThan(0), TimeSpan.FromSeconds(3));
|
||||||
driver.RaiseRediscovery("agent-instance-changed");
|
driver.RaiseRediscovery("agent-instance-changed");
|
||||||
AwaitAssert(
|
AwaitAssert(
|
||||||
() => publisher.Published.Any(p => p.RediscoveryNeededUtc is not null),
|
() => publisher.Published.Any(p => p.RediscoveryNeededUtc is not null).ShouldBeTrue(),
|
||||||
TimeSpan.FromSeconds(3));
|
TimeSpan.FromSeconds(3));
|
||||||
|
|
||||||
// Force a further publish by changing something else about the driver's health.
|
// Force a further publish by changing something else about the driver's health.
|
||||||
driver.SetLastError("transient read failure");
|
driver.SetLastError("transient read failure");
|
||||||
AwaitAssert(
|
AwaitAssert(
|
||||||
() => publisher.Published.Any(p => p.LastError == "transient read failure"),
|
() => publisher.Published.Any(p => p.LastError == "transient read failure").ShouldBeTrue(),
|
||||||
TimeSpan.FromSeconds(3));
|
TimeSpan.FromSeconds(3));
|
||||||
|
|
||||||
var latest = publisher.Published[^1];
|
var latest = publisher.Published[^1];
|
||||||
|
|||||||
Reference in New Issue
Block a user