fix(adminui): Faulted-devices tile counts distinct Faulted devices across the cluster pair (#786)
Owner decision 2026-11-11: /fleet/diagnostics "Faulted devices" counts DISTINCT devices across the nodes of the selected node's cluster, Faulted state only. - DriverHostActor: FaultedDevices = HostState.Faulted only (Stopped no longer counted); new StoppedDevices + FaultedHostNames. Counting extracted to the testable DiagnosticsFromHealth. - DriverInstanceDiagnostics: StoppedDevices (default 0) and FaultedHostNames (default null) are additive with defaults, so a pre-#786 sender's snapshot still deserializes over Akka's default JSON serializer (pinned by a test). - FleetDiagnosticsAggregation (pure): identity key = (driver-instance string id, HostName), case-insensitive; a single-host driver / nameless pre-#786 count is combined by MAX across nodes, never summed. Cluster peers come from enabled ClusterNode rows of the selected node's ClusterId. - FleetDiagnostics.razor: tile fetches the cluster peers and shows the distinct count + "n of m nodes answered"; per-driver table gains a Stopped devices column. Claude-Session: https://claude.ai/code/session_01GT67AD99zQQqpLCVm3p7xk
This commit is contained in:
+43
@@ -4,6 +4,8 @@ using Xunit;
|
||||
using ZB.MOM.WW.OtOpcUa.Commons.Interfaces;
|
||||
using ZB.MOM.WW.OtOpcUa.Commons.Messages.Fleet;
|
||||
using ZB.MOM.WW.OtOpcUa.Commons.Types;
|
||||
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
||||
using ZB.MOM.WW.OtOpcUa.Runtime.Drivers;
|
||||
using ZB.MOM.WW.OtOpcUa.Runtime.Tests.Harness;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.Runtime.Tests.Drivers;
|
||||
@@ -43,6 +45,7 @@ public sealed class DriverHostActorDiagnosticsTests : RuntimeActorTestBase
|
||||
driver.State.ShouldBe("Healthy");
|
||||
driver.ConnectedDevices.ShouldBe(1);
|
||||
driver.FaultedDevices.ShouldBe(0);
|
||||
driver.StoppedDevices.ShouldBe(0);
|
||||
driver.LastChangeUtc.ShouldBeGreaterThan(before);
|
||||
driver.LastChangeUtc.ShouldBeLessThanOrEqualTo(DateTime.UtcNow);
|
||||
}
|
||||
@@ -66,6 +69,46 @@ public sealed class DriverHostActorDiagnosticsTests : RuntimeActorTestBase
|
||||
driver.FaultedDevices.ShouldBe(0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Faulted_counts_only_Faulted_hosts_and_Stopped_is_reported_separately()
|
||||
{
|
||||
// #786: a Stopped host used to be counted as faulted.
|
||||
var now = DateTime.UtcNow;
|
||||
var health = new ChildHealthRecord(
|
||||
DriverState.Degraded, now, null,
|
||||
new[]
|
||||
{
|
||||
new HostConnectivityStatus("plc-a:502", HostState.Running, now),
|
||||
new HostConnectivityStatus("plc-b:502", HostState.Faulted, now),
|
||||
new HostConnectivityStatus("plc-c:502", HostState.Stopped, now),
|
||||
new HostConnectivityStatus("plc-d:502", HostState.Stopped, now),
|
||||
new HostConnectivityStatus("plc-e:502", HostState.Unknown, now),
|
||||
},
|
||||
now);
|
||||
|
||||
var row = DriverHostActor.DiagnosticsFromHealth(Guid.NewGuid(), DriverId, health);
|
||||
|
||||
row.ConnectedDevices.ShouldBe(1);
|
||||
row.FaultedDevices.ShouldBe(1);
|
||||
row.StoppedDevices.ShouldBe(2);
|
||||
row.FaultedHostNames.ShouldBe(new[] { "plc-b:502" });
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(DriverState.Faulted, 0, 1)]
|
||||
[InlineData(DriverState.Healthy, 1, 0)]
|
||||
[InlineData(DriverState.Degraded, 1, 0)]
|
||||
public void A_single_host_driver_is_one_device_with_no_host_name(DriverState state, int connected, int faulted)
|
||||
{
|
||||
var row = DriverHostActor.DiagnosticsFromHealth(
|
||||
Guid.NewGuid(), DriverId, new ChildHealthRecord(state, null, null, null, DateTime.UtcNow));
|
||||
|
||||
row.ConnectedDevices.ShouldBe(connected);
|
||||
row.FaultedDevices.ShouldBe(faulted);
|
||||
row.StoppedDevices.ShouldBe(0);
|
||||
row.FaultedHostNames.ShouldNotBeNull().ShouldBeEmpty();
|
||||
}
|
||||
|
||||
private async Task<NodeDiagnosticsSnapshot> AwaitDiagnosticsAsync(IActorRef host, Func<NodeDiagnosticsSnapshot, bool> ready)
|
||||
{
|
||||
NodeDiagnosticsSnapshot? snapshot = null;
|
||||
|
||||
Reference in New Issue
Block a user