64e3fbe035
v2-ci / build (push) Failing after 1m43s
v2-ci / unit-tests (tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Security.Tests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests) (push) Has been skipped
Adds <summary>, <param>, <typeparam>, and <inheritdoc/> tags to public members surfaced by commentchecker — resolves 5,847 of 5,869 issues (99.6%) across three /fixdocs passes.
46 lines
2.0 KiB
C#
46 lines
2.0 KiB
C#
using Akka.Actor;
|
|
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.Commons.Messages.Redundancy;
|
|
using ZB.MOM.WW.OtOpcUa.ControlPlane.Redundancy;
|
|
using ZB.MOM.WW.OtOpcUa.ControlPlane.Tests.Harness;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.ControlPlane.Tests;
|
|
|
|
/// <summary>
|
|
/// Verifies <see cref="RedundancyStateActor"/> publishes a <see cref="RedundancyStateChanged"/>
|
|
/// snapshot in response to cluster events, and that the 250ms debounce coalesces bursts.
|
|
/// The actor accepts an <c>Action<object></c> broadcast override so tests can use a
|
|
/// TestProbe sink instead of bootstrapping DistributedPubSub (which is flaky single-node).
|
|
/// </summary>
|
|
public sealed class RedundancyStateActorTests : ControlPlaneActorTestBase
|
|
{
|
|
/// <summary>Verifies that a self-join event triggers RedundancyStateChanged through the broadcast override.</summary>
|
|
[Fact]
|
|
public void Self_join_triggers_RedundancyStateChanged_via_broadcast_override()
|
|
{
|
|
var probe = CreateTestProbe("redundancy-listener");
|
|
Sys.ActorOf(RedundancyStateActor.Props(broadcast: msg => probe.Ref.Tell(msg)),
|
|
"redundancy-actor");
|
|
|
|
var msg = probe.ExpectMsg<RedundancyStateChanged>(TimeSpan.FromSeconds(3));
|
|
msg.Nodes.ShouldNotBeNull();
|
|
msg.CorrelationId.Value.ShouldNotBe(Guid.Empty);
|
|
}
|
|
|
|
/// <summary>Verifies that multiple back-to-back events debounce to a single RedundancyStateChanged publication.</summary>
|
|
[Fact]
|
|
public void Multiple_back_to_back_events_debounce_to_single_publish()
|
|
{
|
|
var probe = CreateTestProbe("dedup-listener");
|
|
Sys.ActorOf(RedundancyStateActor.Props(broadcast: msg => probe.Ref.Tell(msg)),
|
|
"redundancy-debounce");
|
|
|
|
// First publish should arrive within the debounce window.
|
|
probe.ExpectMsg<RedundancyStateChanged>(TimeSpan.FromSeconds(3));
|
|
|
|
// After debounce settles, no more events are fired by a quiescent cluster.
|
|
probe.ExpectNoMsg(TimeSpan.FromMilliseconds(500));
|
|
}
|
|
}
|