diff --git a/src/ZB.MOM.WW.MxGateway.Tests/Gateway/Sessions/SessionWorkerClientFactoryFakeWorkerTests.cs b/src/ZB.MOM.WW.MxGateway.Tests/Gateway/Sessions/SessionWorkerClientFactoryFakeWorkerTests.cs index 13534a0..ed808bc 100644 --- a/src/ZB.MOM.WW.MxGateway.Tests/Gateway/Sessions/SessionWorkerClientFactoryFakeWorkerTests.cs +++ b/src/ZB.MOM.WW.MxGateway.Tests/Gateway/Sessions/SessionWorkerClientFactoryFakeWorkerTests.cs @@ -15,6 +15,13 @@ public sealed class SessionWorkerClientFactoryFakeWorkerTests : IAsyncDisposable { private static readonly TimeSpan TestTimeout = TimeSpan.FromSeconds(5); + // Anti-hang guard for the CreateAsync failure/timeout tests. It only exists to stop a genuine + // hang from wedging the run, so it must be far larger than any in-test semantic timeout (the + // factory startup timeout being exercised) — otherwise, under CI load, this WaitAsync net can + // trip before the factory's own timeout propagates and the test observes .NET's generic + // "The operation has timed out." instead of the asserted "did not complete startup". + private static readonly TimeSpan HangGuardTimeout = TimeSpan.FromSeconds(30); + private readonly List _launchers = []; /// @@ -79,7 +86,7 @@ public sealed class SessionWorkerClientFactoryFakeWorkerTests : IAsyncDisposable GatewaySession session = CreateSession(); WorkerClientException exception = await Assert.ThrowsAsync( - async () => await factory.CreateAsync(session, CancellationToken.None).WaitAsync(TestTimeout)); + async () => await factory.CreateAsync(session, CancellationToken.None).WaitAsync(HangGuardTimeout)); Assert.Equal(WorkerClientErrorCode.ProtocolViolation, exception.ErrorCode); Assert.True(launcher.Process.IsDisposed); @@ -100,7 +107,7 @@ public sealed class SessionWorkerClientFactoryFakeWorkerTests : IAsyncDisposable GatewaySession session = CreateSession(startupTimeout: TimeSpan.FromSeconds(1)); TimeoutException exception = await Assert.ThrowsAsync( - async () => await factory.CreateAsync(session, CancellationToken.None).WaitAsync(TestTimeout)); + async () => await factory.CreateAsync(session, CancellationToken.None).WaitAsync(HangGuardTimeout)); Assert.Contains("did not complete startup", exception.Message); Assert.Equal(1, launcher.Process.KillCount);