test: shared actor test bases poll AwaitCondition every 20 ms, not max/10 (lmxopcua#775)
v2-ci / unit-tests (push) Has been cancelled

Akka TestKit's AwaitCondition without an interval polls every max/10 of the
DILATED budget. Measured here: a condition that turned true at 2 s under a
15 s budget returned after 3003 ms at timefactor 1 (3 polls) and 4502 ms at
timefactor 3 (2 polls). AwaitAssert / AwaitAssertAsync are unaffected (a
fixed 100 ms: 21 polls in ~2 s at both factors).

RuntimeActorTestBase and ControlPlaneActorTestBase now declare
AwaitCondition overloads that hide TestKit's and default the interval to
PollInterval (20 ms), so every subclass call without an interval binds to
them (measured after: returns 5-22 ms after the condition holds, at both
factors). PresenceBudget's doc no longer claims the helpers return "the
instant the condition holds" - it states the per-helper poll behaviour.

Bare-TestKit classes with AwaitCondition calls get an explicit interval:
TelemetryDialDeadlineTests / TelemetryDialSupervisorTests (next to their own
undilated 5 s / 8 s WaitForCount deadlines and a 1 s dial deadline) and
OpcUaEndpointStepDownActorTests (RuntimeActorTestBase.PollInterval, now
public like PresenceBudget). ContinuousHistorizationRecorderTypedValueTests'
AwaitConditionAsync was left alone (historian code is being changed in
parallel).

Suite results (Release, 0 warnings):
- Runtime.Tests 946/3 skipped/0 failed at timefactor 3 (1 m 45 s, was
  2 m 57 s) and 1 (1 m 18 s, was 2 m 57 s);
- ControlPlane.Tests 319/0 failed at 3 (1 m 51 s) and 1 (1 m 11 s);
- AdminUI.Tests Telemetry 15/0 failed at 3 and 1.

Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
Joseph Doherty
2026-11-09 15:28:58 -05:00
parent 75be6fe12b
commit c86c7cbf35
5 changed files with 97 additions and 11 deletions
@@ -23,6 +23,10 @@ namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.Telemetry;
/// </summary>
public sealed class TelemetryDialDeadlineTests : TestKit
{
/// <summary>Explicit AwaitCondition poll interval: Akka's default is max / 10 of the dilated budget, i.e.
/// seconds under CI's timefactor (lmxopcua#775).</summary>
private static readonly TimeSpan PollInterval = TimeSpan.FromMilliseconds(20);
private static readonly TimeSpan Timeout = TimeSpan.FromSeconds(8);
[Fact]
@@ -35,7 +39,7 @@ public sealed class TelemetryDialDeadlineTests : TestKit
first.Ct.IsCancellationRequested.ShouldBeFalse("the deadline has not elapsed yet");
// The stalled dial is cut at the deadline...
AwaitCondition(() => first.Ct.IsCancellationRequested, Timeout);
AwaitCondition(() => first.Ct.IsCancellationRequested, Timeout, PollInterval);
// ...and the supervisor re-dials (a stalled dial is a transport failure, never a silent end).
var invocations = dial.WaitForCount(2, Timeout);
invocations[1].CorrelationId.ShouldBe("central-node-1-2");
@@ -49,7 +53,7 @@ public sealed class TelemetryDialDeadlineTests : TestKit
Spawn(dial, callTimeoutSeconds: 1, sinks);
var first = dial.WaitForCount(1, Timeout).Single();
AwaitCondition(() => sinks.HealthStore.Upserts.Count == 1, Timeout);
AwaitCondition(() => sinks.HealthStore.Upserts.Count == 1, Timeout, PollInterval);
// Positive control: well past the deadline, the established stream is untouched.
await Task.Delay(TimeSpan.FromSeconds(2.5));
@@ -23,6 +23,10 @@ namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.Telemetry;
/// </summary>
public sealed class TelemetryDialSupervisorTests : TestKit
{
/// <summary>Explicit AwaitCondition poll interval: Akka's default is max / 10 of the dilated budget, i.e.
/// seconds under CI's timefactor (lmxopcua#775).</summary>
private static readonly TimeSpan PollInterval = TimeSpan.FromMilliseconds(20);
private static readonly TimeSpan Timeout = TimeSpan.FromSeconds(5);
[Fact]
@@ -66,7 +70,7 @@ public sealed class TelemetryDialSupervisorTests : TestKit
actor.Tell(new TelemetryDialSupervisor.RefreshNodes());
// node-1's dialer is cancelled and dropped.
AwaitCondition(() => node1.Ct.IsCancellationRequested, Timeout);
AwaitCondition(() => node1.Ct.IsCancellationRequested, Timeout, PollInterval);
// node-3 gets a fresh dialer.
var invocations = dial.WaitForCount(3, Timeout);
invocations.ShouldContain(i => i.Target.NodeId == "node-3" && i.CorrelationId == "central-node-3-1");
@@ -98,7 +102,7 @@ public sealed class TelemetryDialSupervisorTests : TestKit
actor.Tell(new TelemetryDialSupervisor.RefreshNodes());
// The old node-1 stream is torn down and a fresh dialer opens at the NEW endpoint (gen 2).
AwaitCondition(() => node1Original.Ct.IsCancellationRequested, Timeout);
AwaitCondition(() => node1Original.Ct.IsCancellationRequested, Timeout, PollInterval);
var invocations = dial.WaitForCount(3, Timeout);
invocations.ShouldContain(i =>
i.Target.NodeId == "node-1"
@@ -246,7 +250,7 @@ public sealed class TelemetryDialSupervisorTests : TestKit
Sys.Stop(actor);
AwaitCondition(() => inv.All(i => i.Ct.IsCancellationRequested), Timeout);
AwaitCondition(() => inv.All(i => i.Ct.IsCancellationRequested), Timeout, PollInterval);
}
[Fact]