a2f0086fa1
ROW 80 (observability correctness). An unreplicated site published
LocalDbReplicationConnected=false / LocalDbOplogBacklog=0, contradicting the
nullable semantics every doc and the proto already state ("null means no
reading, NOT disconnected with an empty backlog").
Root cause: the replication engine is registered unconditionally and idles
without a peer, so ISyncStatus answers false/0 on a node that was never meant to
replicate, and LocalDbReplicationStatusReporter passed that straight through.
Two consequences: an operator read connected:false on a healthy site as a fault,
and central's null branches — row 33's conditional KPI emission and
sustained-badge anchor exclusion — never received the null they exist for, so
rig site-b/site-c emitted a permanently misleading
localDbReplicationConnected=0 series.
Fix mirrors the SiteEventLogReplicationCheck precedent: the Host evaluates
SiteLocalDbSetup.ReplicationIsConfigured ONCE and passes it to
AddLocalDbReplicationHealthBridge as a third provider; unconfigured
short-circuits the probe to (null, null). HealthMonitoring never reads LocalDb
config itself, and the same captured value now also feeds
SiteEventLogReplicationCheck so the two surfaces cannot disagree.
ISiteHealthCollector.SetLocalDbReplicationStatus widens to bool? — the
non-nullable bool was the type-level root cause (null was inexpressible).
false now means exactly one thing: configured, peer session down = a real fault.
Wire/central/UI needed no change: the proto already carries BoolValue/Int64Value
wrappers and the aggregator + KPI source already branch on null. This makes code
match doc, so no doc claim was weakened.
Watch the trap that caused this: configured-ness is PeerAddress OR ApiKey (only
the dialling half sets a peer address). The pre-existing SiteLocalDbWiringTests
fixture sets ApiKey and IS a replicating node, so its false/0 assertion is
correct and is kept, with a comment saying so; the new
UnreplicatedSiteLocalDbHealthTests fixture is the genuinely-unreplicated one.
ROW 73 (silent loss of self-heal). AkkaHostedService skips
SiteReconciliationActor when no IDeploymentConfigFetcher is resolvable, and that
skip was a lone boot Warning — a node with no self-heal path at all went on
reporting itself perfectly healthy forever.
Adds tri-state SiteHealthReport.StartupReconcilerActive (null = not reported,
i.e. the central self-report or a pre-row-73 site build; true = running;
false = booted without it), latched once at boot by the Host in both branches.
Additive proto field 29 (BoolValue, vendored C# regenerated via
docker/regen-proto.sh centralcontrol; csproj restored, verified empty diff).
The skip branch also raises its log to Error — no configuration makes the
fetcher legitimately absent on a site node — and writes a best-effort
deployment/Error site event so the evidence outlives the boot log.
Central treatment: a "No self-heal" WARNING badge on the site tile, not a
failure. Config still reaches the node via LocalDb replication while it is up;
what it lost is recovery from a deploy that landed while it was down — degraded,
not offline. Only the explicit false is badged (badging null would light up the
whole fleet the moment central is upgraded ahead of the sites), and offline
sites are skipped, matching the replication-backlog badge.
Fail-before evidence: with the row-80 gate behaviourally reverted,
UnreplicatedSite_HealthReport_ReportsNullForBothLocalDbFields fails
"Expected: null / Actual: False" and 3 of the 8 new reporter unit tests fail.
Tests: HealthMonitoring 128, Host 518, CentralUI 1051, Communication 717,
Commons 715, SiteEventLogging 81 — all green.
80 lines
3.0 KiB
C#
80 lines
3.0 KiB
C#
namespace ZB.MOM.WW.ScadaBridge.HealthMonitoring.Tests;
|
|
|
|
/// <summary>
|
|
/// Deferred-work register row 73 — <c>SiteHealthReport.StartupReconcilerActive</c> surfaces
|
|
/// whether a site node spawned its <c>SiteReconciliationActor</c> at boot.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// The skip used to be a single boot Warning and nothing else, so a node that lost its whole
|
|
/// self-heal path went on reporting itself perfectly healthy. The field is tri-state and the
|
|
/// three cases must stay distinct: null = not reported (central self-report, or a pre-row-73
|
|
/// site build), true = running, false = skipped because no <c>IDeploymentConfigFetcher</c>
|
|
/// was available. Collapsing null into false would badge every site the moment central is
|
|
/// upgraded ahead of them.
|
|
/// </remarks>
|
|
public class StartupReconcilerHealthFieldTests
|
|
{
|
|
[Fact]
|
|
public void CollectReport_NeverTold_LeavesTheFieldNull()
|
|
{
|
|
// "Not reported" — NOT "the reconciler is missing". This is the state of central's
|
|
// own self-report and of every test host that never calls the setter.
|
|
var collector = new SiteHealthCollector();
|
|
|
|
var report = collector.CollectReport("TestSite");
|
|
|
|
Assert.Null(report.StartupReconcilerActive);
|
|
}
|
|
|
|
[Fact]
|
|
public void CollectReport_ReconcilerSpawned_ReportsTrue()
|
|
{
|
|
var collector = new SiteHealthCollector();
|
|
|
|
collector.SetStartupReconcilerActive(true);
|
|
|
|
Assert.True(collector.CollectReport("TestSite").StartupReconcilerActive);
|
|
}
|
|
|
|
[Fact]
|
|
public void CollectReport_ReconcilerSkipped_ReportsFalse_NotNull()
|
|
{
|
|
// The case the row exists for: false must be distinguishable from "not reported",
|
|
// because false is what central badges.
|
|
var collector = new SiteHealthCollector();
|
|
|
|
collector.SetStartupReconcilerActive(false);
|
|
|
|
var report = collector.CollectReport("TestSite");
|
|
Assert.NotNull(report.StartupReconcilerActive);
|
|
Assert.False(report.StartupReconcilerActive);
|
|
}
|
|
|
|
[Fact]
|
|
public void CollectReport_IsPointInTime_NotDrainedOnCollect()
|
|
{
|
|
// A latched boot fact, not a per-interval counter: every subsequent report must
|
|
// carry it, or the badge would flicker off after the first report.
|
|
var collector = new SiteHealthCollector();
|
|
collector.SetStartupReconcilerActive(false);
|
|
|
|
collector.CollectReport("TestSite");
|
|
var second = collector.CollectReport("TestSite");
|
|
|
|
Assert.False(second.StartupReconcilerActive);
|
|
}
|
|
|
|
[Fact]
|
|
public void SetStartupReconcilerActive_IsNotWriteOnce()
|
|
{
|
|
// Nothing in the Host calls this twice today, but a latch that silently ignored a
|
|
// correction would be a nasty way to find that out.
|
|
var collector = new SiteHealthCollector();
|
|
|
|
collector.SetStartupReconcilerActive(false);
|
|
collector.SetStartupReconcilerActive(true);
|
|
|
|
Assert.True(collector.CollectReport("TestSite").StartupReconcilerActive);
|
|
}
|
|
}
|