diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.ScriptWorker.Tests/PipeFaultTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.ScriptWorker.Tests/PipeFaultTests.cs index bfe8d1460..3bdfa1ac4 100644 --- a/tests/Server/ZB.MOM.WW.OtOpcUa.ScriptWorker.Tests/PipeFaultTests.cs +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.ScriptWorker.Tests/PipeFaultTests.cs @@ -65,6 +65,18 @@ public sealed class PipeFaultTests /// starts only when the worker starts it) blocks in the write. The write-stall check must kill the worker within /// its bound — as unresponsive, not for silence, which proves it kept heartbeating — and that releases the producer. /// + /// + /// The two bounds are relative: the silence limit must stay well below the write-stall limit, or a worker (or a + /// host reader) that stopped heartbeating along with the reader would also be killed "unresponsive" and the + /// assertion would prove nothing. lmxopcua#1100 sizes them for whole-process stalls of a swapping dev box (see + /// SupervisionTests' #1092 remarks: 290–380 ms late beats measured at the worker, ~1 s observed): the silence + /// limit was 5 × 200 ms = 1 s, which a 1 s stall reaches; it is now 2 s (10 intervals — a stall must exceed ~1.8 s), + /// and the write-stall limit 5 s (was 2 s) so a silent worker is still killed for silence 3 s before the write-stall + /// check could fire. Mutation check: a worker that stops its heartbeat when its reader stalls exits + /// KilledHeartbeat at ~2 s, which releases the producer before the stallLimit / 2 positive control, and the test fails. + /// Stall check (temporary, not committed): the worker SIGSTOPped for 1.2 s right after its reader stopped failed the + /// old bounds 3 of 3 runs (killed for silence) and passed the new ones 3 of 3. + /// [Fact] public async Task A_worker_that_stops_reading_but_keeps_heartbeating_is_killed_and_the_blocked_producer_returns() { @@ -77,8 +89,8 @@ public sealed class PipeFaultTests var warm = await connection.EnsureLoadedAsync("k", ContextKind.VirtualTag, Healthy, SHA256.HashData(Encoding.UTF8.GetBytes(Healthy)), []).WaitAsync(TimeSpan.FromSeconds(60), Ct); warm.Outcome.ShouldNotBeNull().Ok.ShouldBeTrue(); - connection.SilenceLimit = heartbeat * 5; // armed once the cold start is over (see SupervisionTests) - var stallLimit = TimeSpan.FromSeconds(2); + connection.SilenceLimit = heartbeat * 10; // armed once the cold start is over (see SupervisionTests); see remarks (#1100) + var stallLimit = TimeSpan.FromSeconds(5); connection.WriteStallLimitOverride = stallLimit; _ = connection.DiagnosticsAsync(TimeSpan.FromSeconds(60)); // the worker's reader stops here for good diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.ScriptWorker.Tests/SupervisionTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.ScriptWorker.Tests/SupervisionTests.cs index 9ef339c0e..a6535e1b1 100644 --- a/tests/Server/ZB.MOM.WW.OtOpcUa.ScriptWorker.Tests/SupervisionTests.cs +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.ScriptWorker.Tests/SupervisionTests.cs @@ -146,7 +146,9 @@ public sealed class SupervisionTests // under 28 CPU burners, every compile on its dedicated thread), and at ~300 even a 1 s limit was hit once in 10 // (1,012 ms). The limit is now PRODUCTION's (3 × the default 1 s heartbeat): the test kills only where a real node // would, and the windev defect (no frame for 3 s, the whole burst) is still the size it catches. The 50 ms - // heartbeat keeps frames flowing for the silence clock. + // heartbeat keeps frames flowing for the silence clock. lmxopcua#1100 audit: kept as is — with a frame every 50 ms + // (plus every LoadResult) only a stall of ~2.95 s trips it, three times the ~1 s whole-process stalls measured for + // #1092, and raising it past production's limit would stop the test catching the 3 s windev defect. worker.SilenceLimit = TimeSpan.FromSeconds(3); const int count = 1500; diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.ScriptWorker.Tests/WorkerSoftClockTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.ScriptWorker.Tests/WorkerSoftClockTests.cs index 2a7fa4dd8..3a6e2dd9a 100644 --- a/tests/Server/ZB.MOM.WW.OtOpcUa.ScriptWorker.Tests/WorkerSoftClockTests.cs +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.ScriptWorker.Tests/WorkerSoftClockTests.cs @@ -395,6 +395,17 @@ public sealed class WorkerSoftClockTests } /// Positive control for the ceiling: the default rule leaves a busy, answering worker alone. + /// + /// lmxopcua#1100: the ceiling was 1 s over 20 × 150 ms runs (~3 s). A whole-process stall of about 1 s on a swapping + /// dev box (see SupervisionTests' #1092 remarks) is a 1.15 s gap between two answers, past that ceiling, so a + /// healthy worker could be killed. Now the ceiling is 2.5 s over 40 runs (~6 s): a gap must exceed ~2.3 s of stall + /// to trip it, while the defect the test guards — progress not advanced by each answer, so the ceiling runs from + /// the batch's submit — still kills the worker 3.5 s before the batch could finish. Mutation check: drop the + /// progress stamp on a Results frame (WorkerConnection.HandleFrame) and the worker is killed + /// (KilledUnresponsive), so the remaining runs complete null and the test fails. Stall check (temporary, not + /// committed): the worker SIGSTOPped for 1 s mid-batch was killed under the old bounds (KilledUnresponsive at the + /// resume, every queued run completed null); under the new ones it survived 1.2 s stalls 3 of 3 runs. + /// [Fact] public async Task The_progress_ceiling_leaves_a_worker_that_keeps_answering_alone() { @@ -407,10 +418,10 @@ public sealed class WorkerSoftClockTests var entry = await connection.EnsureLoadedAsync("k", ContextKind.VirtualTag, spin, SHA256.HashData(Encoding.UTF8.GetBytes(spin)), []).WaitAsync(TimeSpan.FromSeconds(60), Ct); entry.Outcome.ShouldNotBeNull().Ok.ShouldBeTrue(); - // Ceiling 1 s; 20 runs of 150 ms queued behind one evaluation thread take ~3 s, but each answers. - connection.ProgressCeilingOverride = TimeSpan.FromSeconds(1); + // Ceiling 2.5 s; 40 runs of 150 ms queued behind one evaluation thread take ~6 s, but each answers (see remarks). + connection.ProgressCeilingOverride = TimeSpan.FromSeconds(2.5); var soft = TimeSpan.FromSeconds(30); - var pendings = connection.SubmitBatch(Enumerable.Range(0, 20).Select(_ => new BatchSubmission("k", + var pendings = connection.SubmitBatch(Enumerable.Range(0, 40).Select(_ => new BatchSubmission("k", new EvalRequest { Key = "k", SoftTimeoutMs = 30_000, HardGraceMs = 60_000, NowUtcTicks = DateTime.UtcNow.Ticks }, soft, TimeSpan.FromSeconds(60), null)).ToArray()); foreach (var p in pendings) (await p.Completion.WaitAsync(TimeSpan.FromSeconds(30), Ct)).ShouldNotBeNull();