fix(communication): replicate heartbeat marks to the peer central node (closes post-failover offline blind window)
This commit is contained in:
@@ -148,6 +148,33 @@ public class CentralCommunicationActorTests : TestKit
|
||||
AwaitAssert(() => aggregator.Received(1).MarkHeartbeat("site1", timestamp));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HeartbeatReplica_MarksLocalAggregator_WithoutRebroadcast()
|
||||
{
|
||||
// Task 16 (arch review 02): a heartbeat replicated from the peer central
|
||||
// node marks the local aggregator (so post-failover both nodes know the
|
||||
// site's liveness) but is NOT re-published (it arrives via pub-sub already).
|
||||
var mockRepo = Substitute.For<ISiteRepository>();
|
||||
mockRepo.GetAllSitesAsync(Arg.Any<CancellationToken>())
|
||||
.Returns(new List<Site>());
|
||||
|
||||
var aggregator = Substitute.For<ICentralHealthAggregator>();
|
||||
|
||||
var services = new ServiceCollection();
|
||||
services.AddScoped(_ => mockRepo);
|
||||
services.AddSingleton(aggregator);
|
||||
var sp = services.BuildServiceProvider();
|
||||
|
||||
var siteClientFactory = Substitute.For<ISiteClientFactory>();
|
||||
var centralActor = Sys.ActorOf(
|
||||
Props.Create(() => new CentralCommunicationActor(sp, siteClientFactory)));
|
||||
|
||||
var ts = DateTimeOffset.UtcNow;
|
||||
centralActor.Tell(new SiteHeartbeatReplica(new HeartbeatMessage("site-1", "host-a", true, ts)));
|
||||
|
||||
AwaitAssert(() => aggregator.Received(1).MarkHeartbeat("site-1", ts));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RefreshSiteAddresses_UpdatesCache()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user