fix(opcuaclient): stale BadNoSubscription after a resubscribe is not a subscription loss (lmxopcua#763, lmxopcua#728)
v2-ci / unit-tests (push) Has been cancelled
v2-ci / unit-tests (push) Has been cancelled
HandlePublishError treated any anonymous BadNoSubscription (subscription id 0) as loss of a tracked subscription whenever anything was tracked. A publish the SDK queued while the session briefly held no subscription (the driver had just deleted its last one) is answered BadNoSubscription and can be handled after the replacement is registered, so a routine unsubscribe->resubscribe declared the new subscription lost: Degraded health, a BadNoCommunication quality-only annotation on every alarm condition and ConnectionLost (host re-initialise). That annotation is the extra Unspecified event the #728 ConditionRefresh wire test saw. - A BadNoSubscription that names a subscription id now counts only if the id is tracked (same rule as BadSubscriptionIdInvalid). - An anonymous BadNoSubscription within StaleNoSubscriptionGrace (5 s) of a delete that left the driver tracking nothing is ignored (Debug log). The window is stamped on removal and restarted when the delete completes; failed-subscribe removes stamp it too; it resets with the session. A delete that leaves another subscription tracked opens no window. A genuine loss inside the window is still caught by the PublishingStopped heuristic; only the immediate ConnectionLost is forgone. - OpcUaClientStaleNoSubscriptionTests: stale error after alarm and data resubscribe (fail without the fix), id-attributed stale error, plus genuine-loss controls (after the grace, no recent delete, non-last delete, session release), each mutation-checked. - The ConditionRefresh wire test now records Kind, AlarmType, message, severity, quality, restatement and timestamp of every post-resubscribe event on failure. Wire test locally: 1/10 passing before (all 9 failures the 0x80310000 ConditionType quality-only annotation), 12/12 after. Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
+13
-2
@@ -314,10 +314,21 @@ public sealed class OpcUaClientDriverWireTests
|
||||
Enabled: true, AlarmShelvingKind.Unshelved, 800, "already hot"));
|
||||
await RecordedEvents.WaitUntilAsync(() => Seen().Any(e => e.Kind == AlarmTransitionKind.Acknowledge));
|
||||
await Task.Delay(500, ct);
|
||||
Seen().Skip(before).Select(e => e.Kind).ShouldBe([AlarmTransitionKind.Acknowledge],
|
||||
"the second refresh re-delivered an unchanged state and must have emitted nothing");
|
||||
// #728: record each event's full shape on failure, not only its Kind — the extra Unspecified that failed CI
|
||||
// could be a changed message/severity, a non-condition event or a quality-only annotation, and the Kind alone
|
||||
// cannot tell them apart.
|
||||
var after = Seen().Skip(before).ToArray();
|
||||
after.Select(e => e.Kind).ShouldBe([AlarmTransitionKind.Acknowledge],
|
||||
"the second refresh re-delivered an unchanged state and must have emitted nothing; events after the " +
|
||||
"resubscribe: " + string.Join(" | ", after.Select(Describe)));
|
||||
}
|
||||
|
||||
/// <summary>One alarm event's distinguishing fields, for a failure message.</summary>
|
||||
private static string Describe(AlarmEventArgs e) =>
|
||||
$"Kind={e.Kind} AlarmType={e.AlarmType} Message='{e.Message}' Severity={e.Severity}/{e.OpcUaSeverity?.ToString() ?? "-"} " +
|
||||
$"Quality={(e.QualityStatusCode is { } q ? $"0x{q:X8}" : "-")} Restatement={e.IsRestatement} " +
|
||||
$"Condition={e.ConditionId} Source={e.SourceTimestampUtc:HH:mm:ss.fff}";
|
||||
|
||||
private sealed class RecordingBuilder : IAddressSpaceBuilder
|
||||
{
|
||||
public List<(string BrowseName, DriverAttributeInfo Info)> Variables { get; } = [];
|
||||
|
||||
Reference in New Issue
Block a user