feat(sitecallaudit): central→site Retry/Discard relay for parked operations
This commit is contained in:
@@ -382,6 +382,64 @@ public class CommunicationServiceTests : TestKit
|
||||
Assert.Equal("plant-a", result.Sites[0].SourceSite);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RetrySiteCallAsync_BeforeSiteCallAuditSet_Throws()
|
||||
{
|
||||
var service = new CommunicationService(
|
||||
Options.Create(new CommunicationOptions()),
|
||||
NullLogger<CommunicationService>.Instance);
|
||||
|
||||
await Assert.ThrowsAsync<InvalidOperationException>(() =>
|
||||
service.RetrySiteCallAsync(new RetrySiteCallRequest("corr-1", Guid.NewGuid(), "plant-a")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RetrySiteCallAsync_AsksSiteCallAuditProxyDirectly()
|
||||
{
|
||||
// The relay is initiated by Asking the central-local Site Call Audit
|
||||
// proxy directly (no SiteEnvelope wrapping at this layer — the actor
|
||||
// does the site routing itself).
|
||||
var service = new CommunicationService(
|
||||
Options.Create(new CommunicationOptions()),
|
||||
NullLogger<CommunicationService>.Instance);
|
||||
var probe = CreateTestProbe();
|
||||
service.SetSiteCallAudit(probe.Ref);
|
||||
|
||||
var request = new RetrySiteCallRequest("corr-r", Guid.NewGuid(), "plant-a");
|
||||
var task = service.RetrySiteCallAsync(request);
|
||||
|
||||
var received = probe.ExpectMsg<RetrySiteCallRequest>();
|
||||
Assert.Same(request, received);
|
||||
var reply = new RetrySiteCallResponse(
|
||||
"corr-r", SiteCallRelayOutcome.Applied, true, true, null);
|
||||
probe.Reply(reply);
|
||||
|
||||
Assert.Same(reply, await task);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DiscardSiteCallAsync_AsksSiteCallAuditProxyDirectly()
|
||||
{
|
||||
var service = new CommunicationService(
|
||||
Options.Create(new CommunicationOptions()),
|
||||
NullLogger<CommunicationService>.Instance);
|
||||
var probe = CreateTestProbe();
|
||||
service.SetSiteCallAudit(probe.Ref);
|
||||
|
||||
var request = new DiscardSiteCallRequest("corr-d", Guid.NewGuid(), "plant-a");
|
||||
var task = service.DiscardSiteCallAsync(request);
|
||||
|
||||
var received = probe.ExpectMsg<DiscardSiteCallRequest>();
|
||||
Assert.Same(request, received);
|
||||
var reply = new DiscardSiteCallResponse(
|
||||
"corr-d", SiteCallRelayOutcome.SiteUnreachable, false, false, "unreachable");
|
||||
probe.Reply(reply);
|
||||
|
||||
var result = await task;
|
||||
Assert.Same(reply, result);
|
||||
Assert.False(result.SiteReachable);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stand-in for CentralCommunicationActor: verifies the message is wrapped
|
||||
/// in a SiteEnvelope targeting the requested site and replies with a typed
|
||||
|
||||
Reference in New Issue
Block a user