Skip to content

Increase a few IIS test timeouts #40884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,9 @@ public DeploymentResult(ILoggerFactory loggerFactory, DeploymentParameters deplo
/// <param name="baseHandler"></param>
/// <returns></returns>
public HttpClient CreateHttpClient(HttpMessageHandler baseHandler) =>
new HttpClient(new LoggingHandler(_loggerFactory, baseHandler)) { BaseAddress = new Uri(ApplicationBaseUri) };
new HttpClient(new LoggingHandler(_loggerFactory, baseHandler))
{
BaseAddress = new Uri(ApplicationBaseUri),
Timeout = TimeSpan.FromSeconds(200),
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public override async Task<DeploymentResult> DeployAsync()
// Target actual address to avoid going through Nginx proxy
using (var httpClient = new HttpClient())
{
httpClient.Timeout = TimeSpan.FromSeconds(200);
var response = await RetryHelper.RetryRequest(() =>
{
return httpClient.GetAsync(redirectUri);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics;
Expand Down Expand Up @@ -254,8 +254,8 @@ private async Task RunScriptAsync(string serverAction)

runScriptsOnRemoteServerProcess.StartAndCaptureOutAndErrToLogger(serverAction, Logger);

// Wait a second for the script to run or fail. The StartServer script will only terminate when the Deployer is disposed,
// so we don't want to wait for it to terminate here because it would deadlock.
// Wait a minute for the script to run or fail. The StartServer script will only terminate when the
// Deployer is disposed, so we don't want to wait for it to terminate here because it would deadlock.
await Task.Delay(TimeSpan.FromMinutes(1));

if (runScriptsOnRemoteServerProcess.HasExited && runScriptsOnRemoteServerProcess.ExitCode != 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ public override async Task<DeploymentResult> DeployAsync()
// Host may not write startup messages, in which case assume it started
if (DeploymentParameters.StatusMessagesEnabled)
{
// The timeout here is large, because we don't know how long the test could need
// We cover a lot of error cases above, but I want to make sure we eventually give up and don't hang the build
// just in case we missed one -anurse
await started.Task.TimeoutAfter(TimeSpan.FromMinutes(10));
// The timeout here is large, because we don't know how long the test could need. We cover a lot
// of error cases above, but I want to make sure we eventually give up and don't hang the build
// just in case we missed one.
await started.Task.TimeoutAfter(TimeSpan.FromMinutes(15));
}

return (url: actualUrl ?? hintUrl, hostExitToken: hostExitTokenSource.Token);
Expand Down
6 changes: 5 additions & 1 deletion src/Hosting/TestHost/src/TestServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ public HttpMessageHandler CreateHandler()
/// </summary>
public HttpClient CreateClient()
{
return new HttpClient(CreateHandler()) { BaseAddress = BaseAddress };
return new HttpClient(CreateHandler())
{
BaseAddress = BaseAddress,
Timeout = TimeSpan.FromSeconds(200),
};
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public void Setup()
// Recreate client, TestServer.Client has additional logging that can hurt performance
_client = new HttpClient()
{
BaseAddress = _server.HttpClient.BaseAddress
BaseAddress = _server.HttpClient.BaseAddress,
Timeout = TimeSpan.FromSeconds(200),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public async Task DynamicResponsesAreCompressed()
var client = new HttpClient(handler)
{
BaseAddress = _fixture.Client.BaseAddress,
Timeout = TimeSpan.FromSeconds(200),
};
client.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip"));
client.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("identity", 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ public async Task CheckFailedRequestEvents()
AssertFrebLogs(result, new FrebLogItem("ANCM_INPROC_ASYNC_COMPLETION_COMPLETION", "2"));
}

// I think this test is flaky due to freb file not being created quickly enough.
// Adding extra logging, marking as flaky, and repeating should help
[ConditionalFact]
[Repeat(10)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General note: [Repeat] is useful when testing reliability but just makes things more flaky if checked in for a non-quarantined test.

[RequiresIIS(IISCapability.FailedRequestTracingModule)]
public async Task CheckFrebDisconnect()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public async Task Reset_Http1_NotSupported()
{
var handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
using HttpClient client = new HttpClient(handler);
using var client = new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(200) };
client.DefaultRequestVersion = HttpVersion.Version11;
var response = await client.GetStringAsync(Fixture.Client.BaseAddress + "Reset_Http1_NotSupported");
Assert.Equal("Hello World", response);
Expand All @@ -370,7 +370,7 @@ public async Task Reset_PriorOSVersions_NotSupported()
{
var handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
using HttpClient client = new HttpClient(handler);
using var client = new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(200) };
client.DefaultRequestVersion = HttpVersion.Version20;
var response = await client.GetStringAsync(Fixture.Client.BaseAddress + "Reset_PriorOSVersions_NotSupported");
Assert.Equal("Hello World", response);
Expand All @@ -390,7 +390,7 @@ private async Task<HttpResponseMessage> SendRequestAsync(string uri, bool http2
var handler = new HttpClientHandler();
handler.MaxResponseHeadersLength = 128;
handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
using var client = new HttpClient(handler);
using var client = new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(200) };
client.DefaultRequestVersion = http2 ? HttpVersion.Version20 : HttpVersion.Version11;
return await client.GetAsync(uri);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private static IEnumerable<EventLogEntry> GetEntries(IISDeploymentResult deploym
var processIdString = $"Process Id: {deploymentResult.HostProcess.Id}.";

// Event log messages round down to the nearest second, so subtract 5 seconds to make sure we get event logs
var processStartTime = deploymentResult.HostProcess.StartTime.AddSeconds(-5);
var processStartTime = deploymentResult.HostProcess.StartTime.AddSeconds(-10);
for (var i = eventLog.Entries.Count - 1; i >= 0; i--)
{
var eventLogEntry = eventLog.Entries[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ public static async Task StressLoad(HttpClient httpClient, string path, Action<H
{
async Task RunRequests()
{
var connection = new HttpClient() { BaseAddress = httpClient.BaseAddress };
var connection = new HttpClient()
{
BaseAddress = httpClient.BaseAddress,
Timeout = TimeSpan.FromSeconds(200),
};

for (int j = 0; j < 10; j++)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Servers/IIS/IIS/test/Common.LongTests/StartupTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,8 @@ public async Task HttpsRedirectionWorksIn30AndNot22()
};
var client = new HttpClient(handler)
{
BaseAddress = new Uri(deploymentParameters.ApplicationBaseUriHint)
BaseAddress = new Uri(deploymentParameters.ApplicationBaseUriHint),
Timeout = TimeSpan.FromSeconds(200),
};

if (DeployerSelector.HasNewHandler)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ private static HttpClient CreateClient()
var handler = new HttpClientHandler();
handler.MaxResponseHeadersLength = 128;
handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
var client = new HttpClient(handler);
var client = new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(200) };
return client;
}

Expand All @@ -512,7 +512,7 @@ private async Task<HttpResponseMessage> SendRequestAsync(string uri, bool http2
var handler = new HttpClientHandler();
handler.MaxResponseHeadersLength = 128;
handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
using var client = new HttpClient(handler);
using var client = new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(200) };
client.DefaultRequestVersion = http2 ? HttpVersion.Version20 : HttpVersion.Version11;
return await client.GetAsync(uri);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,6 @@ private HttpClient SetUpClient()
var handler = new HttpClientHandler();
// Needed on CI, the IIS Express cert we use isn't trusted there.
handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
return new HttpClient(handler);
return new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(200) };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ private void Start()

HttpClient = new HttpClient(new LoggingHandler(new SocketsHttpHandler(), _loggerFactory.CreateLogger<TestServer>()))
{
BaseAddress = BaseUri
BaseAddress = BaseUri,
Timeout = TimeSpan.FromSeconds(200),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ public WebSocketsTests(IISTestSiteFixture fixture)
[ConditionalFact]
public async Task RequestWithBody_NotUpgradable()
{
using var client = new HttpClient();
using var client = new HttpClient() { Timeout = TimeSpan.FromSeconds(200) };
using var response = await client.PostAsync(_requestUri + "WebSocketNotUpgradable", new StringContent("Hello World"));
response.EnsureSuccessStatusCode();
}

[ConditionalFact]
public async Task RequestWithoutBody_Upgradable()
{
using var client = new HttpClient();
using var client = new HttpClient() { Timeout = TimeSpan.FromSeconds(200) };
// POST with Content-Length: 0 counts as not having a body.
using var response = await client.PostAsync(_requestUri + "WebSocketUpgradable", new StringContent(""));
response.EnsureSuccessStatusCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting;
/// </summary>
public class TestConnection : IDisposable
{
private static readonly TimeSpan Timeout = TimeSpan.FromMinutes(1);
private static readonly TimeSpan Timeout = TimeSpan.FromMinutes(2);

private readonly bool _ownsSocket;
private readonly Socket _socket;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting;

public static class TimeoutExtensions
{
public static TimeSpan DefaultTimeoutValue = TimeSpan.FromSeconds(300);
public static TimeSpan DefaultTimeoutValue = TimeSpan.FromMinutes(10);
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public async Task MiddlewareShutsdownGivenANCMShutdown(string pathBase, string r
request.Headers.TryAddWithoutValidation("MS-ASPNETCORE-EVENT", shutdownEvent);
var response = await server.CreateClient().SendAsync(request);

await applicationStoppingFired.Task.TimeoutAfter(TimeSpan.FromSeconds(5));
await applicationStoppingFired.Task.TimeoutAfter(TimeSpan.FromSeconds(10));
Assert.False(requestExecuted.Task.IsCompleted);
Assert.Equal(HttpStatusCode.Accepted, response.StatusCode);
}
Expand Down Expand Up @@ -195,7 +195,7 @@ public async Task MiddlewareIgnoresShutdownGivenWrongMethod(HttpMethod method)
var response = await server.CreateClient().SendAsync(request);

Assert.False(applicationStoppingFired.Task.IsCompleted);
await requestExecuted.Task.TimeoutAfter(TimeSpan.FromSeconds(1));
await requestExecuted.Task.TimeoutAfter(TimeSpan.FromSeconds(2));
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}

Expand Down Expand Up @@ -240,7 +240,7 @@ public async Task MiddlewareIgnoresShutdownGivenWrongPath(string path)
var response = await server.CreateClient().SendAsync(request);

Assert.False(applicationStoppingFired.Task.IsCompleted);
await requestExecuted.Task.TimeoutAfter(TimeSpan.FromSeconds(1));
await requestExecuted.Task.TimeoutAfter(TimeSpan.FromSeconds(2));
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}

Expand Down Expand Up @@ -285,7 +285,7 @@ public async Task MiddlewareIgnoresShutdownGivenWrongEvent(string shutdownEvent)
var response = await server.CreateClient().SendAsync(request);

Assert.False(applicationStoppingFired.Task.IsCompleted);
await requestExecuted.Task.TimeoutAfter(TimeSpan.FromSeconds(1));
await requestExecuted.Task.TimeoutAfter(TimeSpan.FromSeconds(2));
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public HttpClient CreateClient(HttpMessageHandler messageHandler)
{
return new HttpClient(new LoggingHandler(messageHandler, Logger))
{
BaseAddress = base.HttpClient.BaseAddress
BaseAddress = base.HttpClient.BaseAddress,
Timeout = TimeSpan.FromSeconds(200),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class IISExpressDeployer : IISDeployerBase
private const string FailedToInitializeBindingsMessage = "Failed to initialize site bindings";
private const string UnableToStartIISExpressMessage = "Unable to start iisexpress.";
private const int MaximumAttempts = 5;
private readonly TimeSpan ShutdownTimeSpan = Debugger.IsAttached ? TimeSpan.FromMinutes(60) : TimeSpan.FromMinutes(1);
private readonly TimeSpan ShutdownTimeSpan = Debugger.IsAttached ? TimeSpan.FromMinutes(60) : TimeSpan.FromMinutes(2);
private static readonly Regex UrlDetectorRegex = new Regex(@"^\s*Successfully registered URL ""(?<url>[^""]+)"" for site.*$");

private Process _hostProcess;
Expand Down Expand Up @@ -234,10 +234,10 @@ private string CheckIfPublishIsRequired()
}

// Wait for the app to start
// The timeout here is large, because we don't know how long the test could need
// We cover a lot of error cases above, but I want to make sure we eventually give up and don't hang the build
// The timeout here is large, because we don't know how long the test could need. We cover a lot
// of error cases above, but I want to make sure we eventually give up and don't hang the build
// just in case we missed one -anurse
if (!await started.Task.TimeoutAfter(TimeSpan.FromMinutes(10)))
if (!await started.Task.TimeoutAfter(TimeSpan.FromMinutes(15)))
{
Logger.LogInformation("iisexpress Process {pid} failed to bind to port {port}, trying again", process.Id, port);

Expand Down