fix(hosts): driver health is per (driver, node) — ReportingNodeId on DriverHealthChanged + telemetry proto (#847)
This commit is contained in:
@@ -56,4 +56,39 @@ public sealed class DriverStatusSnapshotStoreTests
|
||||
|
||||
count.ShouldBe(1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Snapshots_from_two_nodes_for_one_driver_are_kept_side_by_side_847()
|
||||
{
|
||||
var store = new InMemoryDriverStatusSnapshotStore();
|
||||
var t0 = new DateTime(2026, 11, 11, 0, 0, 0, DateTimeKind.Utc);
|
||||
store.Upsert(new DriverHealthChanged("MAIN", "drv", "Faulted", null, "x", 1, t0, ReportingNodeId: "central-1"));
|
||||
store.Upsert(new DriverHealthChanged("MAIN", "drv", "Healthy", null, null, 0, t0.AddSeconds(1), ReportingNodeId: "central-2"));
|
||||
// A re-publish from central-1 replaces only central-1's entry.
|
||||
store.Upsert(new DriverHealthChanged("MAIN", "drv", "Faulted", null, "y", 2, t0.AddSeconds(2), ReportingNodeId: "central-1"));
|
||||
|
||||
var all = store.GetAll();
|
||||
all.Count.ShouldBe(2);
|
||||
all.Single(s => s.ReportingNodeId == "central-1").LastError.ShouldBe("y");
|
||||
all.Single(s => s.ReportingNodeId == "central-2").State.ShouldBe("Healthy");
|
||||
|
||||
// TryGet (the per-driver panel / hub) answers the most recently published across nodes.
|
||||
store.TryGet("drv", out var latest).ShouldBeTrue();
|
||||
latest.ReportingNodeId.ShouldBe("central-1");
|
||||
latest.LastError.ShouldBe("y");
|
||||
store.TryGet("other", out _).ShouldBeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Eviction_removes_every_node_entry_of_an_unconfigured_stale_driver_847()
|
||||
{
|
||||
var store = new InMemoryDriverStatusSnapshotStore();
|
||||
var old = new DateTime(2026, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
store.Upsert(new DriverHealthChanged("MAIN", "gone", "Healthy", null, null, 0, old, ReportingNodeId: "a"));
|
||||
store.Upsert(new DriverHealthChanged("MAIN", "gone", "Healthy", null, null, 0, old, ReportingNodeId: "b"));
|
||||
store.Upsert(new DriverHealthChanged("MAIN", "kept", "Healthy", null, null, 0, old, ReportingNodeId: "a"));
|
||||
|
||||
store.EvictUnconfiguredStale(new HashSet<string> { "kept" }, old.AddMinutes(1)).ShouldBe(2);
|
||||
store.GetAll().ShouldHaveSingleItem().DriverInstanceId.ShouldBe("kept");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user