fix(scripting): count re-triggers answered 'worker unresponsive' (#827 review F5)

otopcua.script.ipc.timeouts gains the tag answer = stalled | retrigger: a
later trigger refused while the key's stalled run is still unanswered was
counted nowhere (not a script refusal, so not ScriptRunGuard's counter).
KeyState carries its Kind for the tag. Test: the stalled-worker test listens
for the instrument and sees one stalled and one retrigger (before: only
stalled).
This commit is contained in:
Joseph Doherty
2026-11-11 02:25:17 -05:00
parent 3f5fdd1d90
commit f50209082e
2 changed files with 24 additions and 2 deletions
@@ -87,6 +87,19 @@ public sealed class WorkerSoftClockTests
var grace = TimeSpan.FromMilliseconds(400);
await using var runner = Runner(grace);
var worker = await WarmAsync(runner, "trivial");
// Review F5: both answers are counted (otopcua.script.ipc.timeouts, answer = stalled | retrigger).
var answers = new System.Collections.Concurrent.ConcurrentQueue<string>();
using var listener = new System.Diagnostics.Metrics.MeterListener();
listener.InstrumentPublished = (instrument, l) =>
{
if (instrument.Name == "otopcua.script.ipc.timeouts") l.EnableMeasurementEvents(instrument);
};
listener.SetMeasurementEventCallback<long>((_, _, tags, _) =>
{
foreach (var tag in tags)
if (tag.Key == "answer") answers.Enqueue((string)tag.Value!);
});
listener.Start();
ScriptRunOutcome stalled, retriggered;
using (ProcessFreezer.Freeze(worker.Pid))
@@ -101,6 +114,7 @@ public sealed class WorkerSoftClockTests
retriggered.Status.ShouldBe(ScriptRunStatus.Unavailable, retriggered.Reason);
retriggered.Reason.ShouldBe(ScriptRunOutcome.WorkerUnresponsiveReason);
stalled.ToVirtualTagEvalResult().StatusCode.ShouldBe(Commons.OpcUa.OpcUaStatus.BadResourceUnavailable);
answers.ToArray().ShouldBe(["stalled", "retrigger"], ignoreOrder: true);
await stalled.Recovery!.WaitAsync(TimeSpan.FromSeconds(30), Ct);
var next = await runner.RunAsync(Scripts.Vt("trivial", Trivial, softT), Ct);