fix(health-monitoring): resolve HealthMonitoring-015 — nullable LastReportReceivedAt
A heartbeat-registered site that has never sent a full report now has
LastReportReceivedAt = null instead of the year-0001 sentinel. TimestampDisplay
accepts DateTimeOffset? and renders null as a placeholder ('awaiting first
report') rather than a ~2000-year-stale date. Cross-module: HealthMonitoring +
CentralUI.
This commit is contained in:
@@ -240,6 +240,43 @@ public class CentralHealthAggregatorTests
|
||||
Assert.Equal(now, state.LastHeartbeatAt);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Regression test for HealthMonitoring-015. A heartbeat-only registered site
|
||||
/// has never processed a full report, so <see cref="SiteHealthState.LastReportReceivedAt"/>
|
||||
/// must be <c>null</c> — not the <c>DateTimeOffset.MinValue</c> (year-0001)
|
||||
/// sentinel that the UI would otherwise render as a ~2000-year-stale timestamp.
|
||||
/// The "no report yet" signal must be an explicit nullable state, consistent
|
||||
/// with <see cref="SiteHealthState.LatestReport"/>.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void MarkHeartbeat_RegistersUnknownSite_WithNullLastReportReceivedAt()
|
||||
{
|
||||
_aggregator.MarkHeartbeat("site-new", _timeProvider.GetUtcNow());
|
||||
|
||||
var state = _aggregator.GetSiteState("site-new");
|
||||
Assert.NotNull(state);
|
||||
Assert.Null(state.LastReportReceivedAt);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Regression test for HealthMonitoring-015. Once a full report is processed
|
||||
/// for a heartbeat-registered site, <see cref="SiteHealthState.LastReportReceivedAt"/>
|
||||
/// becomes a real (non-null) instant.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void ProcessReport_SetsLastReportReceivedAt_ForHeartbeatRegisteredSite()
|
||||
{
|
||||
_aggregator.MarkHeartbeat("site-new", _timeProvider.GetUtcNow());
|
||||
_timeProvider.Advance(TimeSpan.FromSeconds(5));
|
||||
var reportTime = _timeProvider.GetUtcNow();
|
||||
|
||||
_aggregator.ProcessReport(MakeReport("site-new", 1));
|
||||
|
||||
var state = _aggregator.GetSiteState("site-new");
|
||||
Assert.NotNull(state);
|
||||
Assert.Equal(reportTime, state.LastReportReceivedAt);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MarkHeartbeat_KeepsSiteOnline_BetweenReports()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user