fix(health): evict deleted sites from the aggregator on the periodic site refresh
This commit is contained in:
@@ -473,6 +473,27 @@ public class CentralHealthAggregatorTests
|
||||
Assert.False(aggregator.GetSiteState("site-a")!.IsMetricsStale);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Review 01 [Low]: <c>_siteStates</c> only ever grew — a site deleted from
|
||||
/// configuration remained a permanently-offline dashboard tile (and a KPI
|
||||
/// sample source) forever. Pruning against the known-site set evicts it; the
|
||||
/// synthetic central id is always retained.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void PruneUnknownSites_RemovesDeletedSites_KeepsKnownAndCentral()
|
||||
{
|
||||
var (aggregator, _) = NewAggregator();
|
||||
aggregator.ProcessReport(MakeReport("site-a", 1));
|
||||
aggregator.ProcessReport(MakeReport("site-b", 1));
|
||||
aggregator.ProcessReport(MakeReport(CentralHealthReportLoop.CentralSiteId, 1));
|
||||
|
||||
aggregator.PruneUnknownSites(new[] { "site-a" });
|
||||
|
||||
Assert.NotNull(aggregator.GetSiteState("site-a"));
|
||||
Assert.Null(aggregator.GetSiteState("site-b"));
|
||||
Assert.NotNull(aggregator.GetSiteState(CentralHealthReportLoop.CentralSiteId)); // synthetic id always kept
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Review 01 underdeveloped #7: "when did the site drop" was unanswerable.
|
||||
/// Every online↔offline flip stamps <see cref="SiteHealthState.LastStatusChangeAt"/>.
|
||||
|
||||
Reference in New Issue
Block a user