Files
ScadaBridge/tests/ZB.MOM.WW.ScadaBridge.IntegrationTests/Cluster/SiteFailoverRelayTests.cs
T
Joseph Doherty 513fa1aa16 docs(tests): fix CommentChecker findings across tests/ — 13,392 → 0 (repo-wide scan clean)
Comment/XML-doc changes only:
- add summaries to ~10k test methods, fixtures, fakes and helpers
  (+ <param> on theories, <returns> on async Task methods,
  <inheritdoc/> on interface implementations the checker can resolve)
- strip ~2.6k project-tracking references (WP*, P*-*, row-NN, Task N,
  #NN, Component-0NN) from comments, keeping the explanatory text;
  reword false positives in comments only
- real docs on fakes implementing BCL/library interfaces
  (IDisposable, ILogger, IOptionsMonitor, IAsyncLifetime)
- reword the last 5 src/ false positives (CWE-1236, failures-1,
  year-0001, M365)

Only non-comment edits: four one-line nested classes split across lines
so members can carry docs. Build 0 errors / 0 warnings.
2026-10-07 15:05:49 -04:00

56 lines
2.8 KiB
C#

using Akka.Actor;
using Akka.Cluster;
using ZB.MOM.WW.ScadaBridge.Communication.ClusterState;
namespace ZB.MOM.WW.ScadaBridge.IntegrationTests.Cluster;
/// <summary>
/// Real-cluster proof for the central→site failover relay. The unit tests in
/// <c>SiteCommunicationActorTests</c> pin the routing and guard logic with the failover action
/// stubbed out; this pins the part they cannot — that the shared
/// <see cref="ClusterFailoverCoordinator"/> actually moves a SITE pair when scoped to the
/// site-specific role.
///
/// <para>The site-specific role scope is the load-bearing detail: site singletons (the
/// Deployment Manager) are placed on <c>site-{SiteId}</c>, not on the base <c>Site</c> role, so
/// failing over the wrong scope would move the wrong node.</para>
/// </summary>
public sealed class SiteFailoverRelayTests
{
/// <summary>Verifies that failing over a site pair moves the oldest node and the survivor takes over.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task Failing_over_a_site_pair_moves_the_oldest_and_the_survivor_takes_over()
{
// A site pair, both nodes carrying the site-specific role.
await using var f = await TwoNodeClusterFixture.StartAsync(role: "site-SiteA");
var oldest = Akka.Cluster.Cluster.Get(f.NodeA);
Assert.True(ActiveNodeEvaluator.SelfIsOldestUp(oldest, "site-SiteA"),
"precondition: NodeA must be the active (oldest Up) site node");
// Issued from the other node, as the relay does when contact rotation lands there.
var target = ClusterFailoverCoordinator.FailOverOldest(f.NodeB, "site-SiteA");
Assert.Equal(oldest.SelfAddress, target);
await f.NodeA.WhenTerminated.WaitAsync(TimeSpan.FromSeconds(30));
await TwoNodeClusterFixture.WaitForMemberRemoved(f.NodeB, oldest.SelfAddress, TimeSpan.FromSeconds(30));
Assert.True(ActiveNodeEvaluator.SelfIsOldestUp(Akka.Cluster.Cluster.Get(f.NodeB), "site-SiteA"));
}
/// <summary>Verifies that a site role scope matching no member is refused.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task A_site_role_scope_that_matches_no_member_is_refused()
{
// Guards the role-scoping mistake directly: asking for a site that isn't this pair
// must find no members and refuse, rather than falling back to some other node.
await using var f = await TwoNodeClusterFixture.StartAsync(role: "site-SiteA");
var target = ClusterFailoverCoordinator.FailOverOldest(f.NodeB, "site-SiteB");
Assert.Null(target);
// Positive control: the pair is untouched and still fully formed.
await TwoNodeClusterFixture.WaitForMembersUp(f.NodeB, 2, TimeSpan.FromSeconds(10));
}
}