fix(communication): correct audit-ingest timeout-path docs and add timeout test
This commit is contained in:
@@ -24,7 +24,7 @@ public class CentralCommunicationActorAuditTests : TestKit
|
||||
{
|
||||
public CentralCommunicationActorAuditTests() : base(@"akka.loglevel = DEBUG") { }
|
||||
|
||||
private IActorRef CreateActor()
|
||||
private IActorRef CreateActor(TimeSpan? auditIngestAskTimeout = null)
|
||||
{
|
||||
var mockRepo = Substitute.For<ISiteRepository>();
|
||||
mockRepo.GetAllSitesAsync(Arg.Any<CancellationToken>())
|
||||
@@ -35,7 +35,8 @@ public class CentralCommunicationActorAuditTests : TestKit
|
||||
var sp = services.BuildServiceProvider();
|
||||
|
||||
var mockFactory = Substitute.For<ISiteClientFactory>();
|
||||
return Sys.ActorOf(Props.Create(() => new CentralCommunicationActor(sp, mockFactory)));
|
||||
return Sys.ActorOf(Props.Create(() =>
|
||||
new CentralCommunicationActor(sp, mockFactory, auditIngestAskTimeout)));
|
||||
}
|
||||
|
||||
private static AuditEvent SampleAuditEvent() => new()
|
||||
@@ -94,6 +95,28 @@ public class CentralCommunicationActorAuditTests : TestKit
|
||||
Assert.Empty(reply.AcceptedEventIds);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IngestAuditEventsCommand_WhenProxyNeverReplies_PipesStatusFailureToSender()
|
||||
{
|
||||
// A short test-only Ask timeout (constructor seam) keeps the test fast —
|
||||
// production uses the 30 s default.
|
||||
var actor = CreateActor(auditIngestAskTimeout: TimeSpan.FromMilliseconds(200));
|
||||
var auditProbe = CreateTestProbe();
|
||||
actor.Tell(new RegisterAuditIngest(auditProbe.Ref));
|
||||
|
||||
var cmd = new IngestAuditEventsCommand(new[] { SampleAuditEvent() });
|
||||
actor.Tell(cmd);
|
||||
|
||||
// The proxy receives the command but deliberately never replies.
|
||||
auditProbe.ExpectMsg(cmd);
|
||||
|
||||
// The Ask times out; PipeTo forwards the faulted task as a Status.Failure
|
||||
// to the original sender. This is the real transient signal the site's
|
||||
// own Ask faults on — it is NOT swallowed into an empty ack.
|
||||
var failure = ExpectMsg<Status.Failure>();
|
||||
Assert.IsType<AskTimeoutException>(failure.Cause);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IngestCachedTelemetryCommand_WithRegisteredProxy_ForwardsAndRoutesReplyToSender()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user