From 7ee13875b1b3e87bb04f4069f0d50d0624761902 Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Tue, 11 Oct 2016 10:44:36 -0700 Subject: [PATCH] Reduce delay variability in KeepAliveTimeoutTests.ConnectionKeptAliveBetweenRequests() (#1157). --- .../KeepAliveTimeoutTests.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/KeepAliveTimeoutTests.cs b/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/KeepAliveTimeoutTests.cs index ce2bcc631c83..ee4a72cc577b 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/KeepAliveTimeoutTests.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/KeepAliveTimeoutTests.cs @@ -21,6 +21,14 @@ public class KeepAliveTimeoutTests [Fact] public async Task TestKeepAliveTimeout() { + // Delays in these tests cannot be much longer than expected. + // Call ConfigureAwait(false) to get rid of Xunit's synchronization context, + // otherwise it can cause unexpectedly longer delays when multiple tests + // are running in parallel. These tests becomes flaky on slower + // hardware because the continuations for the delay tasks might take too long to be + // scheduled if running on Xunit's synchronization context. + await Task.Delay(1).ConfigureAwait(false); + var longRunningCancellationTokenSource = new CancellationTokenSource(); var upgradeCancellationTokenSource = new CancellationTokenSource();