- NodeManagerLockTimeBenchmark: wall-clock budget enforced only with OTOPCUA_BENCH=1; default run keeps the state-correctness asserts and logs timings. - OpcUaClientDriverWire host-status: signal (semaphore) wait that only accepts a non-Running state observed after the server is disposed. - AbCip PollLatencyComparison: retry once on a fixture connection reset; p95 criterion enforced only with AB_LAT_ENFORCE=1. - ScriptRunGuardTests: orphan scripts held by a ctx.Released signal instead of a 250 ms wall-clock spin that could finish inside the 60 ms budget under load; stuck-orphan wall-clock rule disabled in the tests that pin the strike counting. - DependencyMuxReplayTests: split the inside-grace positive control (1 h grace) from the release test (control asserted before unregister), removing the 200 ms grace race. Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
+16
-10
@@ -212,20 +212,26 @@ public sealed class OpcUaClientDriverWireTests
|
||||
await drv.InitializeAsync("{}", ct);
|
||||
drv.GetHostStatuses().Single().State.ShouldBe(HostState.Running);
|
||||
|
||||
var transitioned = new TaskCompletionSource<HostState>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
drv.OnHostStatusChanged += (_, e) =>
|
||||
{
|
||||
if (e.NewState != HostState.Running) transitioned.TrySetResult(e.NewState);
|
||||
};
|
||||
// Signal-based (lmxopcua#769): every host-status event releases the semaphore, and the loop re-reads the
|
||||
// driver's state. A transient non-Running tick BEFORE the server is gone (a starved keep-alive) must not
|
||||
// satisfy the wait, so the loop only accepts a non-Running state observed AFTER the rig is disposed; the
|
||||
// 120 s ceiling only matters on a starved box and costs nothing when the signal arrives.
|
||||
using var signal = new SemaphoreSlim(0);
|
||||
drv.OnHostStatusChanged += (_, _) => signal.Release();
|
||||
|
||||
await rig.DisposeAsync();
|
||||
rig = null;
|
||||
signal.Release(); // re-evaluate once now that the server is certainly gone
|
||||
|
||||
var deadline = TimeSpan.FromSeconds(120);
|
||||
var sw = System.Diagnostics.Stopwatch.StartNew();
|
||||
while (drv.GetHostStatuses().Single().State == HostState.Running)
|
||||
{
|
||||
var remaining = deadline - sw.Elapsed;
|
||||
(await signal.WaitAsync(remaining > TimeSpan.Zero ? remaining : TimeSpan.Zero, ct))
|
||||
.ShouldBeTrue("the host probe never left Running after the server stopped");
|
||||
}
|
||||
|
||||
// Signal-based (lmxopcua#769): the wait completes the instant the keep-alive loop reports the loss, so
|
||||
// the ceiling only matters on a starved box, where server teardown plus the 10 s request timeout plus a
|
||||
// 1 s keep-alive tick exceeded the old 30 s. A generous ceiling costs nothing when the signal arrives.
|
||||
var state = await transitioned.Task.WaitAsync(TimeSpan.FromSeconds(120), ct);
|
||||
state.ShouldNotBe(HostState.Running);
|
||||
drv.GetHostStatuses().Single().State.ShouldNotBe(HostState.Running);
|
||||
}
|
||||
finally
|
||||
|
||||
Reference in New Issue
Block a user