From 2d145682cedc059146f06f328842a7645822bb67 Mon Sep 17 00:00:00 2001 From: Justin Kotalik Date: Wed, 20 Mar 2019 08:59:43 -0700 Subject: [PATCH] Update some tests to be flaky rather than skipped (#8666) --- .../Common.FunctionalTests/AppOfflineTests.cs | 9 +++- .../ConfigurationChangeTests.cs | 3 +- .../Inprocess/StartupTests.cs | 31 +++++++----- .../test/IIS.Tests/ClientDisconnectTests.cs | 50 +++++++++++++++++-- 4 files changed, 75 insertions(+), 18 deletions(-) diff --git a/src/Servers/IIS/IIS/test/Common.FunctionalTests/AppOfflineTests.cs b/src/Servers/IIS/IIS/test/Common.FunctionalTests/AppOfflineTests.cs index 5d162a1c3a..691e079474 100644 --- a/src/Servers/IIS/IIS/test/Common.FunctionalTests/AppOfflineTests.cs +++ b/src/Servers/IIS/IIS/test/Common.FunctionalTests/AppOfflineTests.cs @@ -212,15 +212,22 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests await AssertRunning(deploymentResult); } - [ConditionalTheory(Skip = "https://github.com/aspnet/AspNetCore/issues/7075")] + [ConditionalTheory] [InlineData(HostingModel.InProcess)] [InlineData(HostingModel.OutOfProcess)] + [Flaky("https://github.com/aspnet/AspNetCore/issues/7075")] public async Task AppOfflineAddedAndRemovedStress(HostingModel hostingModel) { var deploymentResult = await AssertStarts(hostingModel); var load = Helpers.StressLoad(deploymentResult.HttpClient, "/HelloWorld", response => { var statusCode = (int)response.StatusCode; + // Test failure involves the stress load receiving a 400 Bad Request. + // We think it is due to IIS returning the 400 itself, but need to confirm the hypothesis. + if (statusCode == 400) + { + Logger.LogError($"Status code was a bad request. Content: {response.Content.ReadAsStringAsync().GetAwaiter().GetResult()}"); + } Assert.True(statusCode == 200 || statusCode == 503, "Status code was " + statusCode); }); diff --git a/src/Servers/IIS/IIS/test/Common.FunctionalTests/ConfigurationChangeTests.cs b/src/Servers/IIS/IIS/test/Common.FunctionalTests/ConfigurationChangeTests.cs index e8ae38edd2..7b82a3b519 100644 --- a/src/Servers/IIS/IIS/test/Common.FunctionalTests/ConfigurationChangeTests.cs +++ b/src/Servers/IIS/IIS/test/Common.FunctionalTests/ConfigurationChangeTests.cs @@ -78,9 +78,10 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests EventLogHelpers.VerifyEventLogEvent(deploymentResult, EventLogHelpers.CouldNotFindHandler(), Logger); } - [ConditionalTheory(Skip = "https://github.com/aspnet/AspNetCore-Internal/issues/1794")] + [ConditionalTheory] [InlineData(HostingModel.InProcess)] [InlineData(HostingModel.OutOfProcess)] + [Flaky("https://github.com/aspnet/AspNetCore-Internal/issues/1794")] public async Task ConfigurationTouchedStress(HostingModel hostingModel) { var deploymentResult = await DeployAsync(Fixture.GetBaseDeploymentParameters(hostingModel)); diff --git a/src/Servers/IIS/IIS/test/Common.FunctionalTests/Inprocess/StartupTests.cs b/src/Servers/IIS/IIS/test/Common.FunctionalTests/Inprocess/StartupTests.cs index b4400ffd2c..4bcc4bba53 100644 --- a/src/Servers/IIS/IIS/test/Common.FunctionalTests/Inprocess/StartupTests.cs +++ b/src/Servers/IIS/IIS/test/Common.FunctionalTests/Inprocess/StartupTests.cs @@ -318,24 +318,31 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests } } - [ConditionalFact(Skip = "https://github.com/aspnet/AspNetCore-Internal/issues/1772")] + [ConditionalFact] + [Flaky("https://github.com/aspnet/AspNetCore-Internal/issues/1772")] public async Task StartupTimeoutIsApplied() { - var deploymentParameters = Fixture.GetBaseDeploymentParameters(Fixture.InProcessTestSite); - deploymentParameters.TransformArguments((a, _) => $"{a} Hang"); - deploymentParameters.WebConfigActionList.Add( - WebConfigHelpers.AddOrModifyAspNetCoreSection("startupTimeLimit", "1")); + // From what I can tell, this failure is due to ungraceful shutdown. + // The error could be the same as https://github.com/dotnet/core-setup/issues/4646 + // But can't be certain without another repro. + using (AppVerifier.Disable(DeployerSelector.ServerType, 0x300)) + { + var deploymentParameters = Fixture.GetBaseDeploymentParameters(Fixture.InProcessTestSite); + deploymentParameters.TransformArguments((a, _) => $"{a} Hang"); + deploymentParameters.WebConfigActionList.Add( + WebConfigHelpers.AddOrModifyAspNetCoreSection("startupTimeLimit", "1")); - var deploymentResult = await DeployAsync(deploymentParameters); + var deploymentResult = await DeployAsync(deploymentParameters); - var response = await deploymentResult.HttpClient.GetAsync("/"); - Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode); + var response = await deploymentResult.HttpClient.GetAsync("/"); + Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode); - StopServer(); + StopServer(); - EventLogHelpers.VerifyEventLogEvents(deploymentResult, - EventLogHelpers.InProcessFailedToStart(deploymentResult, "Managed server didn't initialize after 1000 ms.") - ); + EventLogHelpers.VerifyEventLogEvents(deploymentResult, + EventLogHelpers.InProcessFailedToStart(deploymentResult, "Managed server didn't initialize after 1000 ms.") + ); + } } [ConditionalFact] diff --git a/src/Servers/IIS/IIS/test/IIS.Tests/ClientDisconnectTests.cs b/src/Servers/IIS/IIS/test/IIS.Tests/ClientDisconnectTests.cs index b52c228069..2d21fba2c6 100644 --- a/src/Servers/IIS/IIS/test/IIS.Tests/ClientDisconnectTests.cs +++ b/src/Servers/IIS/IIS/test/IIS.Tests/ClientDisconnectTests.cs @@ -50,7 +50,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests AssertConnectionDisconnectLog(); } - [ConditionalFact(Skip = "https://github.com/aspnet/AspNetCore-Internal/issues/1831")] + [ConditionalFact] + [Flaky("https://github.com/aspnet/AspNetCore-Internal/issues/1831")] public async Task WritesCancelledWhenUsingAbortedToken() { var requestStartedCompletionSource = CreateTaskCompletionSource(); @@ -172,7 +173,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests } } - [ConditionalFact(Skip = "https://github.com/aspnet/AspNetCore-Internal/issues/1831")] + [ConditionalFact] + [Flaky("https://github.com/aspnet/AspNetCore-Internal/issues/1831")] public async Task ReaderThrowsCancelledException() { var requestStartedCompletionSource = CreateTaskCompletionSource(); @@ -217,7 +219,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests } } - [ConditionalFact(Skip = "https://github.com/aspnet/AspNetCore-Internal/issues/1817")] + [ConditionalFact] + [Flaky("https://github.com/aspnet/AspNetCore-Internal/issues/1817")] public async Task ReaderThrowsResetExceptionOnInvalidBody() { var requestStartedCompletionSource = CreateTaskCompletionSource(); @@ -237,7 +240,6 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests { exception = e; } - requestCompletedCompletionSource.SetResult(true); }, LoggerFactory)) { @@ -269,6 +271,46 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests AssertConnectionDisconnectLog(); } + [ConditionalFact] + public async Task ReadsAlwaysGoAsync() + { + // A hypothesis on why there are flaky tests is due to read async not going + // async. Adding a test that confirms ReadAsync is async. + for (var i = 0; i < 10; i++) + { + var requestStartedCompletionSource = CreateTaskCompletionSource(); + var requestCompletedCompletionSource = CreateTaskCompletionSource(); + + var data = new byte[1024]; + using (var testServer = await TestServer.Create(async ctx => + { + var task = ctx.Request.Body.ReadAsync(data); + Assert.True(!task.IsCompleted); + requestStartedCompletionSource.SetResult(true); + await task; + + requestCompletedCompletionSource.SetResult(true); + }, LoggerFactory)) + { + using (var connection = testServer.CreateConnection()) + { + await SendContentLength1Post(connection); + + await requestStartedCompletionSource.Task; + await connection.Send( + "a"); + + await connection.Receive( + "HTTP/1.1 200 OK", + "" + ); + + } + await requestCompletedCompletionSource.Task.DefaultTimeout(); + } + } + } + [ConditionalFact] public async Task RequestAbortedIsTrippedWithoutIO() {