diff --git a/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs b/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs index 7f592ec859ae..3997e2cba497 100644 --- a/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs +++ b/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs @@ -1882,7 +1882,7 @@ await InitializeConnectionAsync(async context => { requestAbortedTcs.SetException(ex); } - }).DefaultTimeout(); + }); await StartStreamAsync(1, _browserRequestHeaders, endStream: true).DefaultTimeout(); diff --git a/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2KeepAliveTests.cs b/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2KeepAliveTests.cs index 47d9ed74d51e..371a6f5f6f8d 100644 --- a/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2KeepAliveTests.cs +++ b/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2KeepAliveTests.cs @@ -13,7 +13,7 @@ public async Task KeepAlivePingDelay_InfiniteTimeSpan_KeepAliveNotEnabled() { _serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = Timeout.InfiniteTimeSpan; - await InitializeConnectionAsync(_noopApplication).DefaultTimeout(); + await InitializeConnectionAsync(_noopApplication); Assert.Null(_connection._keepAlive); @@ -26,7 +26,7 @@ public async Task KeepAlivePingTimeout_InfiniteTimeSpan_NoGoAway() _serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = TimeSpan.FromSeconds(1); _serviceContext.ServerOptions.Limits.Http2.KeepAlivePingTimeout = Timeout.InfiniteTimeSpan; - await InitializeConnectionAsync(_noopApplication).DefaultTimeout(); + await InitializeConnectionAsync(_noopApplication); DateTimeOffset now = _serviceContext.MockSystemClock.UtcNow; @@ -56,7 +56,7 @@ public async Task IntervalExceeded_WithoutActivity_PingSent() { _serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = TimeSpan.FromSeconds(1); - await InitializeConnectionAsync(_noopApplication).DefaultTimeout(); + await InitializeConnectionAsync(_noopApplication); DateTimeOffset now = _serviceContext.MockSystemClock.UtcNow; @@ -79,7 +79,7 @@ public async Task IntervalExceeded_WithActivity_NoPingSent() { _serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = TimeSpan.FromSeconds(1); - await InitializeConnectionAsync(_noopApplication).DefaultTimeout(); + await InitializeConnectionAsync(_noopApplication); DateTimeOffset now = _serviceContext.MockSystemClock.UtcNow; @@ -103,7 +103,7 @@ public async Task IntervalNotExceeded_NoPingSent() { _serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = TimeSpan.FromSeconds(5); - await InitializeConnectionAsync(_noopApplication).DefaultTimeout(); + await InitializeConnectionAsync(_noopApplication); DateTimeOffset now = new DateTimeOffset(1, TimeSpan.Zero); @@ -121,7 +121,7 @@ public async Task IntervalExceeded_MultipleTimes_PingsNotSentWhileAwaitingOnAck( { _serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = TimeSpan.FromSeconds(1); - await InitializeConnectionAsync(_noopApplication).DefaultTimeout(); + await InitializeConnectionAsync(_noopApplication); DateTimeOffset now = _serviceContext.MockSystemClock.UtcNow; @@ -145,7 +145,7 @@ public async Task IntervalExceeded_MultipleTimes_PingSentAfterAck() { _serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = TimeSpan.FromSeconds(1); - await InitializeConnectionAsync(_noopApplication).DefaultTimeout(); + await InitializeConnectionAsync(_noopApplication); DateTimeOffset now = _serviceContext.MockSystemClock.UtcNow; @@ -185,7 +185,7 @@ public async Task TimeoutExceeded_NoAck_GoAway() _serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = TimeSpan.FromSeconds(1); _serviceContext.ServerOptions.Limits.Http2.KeepAlivePingTimeout = TimeSpan.FromSeconds(3); - await InitializeConnectionAsync(_noopApplication).DefaultTimeout(); + await InitializeConnectionAsync(_noopApplication); DateTimeOffset now = _serviceContext.MockSystemClock.UtcNow; @@ -217,7 +217,7 @@ public async Task TimeoutExceeded_NonPingActivity_NoGoAway() _serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = TimeSpan.FromSeconds(1); _serviceContext.ServerOptions.Limits.Http2.KeepAlivePingTimeout = TimeSpan.FromSeconds(3); - await InitializeConnectionAsync(_noopApplication).DefaultTimeout(); + await InitializeConnectionAsync(_noopApplication); DateTimeOffset now = _serviceContext.MockSystemClock.UtcNow; @@ -249,7 +249,7 @@ public async Task IntervalExceeded_StreamStarted_NoPingSent() { _serviceContext.ServerOptions.Limits.Http2.KeepAlivePingDelay = TimeSpan.FromSeconds(1); - await InitializeConnectionAsync(_noopApplication).DefaultTimeout(); + await InitializeConnectionAsync(_noopApplication); DateTimeOffset now = _serviceContext.MockSystemClock.UtcNow; @@ -284,7 +284,7 @@ await InitializeConnectionAsync(async c => await tcs.Task; // Send headers await c.Request.Body.FlushAsync(); - }, expectedWindowUpdate: false).DefaultTimeout(); + }, expectedWindowUpdate: false); DateTimeOffset now = _serviceContext.MockSystemClock.UtcNow; @@ -339,7 +339,7 @@ await InitializeConnectionAsync(async c => await tcs.Task; // Send headers await c.Request.Body.FlushAsync(); - }, expectedWindowUpdate: false).DefaultTimeout(); + }, expectedWindowUpdate: false); DateTimeOffset now = _serviceContext.MockSystemClock.UtcNow; diff --git a/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2StreamTests.cs b/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2StreamTests.cs index b5e37940abea..e8309332712b 100644 --- a/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2StreamTests.cs +++ b/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2StreamTests.cs @@ -2577,7 +2577,7 @@ await InitializeConnectionAsync(async context => context.Response.BodyWriter.Advance(windowSize + 1); context.Response.AppendTrailer("CustomName", "Custom Value"); - }).DefaultTimeout(); + }); await StartStreamAsync(1, headers, endStream: true).DefaultTimeout(); diff --git a/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2TestBase.cs b/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2TestBase.cs index ec8627bab14b..cfeb4db4630e 100644 --- a/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2TestBase.cs +++ b/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2TestBase.cs @@ -10,6 +10,7 @@ using System.Net.Http; using System.Net.Http.HPack; using System.Reflection; +using System.Runtime.CompilerServices; using System.Text; using Microsoft.AspNetCore.Connections; using Microsoft.AspNetCore.Http; @@ -531,7 +532,10 @@ async Task CompletePipeOnTaskCompletion() _connectionTask = CompletePipeOnTaskCompletion(); } - protected async Task InitializeConnectionAsync(RequestDelegate application, int expectedSettingsCount = 4, bool expectedWindowUpdate = true, bool addKestrelFeatures = false) + protected ConfiguredTaskAwaitable InitializeConnectionAsync(RequestDelegate application, int expectedSettingsCount = 3, bool expectedWindowUpdate = true, bool addKestrelFeatures = false) => + InnerInitializeConnectionAsync(application, expectedSettingsCount, expectedWindowUpdate).ConfigureAwait(false); + + private async Task InnerInitializeConnectionAsync(RequestDelegate application, int expectedSettingsCount, bool expectedWindowUpdate, bool addKestrelFeatures) { InitializeConnectionWithoutPreface(application, addKestrelFeatures);