feat(audit,install): #1030 audit overflow drops exported as otopcua.audit.dropped; scripted SCM-restart-after-cluster-exit gate
- AuditWriterActor: every buffer-full drop is added to OtOpcUaTelemetry.AuditDropped
(otopcua.audit.dropped{reason=buffer_full, actor}) — the count used to be readable only
through the actor's own property.
- scripts/install/tests/Test-ScmRestartAfterClusterExit.Windows.ps1: the windev manual gate
of 2026-12-03 as a script (qfailure restart action; failover/command trigger => non-zero exit,
7031, Running under a new pid; Stop-Service stays stopped; optional kill control). Parse-checked
with pwsh on macOS; must be run elevated on a Windows box hosting OtOpcUaHost.
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Diagnostics.Metrics;
|
||||
using Akka.Actor;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
@@ -91,6 +93,45 @@ public sealed class AuditWriterActorRetryTests : ControlPlaneActorTestBase
|
||||
persisted.ShouldContain(ids[extra]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// #1030: the overflow drop count is exported on the shared OtOpcUa meter as
|
||||
/// <c>otopcua.audit.dropped</c> (it used to be visible only through the actor's own property, which nothing
|
||||
/// outside a test can read). Measurements are filtered by the writer's <c>actor</c> tag so a parallel test's
|
||||
/// writer cannot leak into the sum.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Overflow_drops_are_exported_on_the_audit_dropped_meter_counter()
|
||||
{
|
||||
var failing = new FailingSaves { Down = true };
|
||||
var factory = new FailingDbFactory(Guid.NewGuid().ToString("N"), new InMemoryDatabaseRoot(), failing);
|
||||
var actor = ActorOfAsTestActorRef<AuditWriterActor>(AuditWriterActor.Props(factory));
|
||||
var actorTag = actor.Path.ToStringWithoutAddress();
|
||||
|
||||
var measured = new ConcurrentQueue<long>();
|
||||
using var listener = new MeterListener();
|
||||
listener.InstrumentPublished = (instrument, l) =>
|
||||
{
|
||||
if (instrument.Name == AuditWriterActor.DroppedCounterName) l.EnableMeasurementEvents(instrument);
|
||||
};
|
||||
listener.SetMeasurementEventCallback<long>((_, value, tags, _) =>
|
||||
{
|
||||
string? owner = null, reason = null;
|
||||
foreach (var tag in tags)
|
||||
{
|
||||
if (tag.Key == "actor") owner = tag.Value as string;
|
||||
if (tag.Key == "reason") reason = tag.Value as string;
|
||||
}
|
||||
if (owner == actorTag && reason == "buffer_full") measured.Enqueue(value);
|
||||
});
|
||||
listener.Start();
|
||||
|
||||
const int extra = 7;
|
||||
for (var i = 0; i < AuditWriterActor.MaxBufferedEvents + extra; i++) actor.Tell(NewEvent(Guid.NewGuid()));
|
||||
|
||||
actor.UnderlyingActor.OverflowDroppedCount.ShouldBe(extra, "positive control: the drops really happened");
|
||||
measured.Sum().ShouldBe(extra, "every dropped event must be counted on the exported meter");
|
||||
}
|
||||
|
||||
private static AuditEvent NewEvent(Guid eventId) => new()
|
||||
{
|
||||
EventId = eventId, Category = "Config", Action = "Edit", Actor = "joe",
|
||||
|
||||
Reference in New Issue
Block a user