test(grpc-data): A4 live scenarios part 2 harness — A03 origin failover (same-incarnation stream reset via mapping revision bump, clear-and-re-raise in the gap, RefreshRequired, BadEventIdUnknown, refreshed EventId acks), A06 consumer Primary change across both nodes + second CONSUMER principal fixture-cli-alt, A07 consumer restart refresh-vs-barrier; CLI alarms prints EventType (names RefreshStart/End/Required)

This commit is contained in:
Joseph Doherty
2026-11-25 01:44:58 -05:00
parent c82b8683b0
commit 9ea50c11b2
8 changed files with 365 additions and 12 deletions
@@ -106,6 +106,31 @@ public class AlarmsCommandTests
output.ShouldContain("EventId: AB01FF");
}
/// <summary>The printed alarm names the EventType, so a script can spot RefreshRequired (i=2789) from a consumer.</summary>
[Fact]
public async Task Execute_PrintsEventType_NamingRefreshRequired()
{
var fakeService = new FakeOpcUaClientService();
var factory = new FakeOpcUaClientServiceFactory(fakeService);
var command = new AlarmsCommand(factory) { Url = "opc.tcp://localhost:4840" };
using var console = TestConsoleHelper.CreateConsole();
var task = Task.Run(async () => { await command.ExecuteAsync(console); }, TestContext.Current.CancellationToken);
await fakeService.SubscribeAlarmsInvoked.WaitAsync(TimeSpan.FromSeconds(10), TestContext.Current.CancellationToken);
fakeService.RaiseAlarmEvent(new Client.Shared.Models.AlarmEventArgs(
"Server", "", 100, "refresh", false, false, false, DateTime.UtcNow, eventType: "i=2789"));
fakeService.RaiseAlarmEvent(new Client.Shared.Models.AlarmEventArgs(
"src", "cond", 500, "msg", true, true, false, DateTime.UtcNow, eventType: "ns=0;i=10637"));
await Task.Delay(500, TestContext.Current.CancellationToken);
console.RequestCancellation();
await task;
var output = TestConsoleHelper.GetOutput(console);
output.ShouldContain("EventType: RefreshRequiredEventType (i=2789)");
output.ShouldContain("EventType: ns=0;i=10637");
}
/// <summary>Verifies that refresh failure prints error.</summary>
[Fact]
public async Task Execute_RefreshFailure_PrintsError()
@@ -1209,6 +1209,7 @@ public class OpcUaClientServiceTests : IDisposable
received.ShouldNotBeNull();
received!.SourceName.ShouldBe("PartialSource");
received.Severity.ShouldBe((ushort)0); // default — field 5 not present
received.EventType.ShouldBe(ObjectTypeIds.AlarmConditionType.ToString()); // field 1 surfaced for RefreshRequired detection
}
/// <summary>