From 6e70b1bccaf71555c3092f76f86df605533316e8 Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Mon, 10 Jul 2017 15:12:01 -0700 Subject: [PATCH] Fix flakiness in MaxRequestBufferSizeTests.LargeUpload (#1850). --- .../AddressRegistrationTests.cs | 5 ++++- .../MaxRequestBufferSizeTests.cs | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/AddressRegistrationTests.cs b/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/AddressRegistrationTests.cs index 35a472a0db..fbbd9038ab 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/AddressRegistrationTests.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/AddressRegistrationTests.cs @@ -34,7 +34,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests private readonly Action _configureLoggingDelegate; - public AddressRegistrationTests(ITestOutputHelper output) => _configureLoggingDelegate = builder => builder.AddXunit(output); + public AddressRegistrationTests(ITestOutputHelper output) + { + _configureLoggingDelegate = builder => builder.AddXunit(output); + } [ConditionalFact] [NetworkIsReachable] diff --git a/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/MaxRequestBufferSizeTests.cs b/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/MaxRequestBufferSizeTests.cs index 6b3d66de1a..9cda0bbde0 100644 --- a/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/MaxRequestBufferSizeTests.cs +++ b/test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/MaxRequestBufferSizeTests.cs @@ -13,7 +13,9 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Testing; +using Microsoft.Extensions.Logging; using Xunit; +using Xunit.Abstractions; namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests { @@ -28,6 +30,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests "\r\n" }; + private readonly Action _configureLoggingDelegate; + + public MaxRequestBufferSizeTests(ITestOutputHelper output) + { + _configureLoggingDelegate = builder => builder.AddXunit(output); + } + public static IEnumerable LargeUploadData { get @@ -243,13 +252,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests } } - private static IWebHost StartWebHost(long? maxRequestBufferSize, + private IWebHost StartWebHost(long? maxRequestBufferSize, byte[] expectedBody, bool useConnectionAdapter, TaskCompletionSource startReadingRequestBody, TaskCompletionSource clientFinishedSendingRequestBody) { var host = new WebHostBuilder() + .ConfigureLogging(_configureLoggingDelegate) .UseKestrel(options => { options.Listen(new IPEndPoint(IPAddress.Loopback, 0), listenOptions => @@ -279,7 +289,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests .UseContentRoot(Directory.GetCurrentDirectory()) .Configure(app => app.Run(async context => { - await startReadingRequestBody.Task.TimeoutAfter(TimeSpan.FromSeconds(30)); + await startReadingRequestBody.Task.TimeoutAfter(TimeSpan.FromSeconds(120)); var buffer = new byte[expectedBody.Length]; var bytesRead = 0;