feat(otopcua): make FixedTree re-discovery per-pass timeout injectable (follow-up A)
This commit is contained in:
+26
@@ -171,6 +171,32 @@ public sealed class DriverInstanceActorDiscoveryTests : RuntimeActorTestBase
|
||||
driver.DiscoverCount.ShouldBe(3);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The per-pass discovery timeout is injectable via <see cref="DriverInstanceActor.Props"/> so tests
|
||||
/// can control it without real-time delays. The default constant must be 30 seconds (behaviour-preserving).
|
||||
/// Wiring is verified by constructing via <c>Props</c> with a custom value and confirming the actor starts
|
||||
/// and begins discovery normally.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Discovery_timeout_default_constant_is_30s_and_Props_accepts_custom_value()
|
||||
{
|
||||
// The constant must exist and preserve the pre-refactor 30 s literal.
|
||||
DriverInstanceActor.DefaultRediscoverDiscoverTimeout.ShouldBe(TimeSpan.FromSeconds(30));
|
||||
|
||||
// Props must accept the new optional parameter — no throw and actor starts normally.
|
||||
var driver = new DiscoverableStubDriver();
|
||||
var parent = CreateTestProbe();
|
||||
var actor = parent.ChildActorOf(DriverInstanceActor.Props(
|
||||
driver,
|
||||
rediscoverInterval: TimeSpan.FromMilliseconds(20),
|
||||
rediscoverDiscoverTimeout: TimeSpan.FromSeconds(5)));
|
||||
|
||||
actor.Tell(new DriverInstanceActor.InitializeRequested("{}"));
|
||||
|
||||
// Actor starts and discovery publishes — confirms the custom timeout was wired without error.
|
||||
parent.ExpectMsg<DriverInstanceActor.DiscoveredNodesReady>(TimeSpan.FromSeconds(2));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A <see cref="StubDriver"/> that also exposes <see cref="ITagDiscovery"/>. Each <c>DiscoverAsync</c>
|
||||
/// pass is counted; passes 1–2 yield nothing (cache warming), passes 3+ yield a stable 3-node set —
|
||||
|
||||
Reference in New Issue
Block a user