test(e2e): harden CliRunner timeout drain + skip-counter (review fixes)

This commit is contained in:
Joseph Doherty
2026-06-05 09:59:41 -04:00
parent 9e914299c8
commit bf78e3e7bf
2 changed files with 6 additions and 3 deletions
@@ -41,7 +41,7 @@ public static class CliRunner
private const string CliPassword = "password"; private const string CliPassword = "password";
private static readonly object DllLock = new(); private static readonly object DllLock = new();
private static string? _cliDll; private static volatile string? _cliDll;
/// <summary> /// <summary>
/// Management URL the CLI connects to (via the Traefik load balancer). /// Management URL the CLI connects to (via the Traefik load balancer).
@@ -111,6 +111,9 @@ public static class CliRunner
catch (OperationCanceledException) catch (OperationCanceledException)
{ {
TryKill(process); TryKill(process);
// Drain both pipes so the abandoned read tasks complete cleanly before disposal.
try { await Task.WhenAll(stdoutTask, stderrTask).WaitAsync(TimeSpan.FromSeconds(5)); }
catch { /* best-effort — we are already throwing TimeoutException */ }
throw new TimeoutException( throw new TimeoutException(
$"CLI [{string.Join(' ', args)}] did not exit within {Timeout.TotalSeconds:F0}s and was killed."); $"CLI [{string.Join(' ', args)}] did not exit within {Timeout.TotalSeconds:F0}s and was killed.");
} }
@@ -32,7 +32,7 @@ public static class ClusterAvailability
{ {
if (!cached) if (!cached)
{ {
SkippedCount++; System.Threading.Interlocked.Increment(ref SkippedCount);
} }
return cached; return cached;
@@ -46,7 +46,7 @@ public static class ClusterAvailability
catch catch
{ {
_cached = false; _cached = false;
SkippedCount++; System.Threading.Interlocked.Increment(ref SkippedCount);
} }
return _cached.Value; return _cached.Value;