Files
ScadaBridge/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Cluster/ClusterAvailability.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.0 KiB
C#

namespace ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests.Cluster;
/// <summary>
/// One-shot probe for whether the dev cluster (and its MSSQL config store) is
/// reachable through the CLI. State-changing E2E tests gate their setup on this so
/// a downed cluster surfaces as a Skipped fact (via <c>Skip.IfNot</c>) rather than
/// an opaque failure. The result is cached for the process; <see cref="SkippedCount"/>
/// is bumped each time a test would skip and is logged at suite teardown.
/// </summary>
public static class ClusterAvailability
{
/// <summary>Reason surfaced on skipped facts when the cluster is unavailable.</summary>
public const string SkipReason =
"Cluster/MSSQL unavailable — start the docker cluster (bash docker/deploy.sh) to run E2E.";
private static bool? _cached;
/// <summary>
/// Number of times a test would have skipped because the cluster is
/// unavailable. Incremented on every <see cref="IsAvailableAsync"/> call that
/// returns <see langword="false"/>; logged at suite teardown.
/// </summary>
public static int SkippedCount;
/// <summary>
/// Returns whether the cluster is reachable, probing once (a <c>site list</c>
/// round-trip through the CLI) and caching the result for the process.
/// </summary>
/// <returns><see langword="true"/> when the cluster is reachable; otherwise <see langword="false"/>.</returns>
public static async Task<bool> IsAvailableAsync()
{
if (_cached is { } cached)
{
if (!cached)
{
System.Threading.Interlocked.Increment(ref SkippedCount);
}
return cached;
}
try
{
using var _ = await CliRunner.RunJsonAsync("site", "list");
_cached = true;
}
catch
{
_cached = false;
System.Threading.Interlocked.Increment(ref SkippedCount);
}
return _cached.Value;
}
}