diff --git a/src/Servers/Kestrel/test/Interop.FunctionalTests/Http3/Http3RequestTests.cs b/src/Servers/Kestrel/test/Interop.FunctionalTests/Http3/Http3RequestTests.cs index 058a05d9eb6a..c278bae7680b 100644 --- a/src/Servers/Kestrel/test/Interop.FunctionalTests/Http3/Http3RequestTests.cs +++ b/src/Servers/Kestrel/test/Interop.FunctionalTests/Http3/Http3RequestTests.cs @@ -314,7 +314,6 @@ public async Task POST_ClientSendsOnlyHeaders_RequestReceivedOnServer(HttpProtoc } } - [QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/52573")] [ConditionalTheory] [MsQuicSupported] [InlineData(HttpProtocols.Http3)] @@ -324,6 +323,20 @@ public async Task POST_MultipleRequests_PooledStreamAndHeaders(HttpProtocols pro // Arrange string contentType = null; string authority = null; + var pooledTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); + Action handler = null; + if (protocol == HttpProtocols.Http3) + { + handler = ctx => + { + if (ctx.EventId.Name == "StreamPooled" && + ctx.LoggerName == "Microsoft.AspNetCore.Server.Kestrel.Transport.Quic") + { + pooledTcs.TrySetResult(); + } + }; + } + var builder = CreateHostBuilder(async context => { contentType = context.Request.ContentType; @@ -333,38 +346,52 @@ public async Task POST_MultipleRequests_PooledStreamAndHeaders(HttpProtocols pro await context.Response.Body.WriteAsync(data); }, protocol: protocol); - using (var host = builder.Build()) - using (var client = HttpHelpers.CreateClient()) + try { - await host.StartAsync(); - - // Act - var response1 = await SendRequestAsync(protocol, host, client); - var contentType1 = contentType; - var authority1 = authority; + if (handler != null) + { + TestSink.MessageLogged += handler; + } - if (protocol == HttpProtocols.Http3) + using (var host = builder.Build()) + using (var client = HttpHelpers.CreateClient()) { - await WaitForLogAsync(logs => + await host.StartAsync(); + + // Act + var response1 = await SendRequestAsync(protocol, host, client); + var contentType1 = contentType; + var authority1 = authority; + + if (protocol == HttpProtocols.Http3) { - return logs.Any(w => w.LoggerName == "Microsoft.AspNetCore.Server.Kestrel.Transport.Quic" && - w.EventId.Name == "StreamPooled"); - }, "Wait for server to finish pooling stream."); - } + // Wait for the server to pool the first request's stream before sending + // the second request, so the second request reuses the same + // HttpRequestHeaders instance and Assert.Same below holds. + await pooledTcs.Task.DefaultTimeout(); + } - var response2 = await SendRequestAsync(protocol, host, client); - var contentType2 = contentType; - var authority2 = authority; + var response2 = await SendRequestAsync(protocol, host, client); + var contentType2 = contentType; + var authority2 = authority; - // Assert - Assert.NotNull(contentType1); - Assert.NotNull(authority1); + // Assert + Assert.NotNull(contentType1); + Assert.NotNull(authority1); - // We're testing `Same`, specifically, since we're trying to detect cache misses - Assert.Same(contentType1, contentType2); - Assert.Same(authority1, authority2); + // We're testing `Same`, specifically, since we're trying to detect cache misses + Assert.Same(contentType1, contentType2); + Assert.Same(authority1, authority2); - await host.StopAsync(); + await host.StopAsync(); + } + } + finally + { + if (handler != null) + { + TestSink.MessageLogged -= handler; + } } static async Task SendRequestAsync(HttpProtocols protocol, IHost host, HttpMessageInvoker client)