feat(auditlog): NotifyDeliver rows carry the originating ExecutionId
This commit is contained in:
@@ -60,7 +60,8 @@ public class NotifyHelperTests : TestKit, IAsyncLifetime, IDisposable
|
||||
|
||||
private ScriptRuntimeContext.NotifyHelper CreateHelper(
|
||||
IActorRef siteCommunicationActor,
|
||||
string? sourceScript = null)
|
||||
string? sourceScript = null,
|
||||
Guid? executionId = null)
|
||||
{
|
||||
return new ScriptRuntimeContext.NotifyHelper(
|
||||
_saf,
|
||||
@@ -70,7 +71,7 @@ public class NotifyHelperTests : TestKit, IAsyncLifetime, IDisposable
|
||||
sourceScript,
|
||||
TimeSpan.FromSeconds(3),
|
||||
NullLogger.Instance,
|
||||
Guid.NewGuid());
|
||||
executionId ?? Guid.NewGuid());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -134,6 +135,27 @@ public class NotifyHelperTests : TestKit, IAsyncLifetime, IDisposable
|
||||
Assert.Equal("ScriptActor:MonitorSpeed", payload!.SourceScript);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Send_StampsExecutionId_OnTheNotificationSubmitPayload()
|
||||
{
|
||||
// Audit Log #23 (ExecutionId Task 5): Notify.Send must stamp the
|
||||
// script run's ExecutionId onto the NotificationSubmit so it rides
|
||||
// inside the serialized S&F payload to central, where the dispatcher
|
||||
// echoes it onto the NotifyDeliver rows. This is the SAME id stamped
|
||||
// onto the site-emitted NotifySend audit row.
|
||||
var executionId = Guid.NewGuid();
|
||||
var commProbe = CreateTestProbe();
|
||||
var notify = CreateHelper(commProbe.Ref, executionId: executionId);
|
||||
|
||||
var notificationId = await notify.To("Operators").Send("Pump alarm", "Pump 3 tripped");
|
||||
|
||||
var buffered = await _saf.GetMessageByIdAsync(notificationId);
|
||||
Assert.NotNull(buffered);
|
||||
var payload = JsonSerializer.Deserialize<NotificationSubmit>(buffered!.PayloadJson);
|
||||
Assert.NotNull(payload);
|
||||
Assert.Equal(executionId, payload!.OriginExecutionId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Send_WhenHelperHasNoSourceScript_LeavesSourceScriptNull()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user