feat(auditlog): NotifyDeliver rows carry the originating ParentExecutionId
This commit is contained in:
@@ -40,7 +40,9 @@ public class NotificationOutboxActorIngestTests : TestKit
|
||||
}
|
||||
|
||||
private static NotificationSubmit MakeSubmit(
|
||||
string? notificationId = null, Guid? originExecutionId = null)
|
||||
string? notificationId = null,
|
||||
Guid? originExecutionId = null,
|
||||
Guid? originParentExecutionId = null)
|
||||
{
|
||||
return new NotificationSubmit(
|
||||
NotificationId: notificationId ?? Guid.NewGuid().ToString(),
|
||||
@@ -51,7 +53,8 @@ public class NotificationOutboxActorIngestTests : TestKit
|
||||
SourceInstanceId: "instance-42",
|
||||
SourceScript: "AlarmScript",
|
||||
SiteEnqueuedAt: new DateTimeOffset(2026, 5, 19, 8, 30, 0, TimeSpan.Zero),
|
||||
OriginExecutionId: originExecutionId);
|
||||
OriginExecutionId: originExecutionId,
|
||||
OriginParentExecutionId: originParentExecutionId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -121,6 +124,42 @@ public class NotificationOutboxActorIngestTests : TestKit
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NotificationSubmit_CopiesOriginParentExecutionId_OntoPersistedNotification()
|
||||
{
|
||||
// Audit Log ParentExecutionId: the routed run's parent ExecutionId rides
|
||||
// on the NotificationSubmit and must be persisted on the Notification row
|
||||
// so the dispatcher can later echo it onto NotifyDeliver audit rows.
|
||||
_repository.InsertIfNotExistsAsync(Arg.Any<Notification>(), Arg.Any<CancellationToken>())
|
||||
.Returns(true);
|
||||
var parentExecutionId = Guid.NewGuid();
|
||||
var submit = MakeSubmit(originParentExecutionId: parentExecutionId);
|
||||
var actor = CreateActor();
|
||||
|
||||
actor.Tell(submit, TestActor);
|
||||
|
||||
ExpectMsg<NotificationSubmitAck>();
|
||||
_repository.Received(1).InsertIfNotExistsAsync(
|
||||
Arg.Is<Notification>(n => n.OriginParentExecutionId == parentExecutionId),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NotificationSubmit_NullOriginParentExecutionId_PersistsNull()
|
||||
{
|
||||
_repository.InsertIfNotExistsAsync(Arg.Any<Notification>(), Arg.Any<CancellationToken>())
|
||||
.Returns(true);
|
||||
var submit = MakeSubmit(originParentExecutionId: null);
|
||||
var actor = CreateActor();
|
||||
|
||||
actor.Tell(submit, TestActor);
|
||||
|
||||
ExpectMsg<NotificationSubmitAck>();
|
||||
_repository.Received(1).InsertIfNotExistsAsync(
|
||||
Arg.Is<Notification>(n => n.OriginParentExecutionId == null),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DuplicateSubmit_RepositoryReturnsFalse_StillAcksAccepted()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user