diff --git a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Cluster/CliRunner.cs b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Cluster/CliRunner.cs index 1c40b2e9..16d3b72d 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Cluster/CliRunner.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Cluster/CliRunner.cs @@ -41,7 +41,7 @@ public static class CliRunner private const string CliPassword = "password"; private static readonly object DllLock = new(); - private static string? _cliDll; + private static volatile string? _cliDll; /// /// Management URL the CLI connects to (via the Traefik load balancer). @@ -111,6 +111,9 @@ public static class CliRunner catch (OperationCanceledException) { 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( $"CLI [{string.Join(' ', args)}] did not exit within {Timeout.TotalSeconds:F0}s and was killed."); } diff --git a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Cluster/ClusterAvailability.cs b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Cluster/ClusterAvailability.cs index 1ebedd81..acf02473 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Cluster/ClusterAvailability.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Cluster/ClusterAvailability.cs @@ -32,7 +32,7 @@ public static class ClusterAvailability { if (!cached) { - SkippedCount++; + System.Threading.Interlocked.Increment(ref SkippedCount); } return cached; @@ -46,7 +46,7 @@ public static class ClusterAvailability catch { _cached = false; - SkippedCount++; + System.Threading.Interlocked.Increment(ref SkippedCount); } return _cached.Value;