test: shared actor test bases poll AwaitCondition every 20 ms, not max/10 (lmxopcua#775)
v2-ci / unit-tests (push) Has been cancelled
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:
+38
-1
@@ -1,4 +1,5 @@
|
||||
using Akka.Cluster;
|
||||
using Akka.TestKit;
|
||||
using Akka.TestKit.Xunit2;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ZB.MOM.WW.OtOpcUa.Configuration;
|
||||
@@ -21,7 +22,9 @@ public abstract class ControlPlaneActorTestBase : TestKit
|
||||
/// <c>AwaitAssert</c>) — the same doctrine as <c>RuntimeActorTestBase.PresenceBudget</c>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A budget, not a delay: the helpers return the instant the condition holds, so raising it costs
|
||||
/// A budget, not a delay: the helpers return within one poll interval of the condition holding
|
||||
/// (<c>AwaitCondition</c> polls every <see cref="PollInterval"/> through this class's overloads, not Akka's
|
||||
/// <c>max / 10</c> of the dilated budget — lmxopcua#775), so raising it costs
|
||||
/// nothing on the happy path and cannot make a genuinely failing assertion pass. Several actors here
|
||||
/// do their first EF Core (InMemory) work inside the waited-for step — model build is a multi-second
|
||||
/// cold cost on a loaded CI runner — and 3–5 s budgets sized on an idle machine failed there (#606).
|
||||
@@ -29,6 +32,40 @@ public abstract class ControlPlaneActorTestBase : TestKit
|
||||
/// </remarks>
|
||||
protected static readonly TimeSpan PresenceBudget = TimeSpan.FromSeconds(15);
|
||||
|
||||
/// <summary>
|
||||
/// Poll interval for every <c>AwaitCondition</c> in this class's subclasses that does not pass its own
|
||||
/// (lmxopcua#775). Akka's own default is <c>max / 10</c> of the DILATED budget — 1.5 s for a 15 s budget
|
||||
/// locally, 4.5 s under CI's <c>AKKA_TEST_TIMEFACTOR=3</c> — so a wait could overshoot the moment its
|
||||
/// condition held by seconds. That wasted CI time everywhere, and failed tests where an undilated
|
||||
/// deadline in the code under test elapsed during the overshoot (lmxopcua 342a825d). <c>AwaitAssert</c>
|
||||
/// is unaffected: its default interval is a fixed 100 ms.
|
||||
/// </summary>
|
||||
protected static readonly TimeSpan PollInterval = TimeSpan.FromMilliseconds(20);
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="TestKitBase.AwaitCondition(Func{bool}, TimeSpan?, TimeSpan?, string, CancellationToken)"/> with
|
||||
/// <paramref name="interval"/> defaulting to <see cref="PollInterval"/> instead of Akka's <c>max / 10</c>.
|
||||
/// Hides the TestKit overloads, so every subclass call without an interval binds here.
|
||||
/// </summary>
|
||||
/// <param name="conditionIsFulfilled">The condition to poll.</param>
|
||||
/// <param name="max">The budget (dilated by Akka); null takes the enclosing <c>Within</c> or the default.</param>
|
||||
/// <param name="interval">The poll interval; null means <see cref="PollInterval"/>.</param>
|
||||
/// <param name="message">The failure message.</param>
|
||||
/// <param name="cancellationToken">Cancels the wait.</param>
|
||||
protected new void AwaitCondition(Func<bool> conditionIsFulfilled, TimeSpan? max = null, TimeSpan? interval = null,
|
||||
string? message = null, CancellationToken cancellationToken = default) =>
|
||||
base.AwaitCondition(conditionIsFulfilled, max, interval ?? PollInterval, message!, cancellationToken);
|
||||
|
||||
/// <summary>The message-carrying overload of <see cref="AwaitCondition(Func{bool}, TimeSpan?, TimeSpan?, string?, CancellationToken)"/>,
|
||||
/// polled every <see cref="PollInterval"/>.</summary>
|
||||
/// <param name="conditionIsFulfilled">The condition to poll.</param>
|
||||
/// <param name="max">The budget (dilated by Akka).</param>
|
||||
/// <param name="message">The failure message.</param>
|
||||
/// <param name="cancellationToken">Cancels the wait.</param>
|
||||
protected new void AwaitCondition(Func<bool> conditionIsFulfilled, TimeSpan? max, string message,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
base.AwaitCondition(conditionIsFulfilled, max, PollInterval, message, cancellationToken);
|
||||
|
||||
/// <summary>Gets the Akka configuration for test actors, including cluster and pub-sub extensions.</summary>
|
||||
/// <remarks>
|
||||
/// <c>akka.test.single-expect-default</c> is raised from Akka's 3 s to <see cref="PresenceBudget"/>:
|
||||
|
||||
Reference in New Issue
Block a user