test(runtime): serialize meter-asserting publish-actor suites (cross-collection counter pollution)

This commit is contained in:
Joseph Doherty
2026-08-15 18:16:59 -04:00
parent 0b537b5dec
commit 3122728593
2 changed files with 22 additions and 0 deletions
@@ -23,6 +23,16 @@ namespace ZB.MOM.WW.OtOpcUa.Runtime.Tests.OpcUa;
/// <c>otopcua.opcua.apply.failed</c> meter and log at Error — instead of the optimistic Info line. The
/// happy path must stay Info-only (zero increments).
/// </summary>
/// <remarks>
/// Shares the <c>opcua-publish-meters</c> collection with <c>OpcUaPublishActorRebuildTests</c> so the two
/// classes NEVER run in parallel. The zero-increment assertions below (<c>recorder.Total.ShouldBe(0)</c>)
/// read a process-wide <see cref="MeterListener"/> filtered only on the instrument NAME, and
/// <c>otopcua.opcua.apply.failed</c> carries no tag identifying the emitting actor instance (only
/// <c>kind=rebuild|nodes</c>) — so the assertion cannot be scoped to this test's own actor. The sibling
/// class's degraded-apply tests deliberately increment the same counter, which intermittently made these
/// zero assertions fail when the two classes ran concurrently in different xUnit collections.
/// </remarks>
[Collection("opcua-publish-meters")]
public sealed class OpcUaPublishActorApplyFailureTests : RuntimeActorTestBase
{
/// <summary>A rebuild whose sink throws increments otopcua.opcua.apply.failed (kind=rebuild). R2-07 — a
@@ -16,6 +16,18 @@ using ZB.MOM.WW.OtOpcUa.Runtime.Tests.Harness;
namespace ZB.MOM.WW.OtOpcUa.Runtime.Tests.OpcUa;
/// <summary>
/// Shares the <c>opcua-publish-meters</c> collection with <see cref="OpcUaPublishActorApplyFailureTests"/>
/// so the two classes NEVER run in parallel. <c>MeterRecorder</c> is a process-wide
/// <see cref="System.Diagnostics.Metrics.MeterListener"/> filtered only on the instrument NAME, and
/// <c>otopcua.opcua.apply.failed</c> carries no tag identifying which actor instance emitted it (only
/// <c>kind=rebuild|nodes</c>) — so it cannot be scoped to one test. The degraded-apply tests here
/// (<see cref="Degraded_non_rebuild_apply_does_not_advance_last_applied"/> and
/// <see cref="Rebuild_with_failures_still_advances_last_applied"/>) deliberately increment that counter,
/// which intermittently broke the sibling class's <c>Total.ShouldBe(0)</c> happy-path assertions when the
/// two classes ran concurrently in different collections. Serialising them is the fix.
/// </summary>
[Collection("opcua-publish-meters")]
public sealed class OpcUaPublishActorRebuildTests : RuntimeActorTestBase
{
/// <summary>R2-07 — RebuildAddressSpace with dbFactory loads the artifact, composes, and applies. Two