635461c0fd
Perf re-baseline (HotPathLatencyTests): empirical p95 on Apple M-series Release build: 4KB DetailsJson slow path ≈14 µs, small-DetailsJson no-redactors ≈2 µs, true no-op fast path ≈0 µs. Thresholds updated: 200 µs / 30 µs / 5 µs (≈15× headroom for contested CI runners). Old thresholds (50 µs / 10 µs) were set for the pre-C3 typed-field path; canonical JSON parse+rewrite is empirically faster. Adds a third test (Filter_Apply_NoDetailsJson_FastPath) that asserts same-instance return on the DetailsJson-null + within-cap fast path. Env-var overrides retained. CollapseAuditLogToCanonicalMigrationTests (new): three MSSQL-gated [SkippableFact] tests verifying Action/Category/Outcome projection, NULL Actor, DetailsJson codec round-trip, and all six persisted computed columns (Kind/Status/SourceSiteId/ ExecutionId/ParentExecutionId) for ApiOutbound, InboundAuthFailure, and Failed- status rows. AddAuditLogTableMigrationTests: rename CreatesFiveNamedIndexes → CreatesNineNamedIndexes; expand coverage from 5 original indexes to all 9 named non-clustered indexes present after CollapseAuditLogToCanonical (adds IX_AuditLog_Execution, IX_AuditLog_ParentExecution, IX_AuditLog_Node_Occurred, UX_AuditLog_EventId). Dead-cref cleanup: zero references to the deleted IAuditPayloadFilter / DefaultAuditPayloadFilter / SafeDefaultAuditPayloadFilter types remain in any .cs file (source or test). 26 occurrences across 13 files replaced with correct references to IAuditRedactor / ScadaBridgeAuditRedactor / SafeDefaultAuditRedactor or reworded as plain prose. Residual sweep: no unused transitional code found beyond the acknowledged "C3 transitional shim" comments on IngestedAtUtc stamping (active code, not dead).
58 lines
2.2 KiB
C#
58 lines
2.2 KiB
C#
namespace ZB.MOM.WW.ScadaBridge.HealthMonitoring.Tests;
|
|
|
|
/// <summary>
|
|
/// Bundle C (M5-T7) regression coverage. The canonical audit redactor
|
|
/// (<see cref="ZB.MOM.WW.ScadaBridge.AuditLog.Redaction.ScadaBridgeAuditRedactor"/>) increments
|
|
/// <see cref="ZB.MOM.WW.ScadaBridge.AuditLog.Payload.IAuditRedactionFailureCounter"/> every time
|
|
/// a header/body/SQL-param redactor stage throws and the redactor has to
|
|
/// over-redact the field with the <c><redacted: redactor error></c> marker.
|
|
/// Bundle C bridges that counter into the Site Health Monitoring report payload
|
|
/// as <c>AuditRedactionFailure</c> so a misconfigured / catastrophic regex
|
|
/// surfaces on /monitoring/health rather than disappearing into a NoOp sink.
|
|
/// Mirrors the Bundle G <c>SiteAuditWriteFailures</c> metric shape — same
|
|
/// per-interval increment-and-reset semantics, same defaults-to-zero
|
|
/// contract.
|
|
/// </summary>
|
|
public class AuditRedactionFailureMetricTests
|
|
{
|
|
private readonly SiteHealthCollector _collector = new();
|
|
|
|
[Fact]
|
|
public void Increment_Three_Times_Counter_Reports_3()
|
|
{
|
|
_collector.IncrementAuditRedactionFailure();
|
|
_collector.IncrementAuditRedactionFailure();
|
|
_collector.IncrementAuditRedactionFailure();
|
|
|
|
var report = _collector.CollectReport("site-1");
|
|
|
|
Assert.Equal(3, report.AuditRedactionFailure);
|
|
}
|
|
|
|
[Fact]
|
|
public void Report_Payload_Includes_AuditRedactionFailure_AsZeroByDefault()
|
|
{
|
|
var report = _collector.CollectReport("site-1");
|
|
|
|
Assert.Equal(0, report.AuditRedactionFailure);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Mirrors the existing per-interval reset semantics for ScriptErrorCount /
|
|
/// AlarmEvaluationErrorCount / DeadLetterCount / SiteAuditWriteFailures —
|
|
/// AuditRedactionFailure is an interval count, not a running total.
|
|
/// </summary>
|
|
[Fact]
|
|
public void CollectReport_Resets_AuditRedactionFailure()
|
|
{
|
|
_collector.IncrementAuditRedactionFailure();
|
|
_collector.IncrementAuditRedactionFailure();
|
|
|
|
var first = _collector.CollectReport("site-1");
|
|
Assert.Equal(2, first.AuditRedactionFailure);
|
|
|
|
var second = _collector.CollectReport("site-1");
|
|
Assert.Equal(0, second.AuditRedactionFailure);
|
|
}
|
|
}
|