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.
This commit is contained in:
+18
-1
@@ -2,7 +2,7 @@ namespace ZB.MOM.WW.ScadaBridge.ClusterInfrastructure.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Unit tests for <see cref="ClusterBootstrapGuard"/> — the pure decision core of the
|
||||
/// simultaneous-cold-start split-brain guard (Gitea #33). The runtime probe + JoinSeedNodes wiring
|
||||
/// simultaneous-cold-start split-brain guard. The runtime probe + JoinSeedNodes wiring
|
||||
/// lives in <c>ClusterBootstrapCoordinator</c> and is covered by the real-ActorSystem
|
||||
/// <c>ClusterBootstrapCoordinatorTests</c> in the integration suite.
|
||||
/// </summary>
|
||||
@@ -11,6 +11,7 @@ public class ClusterBootstrapGuardTests
|
||||
private const string A = "akka.tcp://scadabridge@scadabridge-site-a-a:8082";
|
||||
private const string B = "akka.tcp://scadabridge@scadabridge-site-a-b:8082";
|
||||
|
||||
/// <summary>Verifies that the node with the lower address is the founder and needs no probe.</summary>
|
||||
[Fact]
|
||||
public void Lower_address_node_is_the_founder_and_needs_no_probe()
|
||||
{
|
||||
@@ -22,6 +23,7 @@ public class ClusterBootstrapGuardTests
|
||||
Assert.Equal(new[] { A, B }, role.SelfFirstOrder);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the node with the higher address is not the founder and probes its partner.</summary>
|
||||
[Fact]
|
||||
public void Higher_address_node_is_not_the_founder_and_targets_the_partner_for_probing()
|
||||
{
|
||||
@@ -34,6 +36,7 @@ public class ClusterBootstrapGuardTests
|
||||
Assert.Equal(8082, role.PartnerPort);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the founder tie-break gives the same result regardless of seed order.</summary>
|
||||
[Fact]
|
||||
public void Tie_break_is_symmetric_regardless_of_seed_order()
|
||||
{
|
||||
@@ -47,6 +50,7 @@ public class ClusterBootstrapGuardTests
|
||||
Assert.True(onLower.IsFounder ^ onHigher.IsFounder);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the tie-break ignores case, so a casing mismatch cannot make both nodes founders.</summary>
|
||||
[Fact]
|
||||
public void Tie_break_is_case_insensitive_so_a_casing_mismatch_cannot_make_both_founders()
|
||||
{
|
||||
@@ -62,6 +66,7 @@ public class ClusterBootstrapGuardTests
|
||||
Assert.True(onLower.IsFounder); // "site-a-a" < "site-a-b" ordinal-ignore-case
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the higher node joins the founder when the partner is reachable.</summary>
|
||||
[Fact]
|
||||
public void Higher_node_joins_the_founder_when_partner_is_reachable()
|
||||
{
|
||||
@@ -71,6 +76,7 @@ public class ClusterBootstrapGuardTests
|
||||
Assert.Equal(new[] { A, B }, ClusterBootstrapGuard.HigherNodeOrder(role, partnerReachable: true)); // partner (node-a) first
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the higher node forms a cluster alone when the partner is unreachable.</summary>
|
||||
[Fact]
|
||||
public void Higher_node_forms_alone_when_partner_is_unreachable()
|
||||
{
|
||||
@@ -80,6 +86,7 @@ public class ClusterBootstrapGuardTests
|
||||
Assert.Equal(new[] { B, A }, ClusterBootstrapGuard.HigherNodeOrder(role, partnerReachable: false)); // self (node-b) first
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the guard does not apply to a single seed node.</summary>
|
||||
[Fact]
|
||||
public void Guard_does_not_apply_to_a_single_seed_node()
|
||||
{
|
||||
@@ -89,6 +96,7 @@ public class ClusterBootstrapGuardTests
|
||||
Assert.False(role.Applies);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the guard does not apply when the local node is absent from the two seeds.</summary>
|
||||
[Fact]
|
||||
public void Guard_does_not_apply_when_self_is_absent_from_the_two_seeds()
|
||||
{
|
||||
@@ -97,6 +105,7 @@ public class ClusterBootstrapGuardTests
|
||||
Assert.False(role.Applies);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the guard does not apply to three or more seeds.</summary>
|
||||
[Fact]
|
||||
public void Guard_does_not_apply_to_three_or_more_seeds()
|
||||
{
|
||||
@@ -106,6 +115,7 @@ public class ClusterBootstrapGuardTests
|
||||
Assert.False(role.Applies);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the guard does not apply when a seed address is malformed.</summary>
|
||||
[Fact]
|
||||
public void Guard_does_not_apply_when_a_seed_is_malformed()
|
||||
{
|
||||
@@ -114,6 +124,10 @@ public class ClusterBootstrapGuardTests
|
||||
Assert.False(role.Applies);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that parsing a seed address extracts the host and port.</summary>
|
||||
/// <param name="seed">The seed address to parse.</param>
|
||||
/// <param name="expectedHost">The expected host.</param>
|
||||
/// <param name="expectedPort">The expected port.</param>
|
||||
[Theory]
|
||||
[InlineData("akka.tcp://scadabridge@scadabridge-site-a-a:8082", "scadabridge-site-a-a", 8082)]
|
||||
[InlineData("akka.tcp://scadabridge@10.0.0.5:8082/", "10.0.0.5", 8082)]
|
||||
@@ -125,6 +139,8 @@ public class ClusterBootstrapGuardTests
|
||||
Assert.Equal(expectedPort, port);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that parsing rejects malformed seed addresses.</summary>
|
||||
/// <param name="seed">The malformed seed address.</param>
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData("garbage")]
|
||||
@@ -134,6 +150,7 @@ public class ClusterBootstrapGuardTests
|
||||
Assert.False(ClusterBootstrapGuard.TryParse(seed, out _, out _));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the port decides the tie-break when the hosts are equal.</summary>
|
||||
[Fact]
|
||||
public void Port_participates_in_the_tie_break_when_hosts_are_equal()
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace ZB.MOM.WW.ScadaBridge.ClusterInfrastructure.Tests;
|
||||
/// </summary>
|
||||
public class ClusterOptionsTests
|
||||
{
|
||||
/// <summary>Verifies that a new options instance carries the expected default values.</summary>
|
||||
[Fact]
|
||||
public void DefaultValues_AreCorrect()
|
||||
{
|
||||
@@ -21,6 +22,7 @@ public class ClusterOptionsTests
|
||||
Assert.True(options.DownIfAlone);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the down-if-alone setting can be changed.</summary>
|
||||
[Fact]
|
||||
public void DownIfAlone_CanBeSet()
|
||||
{
|
||||
@@ -29,6 +31,7 @@ public class ClusterOptionsTests
|
||||
Assert.False(options.DownIfAlone);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the seed node list defaults to an empty list.</summary>
|
||||
[Fact]
|
||||
public void SeedNodes_DefaultsToEmptyList()
|
||||
{
|
||||
@@ -38,17 +41,18 @@ public class ClusterOptionsTests
|
||||
Assert.Empty(options.SeedNodes);
|
||||
}
|
||||
|
||||
// ClusterInfra-011: SectionName constant deleted — the previous test
|
||||
// The SectionName constant was deleted — the previous test
|
||||
// `SectionName_IsTheExpectedAppSettingsSection` is removed alongside it.
|
||||
// The Host's SiteServiceRegistration / StartupValidator continue to
|
||||
// reference the `"ScadaBridge:Cluster"` literal directly; reinstating the
|
||||
// constant should happen when those Host binding sites can be updated in
|
||||
// the same change.
|
||||
|
||||
/// <summary>Verifies that the options properties accept custom values.</summary>
|
||||
[Fact]
|
||||
public void Properties_CanBeSetToCustomValues()
|
||||
{
|
||||
// ClusterInfra-013: this test exercises the POCO property setters only —
|
||||
// This test exercises the POCO property setters only —
|
||||
// `SplitBrainResolverStrategy = "keep-majority"` and `MinNrOfMembers = 2`
|
||||
// are values the design doc explicitly forbids in production
|
||||
// (`keep-majority` causes total shutdown on a two-node partition;
|
||||
|
||||
+22
-3
@@ -3,7 +3,7 @@ using Microsoft.Extensions.Options;
|
||||
namespace ZB.MOM.WW.ScadaBridge.ClusterInfrastructure.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// CI-004: Tests that <see cref="ClusterOptionsValidator"/> rejects the
|
||||
/// Tests that <see cref="ClusterOptionsValidator"/> rejects the
|
||||
/// catastrophic misconfigurations the design doc warns against — a
|
||||
/// <c>MinNrOfMembers</c> other than 1, an unsupported split-brain strategy,
|
||||
/// empty seed nodes, and timings where the heartbeat is not below the
|
||||
@@ -22,6 +22,7 @@ public class ClusterOptionsValidatorTests
|
||||
DownIfAlone = true
|
||||
};
|
||||
|
||||
/// <summary>Verifies that the default options are valid.</summary>
|
||||
[Fact]
|
||||
public void DefaultOptions_AreValid()
|
||||
{
|
||||
@@ -30,6 +31,7 @@ public class ClusterOptionsValidatorTests
|
||||
Assert.True(result.Succeeded, result.FailureMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a minimum member count other than one fails validation.</summary>
|
||||
[Fact]
|
||||
public void MinNrOfMembers_NotOne_FailsValidation()
|
||||
{
|
||||
@@ -42,6 +44,8 @@ public class ClusterOptionsValidatorTests
|
||||
Assert.Contains("MinNrOfMembers", result.FailureMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an unsupported split-brain strategy fails validation.</summary>
|
||||
/// <param name="strategy">The unsupported strategy name.</param>
|
||||
[Theory]
|
||||
[InlineData("keep-majority")]
|
||||
[InlineData("static-quorum")]
|
||||
@@ -57,6 +61,7 @@ public class ClusterOptionsValidatorTests
|
||||
Assert.Contains("SplitBrainResolverStrategy", result.FailureMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an empty seed node list fails validation.</summary>
|
||||
[Fact]
|
||||
public void EmptySeedNodes_FailsValidation()
|
||||
{
|
||||
@@ -69,6 +74,7 @@ public class ClusterOptionsValidatorTests
|
||||
Assert.Contains("SeedNodes", result.FailureMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a single seed node without acknowledgement fails validation.</summary>
|
||||
[Fact]
|
||||
public void SingleSeed_WithoutAcknowledgement_Fails()
|
||||
{
|
||||
@@ -81,6 +87,7 @@ public class ClusterOptionsValidatorTests
|
||||
Assert.Contains("AllowSingleNodeCluster", result.FailureMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a single seed node passes when single-node clusters are explicitly allowed.</summary>
|
||||
[Fact]
|
||||
public void SingleSeed_WithAllowSingleNodeCluster_Passes()
|
||||
{
|
||||
@@ -96,6 +103,7 @@ public class ClusterOptionsValidatorTests
|
||||
Assert.True(result.Succeeded, result.FailureMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an empty seed list fails even when single-node clusters are allowed.</summary>
|
||||
[Fact]
|
||||
public void EmptySeeds_FailsEvenWithFlag()
|
||||
{
|
||||
@@ -110,10 +118,11 @@ public class ClusterOptionsValidatorTests
|
||||
Assert.Contains("SeedNodes", result.FailureMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a single seed node fails validation.</summary>
|
||||
[Fact]
|
||||
public void SingleSeedNode_FailsValidation()
|
||||
{
|
||||
// CI-012: design doc says "both nodes are seed nodes" — a single-seed
|
||||
// The design doc says "both nodes are seed nodes" — a single-seed
|
||||
// configuration defeats the no-startup-ordering-dependency guarantee and
|
||||
// must be rejected by the contract owner's validator, not just by the
|
||||
// Host's startup validator.
|
||||
@@ -127,6 +136,7 @@ public class ClusterOptionsValidatorTests
|
||||
Assert.Contains("2", result.FailureMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a heartbeat interval that is not below the failure threshold fails validation.</summary>
|
||||
[Fact]
|
||||
public void HeartbeatNotBelowFailureThreshold_FailsValidation()
|
||||
{
|
||||
@@ -140,6 +150,7 @@ public class ClusterOptionsValidatorTests
|
||||
Assert.Contains("HeartbeatInterval", result.FailureMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that a non-positive stable-after duration fails validation.</summary>
|
||||
[Fact]
|
||||
public void NonPositiveStableAfter_FailsValidation()
|
||||
{
|
||||
@@ -152,6 +163,7 @@ public class ClusterOptionsValidatorTests
|
||||
Assert.Contains("StableAfter", result.FailureMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that disabling down-if-alone under the keep-oldest strategy fails validation.</summary>
|
||||
[Fact]
|
||||
public void DownIfAloneFalse_UnderKeepOldest_FailsValidation()
|
||||
{
|
||||
@@ -165,6 +177,7 @@ public class ClusterOptionsValidatorTests
|
||||
Assert.Contains("DownIfAlone", result.FailureMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the auto-down strategy passes validation.</summary>
|
||||
[Fact]
|
||||
public void AutoDownStrategy_Passes()
|
||||
{
|
||||
@@ -179,6 +192,7 @@ public class ClusterOptionsValidatorTests
|
||||
Assert.True(result.Succeeded, result.FailureMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that disabling down-if-alone under the auto-down strategy passes validation.</summary>
|
||||
[Fact]
|
||||
public void DownIfAloneFalse_UnderAutoDown_Passes()
|
||||
{
|
||||
@@ -193,6 +207,7 @@ public class ClusterOptionsValidatorTests
|
||||
Assert.True(result.Succeeded, result.FailureMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that validation accumulates every failure rather than stopping at the first.</summary>
|
||||
[Fact]
|
||||
public void Validate_AccumulatesAllFailures()
|
||||
{
|
||||
@@ -216,8 +231,9 @@ public class ClusterOptionsValidatorTests
|
||||
Assert.Contains("HeartbeatInterval", result.FailureMessage);
|
||||
}
|
||||
|
||||
// ---- BootstrapGuard timing validation (Gitea #33) ----
|
||||
// ---- BootstrapGuard timing validation ----
|
||||
|
||||
/// <summary>Verifies that a disabled bootstrap guard with zero timings passes validation.</summary>
|
||||
[Fact]
|
||||
public void BootstrapGuard_disabled_with_zero_timings_passes_validation()
|
||||
{
|
||||
@@ -237,6 +253,7 @@ public class ClusterOptionsValidatorTests
|
||||
Assert.True(result.Succeeded, result.FailureMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an enabled bootstrap guard with default timings passes validation.</summary>
|
||||
[Fact]
|
||||
public void BootstrapGuard_enabled_with_default_timings_passes_validation()
|
||||
{
|
||||
@@ -248,6 +265,7 @@ public class ClusterOptionsValidatorTests
|
||||
Assert.True(result.Succeeded, result.FailureMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an enabled bootstrap guard with non-positive probe seconds fails validation.</summary>
|
||||
[Fact]
|
||||
public void BootstrapGuard_enabled_with_nonpositive_probe_seconds_fails_validation()
|
||||
{
|
||||
@@ -262,6 +280,7 @@ public class ClusterOptionsValidatorTests
|
||||
Assert.Contains("PartnerProbeSeconds", result.FailureMessage);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that an enabled bootstrap guard with a non-positive interval or timeout fails validation.</summary>
|
||||
[Fact]
|
||||
public void BootstrapGuard_enabled_with_nonpositive_interval_or_timeout_fails_validation()
|
||||
{
|
||||
|
||||
+5
-3
@@ -4,14 +4,15 @@ using Microsoft.Extensions.Options;
|
||||
namespace ZB.MOM.WW.ScadaBridge.ClusterInfrastructure.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// CI-002: Tests that <see cref="ServiceCollectionExtensions.AddClusterInfrastructure"/>
|
||||
/// Tests that <see cref="ServiceCollectionExtensions.AddClusterInfrastructure"/>
|
||||
/// does real work rather than silently returning success — it must register
|
||||
/// the <see cref="ClusterOptionsValidator"/> so misconfiguration fails fast.
|
||||
/// (The companion actor-registration test was removed alongside the deleted
|
||||
/// `AddClusterInfrastructureActors` extension method — see ClusterInfra-014.)
|
||||
/// `AddClusterInfrastructureActors` extension method.)
|
||||
/// </summary>
|
||||
public class ServiceCollectionExtensionsTests
|
||||
{
|
||||
/// <summary>Verifies the case: add Cluster Infrastructure, registers Options Validator.</summary>
|
||||
[Fact]
|
||||
public void AddClusterInfrastructure_RegistersOptionsValidator()
|
||||
{
|
||||
@@ -29,6 +30,7 @@ public class ServiceCollectionExtensionsTests
|
||||
Assert.IsType<ClusterOptionsValidator>(validator);
|
||||
}
|
||||
|
||||
/// <summary>Verifies the case: add Cluster Infrastructure, validator Rejects Bad Options At Resolution.</summary>
|
||||
[Fact]
|
||||
public void AddClusterInfrastructure_ValidatorRejectsBadOptionsAtResolution()
|
||||
{
|
||||
@@ -48,7 +50,7 @@ public class ServiceCollectionExtensionsTests
|
||||
Assert.Contains("MinNrOfMembers", ex.Message);
|
||||
}
|
||||
|
||||
// ClusterInfra-014: `AddClusterInfrastructureActors_ThrowsRatherThanSilentlySucceeding`
|
||||
// `AddClusterInfrastructureActors_ThrowsRatherThanSilentlySucceeding`
|
||||
// was removed alongside the now-deleted `AddClusterInfrastructureActors`
|
||||
// extension method. The Akka.NET actor wiring legitimately lives in
|
||||
// `ZB.MOM.WW.ScadaBridge.Host` (AkkaHostedService) per the
|
||||
|
||||
Reference in New Issue
Block a user