Skip to content

Commit 0f61a3d

Browse files
authored
Increase a few IIS test timeouts (#40884)
- double all `HttpClient.Timeout` values - increate max. `TimeoutAfter(...)` timeout to 15 minutes (from 10) - double values that weren't 10 minutes - double `TestConnection.Timeout` and `IISExpressDeployer.ShutdownTimeSpan` - problems acquiring logs after shutdown seem common - nearly double `TimeoutExtensions.DefaultTimeoutValue` - remove `[Repeat]` on `CheckFrebDisconnect(...)` because it makes test _more_ flaky - check more events in `EventLogHelpers` nit: Update a couple of timeout-related comments
1 parent bbc0534 commit 0f61a3d

File tree

21 files changed

+51
-36
lines changed

21 files changed

+51
-36
lines changed

src/Hosting/Server.IntegrationTesting/src/Common/DeploymentResult.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,9 @@ public DeploymentResult(ILoggerFactory loggerFactory, DeploymentParameters deplo
6262
/// <param name="baseHandler"></param>
6363
/// <returns></returns>
6464
public HttpClient CreateHttpClient(HttpMessageHandler baseHandler) =>
65-
new HttpClient(new LoggingHandler(_loggerFactory, baseHandler)) { BaseAddress = new Uri(ApplicationBaseUri) };
65+
new HttpClient(new LoggingHandler(_loggerFactory, baseHandler))
66+
{
67+
BaseAddress = new Uri(ApplicationBaseUri),
68+
Timeout = TimeSpan.FromSeconds(200),
69+
};
6670
}

src/Hosting/Server.IntegrationTesting/src/Deployers/NginxDeployer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public override async Task<DeploymentResult> DeployAsync()
7777
// Target actual address to avoid going through Nginx proxy
7878
using (var httpClient = new HttpClient())
7979
{
80+
httpClient.Timeout = TimeSpan.FromSeconds(200);
8081
var response = await RetryHelper.RetryRequest(() =>
8182
{
8283
return httpClient.GetAsync(redirectUri);

src/Hosting/Server.IntegrationTesting/src/Deployers/RemoteWindowsDeployer/RemoteWindowsDeployer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Diagnostics;
@@ -254,8 +254,8 @@ private async Task RunScriptAsync(string serverAction)
254254

255255
runScriptsOnRemoteServerProcess.StartAndCaptureOutAndErrToLogger(serverAction, Logger);
256256

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

261261
if (runScriptsOnRemoteServerProcess.HasExited && runScriptsOnRemoteServerProcess.ExitCode != 0)

src/Hosting/Server.IntegrationTesting/src/Deployers/SelfHostDeployer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ public override async Task<DeploymentResult> DeployAsync()
192192
// Host may not write startup messages, in which case assume it started
193193
if (DeploymentParameters.StatusMessagesEnabled)
194194
{
195-
// The timeout here is large, because we don't know how long the test could need
196-
// We cover a lot of error cases above, but I want to make sure we eventually give up and don't hang the build
197-
// just in case we missed one -anurse
198-
await started.Task.TimeoutAfter(TimeSpan.FromMinutes(10));
195+
// The timeout here is large, because we don't know how long the test could need. We cover a lot
196+
// of error cases above, but I want to make sure we eventually give up and don't hang the build
197+
// just in case we missed one.
198+
await started.Task.TimeoutAfter(TimeSpan.FromMinutes(15));
199199
}
200200

201201
return (url: actualUrl ?? hintUrl, hostExitToken: hostExitTokenSource.Token);

src/Hosting/TestHost/src/TestServer.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,11 @@ public HttpMessageHandler CreateHandler()
152152
/// </summary>
153153
public HttpClient CreateClient()
154154
{
155-
return new HttpClient(CreateHandler()) { BaseAddress = BaseAddress };
155+
return new HttpClient(CreateHandler())
156+
{
157+
BaseAddress = BaseAddress,
158+
Timeout = TimeSpan.FromSeconds(200),
159+
};
156160
}
157161

158162
/// <summary>

src/Servers/IIS/IIS/perf/Microbenchmarks/PlaintextBenchmark.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ public void Setup()
2727
// Recreate client, TestServer.Client has additional logging that can hurt performance
2828
_client = new HttpClient()
2929
{
30-
BaseAddress = _server.HttpClient.BaseAddress
30+
BaseAddress = _server.HttpClient.BaseAddress,
31+
Timeout = TimeSpan.FromSeconds(200),
3132
};
3233
}
3334

src/Servers/IIS/IIS/test/Common.FunctionalTests/CompressionTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public async Task DynamicResponsesAreCompressed()
130130
var client = new HttpClient(handler)
131131
{
132132
BaseAddress = _fixture.Client.BaseAddress,
133+
Timeout = TimeSpan.FromSeconds(200),
133134
};
134135
client.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip"));
135136
client.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("identity", 0));

src/Servers/IIS/IIS/test/Common.FunctionalTests/FrebTests.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@ public async Task CheckFailedRequestEvents()
9090
AssertFrebLogs(result, new FrebLogItem("ANCM_INPROC_ASYNC_COMPLETION_COMPLETION", "2"));
9191
}
9292

93-
// I think this test is flaky due to freb file not being created quickly enough.
94-
// Adding extra logging, marking as flaky, and repeating should help
9593
[ConditionalFact]
96-
[Repeat(10)]
9794
[RequiresIIS(IISCapability.FailedRequestTracingModule)]
9895
public async Task CheckFrebDisconnect()
9996
{

src/Servers/IIS/IIS/test/Common.FunctionalTests/Http2Tests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ public async Task Reset_Http1_NotSupported()
356356
{
357357
var handler = new HttpClientHandler();
358358
handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
359-
using HttpClient client = new HttpClient(handler);
359+
using var client = new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(200) };
360360
client.DefaultRequestVersion = HttpVersion.Version11;
361361
var response = await client.GetStringAsync(Fixture.Client.BaseAddress + "Reset_Http1_NotSupported");
362362
Assert.Equal("Hello World", response);
@@ -370,7 +370,7 @@ public async Task Reset_PriorOSVersions_NotSupported()
370370
{
371371
var handler = new HttpClientHandler();
372372
handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
373-
using HttpClient client = new HttpClient(handler);
373+
using var client = new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(200) };
374374
client.DefaultRequestVersion = HttpVersion.Version20;
375375
var response = await client.GetStringAsync(Fixture.Client.BaseAddress + "Reset_PriorOSVersions_NotSupported");
376376
Assert.Equal("Hello World", response);
@@ -390,7 +390,7 @@ private async Task<HttpResponseMessage> SendRequestAsync(string uri, bool http2
390390
var handler = new HttpClientHandler();
391391
handler.MaxResponseHeadersLength = 128;
392392
handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
393-
using var client = new HttpClient(handler);
393+
using var client = new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(200) };
394394
client.DefaultRequestVersion = http2 ? HttpVersion.Version20 : HttpVersion.Version11;
395395
return await client.GetAsync(uri);
396396
}

src/Servers/IIS/IIS/test/Common.FunctionalTests/Infrastructure/EventLogHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private static IEnumerable<EventLogEntry> GetEntries(IISDeploymentResult deploym
8888
var processIdString = $"Process Id: {deploymentResult.HostProcess.Id}.";
8989

9090
// Event log messages round down to the nearest second, so subtract 5 seconds to make sure we get event logs
91-
var processStartTime = deploymentResult.HostProcess.StartTime.AddSeconds(-5);
91+
var processStartTime = deploymentResult.HostProcess.StartTime.AddSeconds(-10);
9292
for (var i = eventLog.Entries.Count - 1; i >= 0; i--)
9393
{
9494
var eventLogEntry = eventLog.Entries[i];

src/Servers/IIS/IIS/test/Common.FunctionalTests/Infrastructure/Helpers.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ public static async Task StressLoad(HttpClient httpClient, string path, Action<H
4141
{
4242
async Task RunRequests()
4343
{
44-
var connection = new HttpClient() { BaseAddress = httpClient.BaseAddress };
44+
var connection = new HttpClient()
45+
{
46+
BaseAddress = httpClient.BaseAddress,
47+
Timeout = TimeSpan.FromSeconds(200),
48+
};
4549

4650
for (int j = 0; j < 10; j++)
4751
{

src/Servers/IIS/IIS/test/Common.LongTests/StartupTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,8 @@ public async Task HttpsRedirectionWorksIn30AndNot22()
13541354
};
13551355
var client = new HttpClient(handler)
13561356
{
1357-
BaseAddress = new Uri(deploymentParameters.ApplicationBaseUriHint)
1357+
BaseAddress = new Uri(deploymentParameters.ApplicationBaseUriHint),
1358+
Timeout = TimeSpan.FromSeconds(200),
13581359
};
13591360

13601361
if (DeployerSelector.HasNewHandler)

src/Servers/IIS/IIS/test/IIS.FunctionalTests/Http2TrailersResetTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ private static HttpClient CreateClient()
503503
var handler = new HttpClientHandler();
504504
handler.MaxResponseHeadersLength = 128;
505505
handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
506-
var client = new HttpClient(handler);
506+
var client = new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(200) };
507507
return client;
508508
}
509509

@@ -512,7 +512,7 @@ private async Task<HttpResponseMessage> SendRequestAsync(string uri, bool http2
512512
var handler = new HttpClientHandler();
513513
handler.MaxResponseHeadersLength = 128;
514514
handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
515-
using var client = new HttpClient(handler);
515+
using var client = new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(200) };
516516
client.DefaultRequestVersion = http2 ? HttpVersion.Version20 : HttpVersion.Version11;
517517
return await client.GetAsync(uri);
518518
}

src/Servers/IIS/IIS/test/IIS.FunctionalTests/Http3Tests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,6 @@ private HttpClient SetUpClient()
173173
var handler = new HttpClientHandler();
174174
// Needed on CI, the IIS Express cert we use isn't trusted there.
175175
handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
176-
return new HttpClient(handler);
176+
return new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(200) };
177177
}
178178
}

src/Servers/IIS/IIS/test/IIS.Tests/Utilities/TestServer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ private void Start()
106106

107107
HttpClient = new HttpClient(new LoggingHandler(new SocketsHttpHandler(), _loggerFactory.CreateLogger<TestServer>()))
108108
{
109-
BaseAddress = BaseUri
109+
BaseAddress = BaseUri,
110+
Timeout = TimeSpan.FromSeconds(200),
110111
};
111112
}
112113

src/Servers/IIS/IIS/test/IISExpress.FunctionalTests/InProcess/WebSocketTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ public WebSocketsTests(IISTestSiteFixture fixture)
3131
[ConditionalFact]
3232
public async Task RequestWithBody_NotUpgradable()
3333
{
34-
using var client = new HttpClient();
34+
using var client = new HttpClient() { Timeout = TimeSpan.FromSeconds(200) };
3535
using var response = await client.PostAsync(_requestUri + "WebSocketNotUpgradable", new StringContent("Hello World"));
3636
response.EnsureSuccessStatusCode();
3737
}
3838

3939
[ConditionalFact]
4040
public async Task RequestWithoutBody_Upgradable()
4141
{
42-
using var client = new HttpClient();
42+
using var client = new HttpClient() { Timeout = TimeSpan.FromSeconds(200) };
4343
// POST with Content-Length: 0 counts as not having a body.
4444
using var response = await client.PostAsync(_requestUri + "WebSocketUpgradable", new StringContent(""));
4545
response.EnsureSuccessStatusCode();

src/Servers/IIS/IIS/test/testassets/IIS.Common.TestLib/TestConnections.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting;
2020
/// </summary>
2121
public class TestConnection : IDisposable
2222
{
23-
private static readonly TimeSpan Timeout = TimeSpan.FromMinutes(1);
23+
private static readonly TimeSpan Timeout = TimeSpan.FromMinutes(2);
2424

2525
private readonly bool _ownsSocket;
2626
private readonly Socket _socket;

src/Servers/IIS/IIS/test/testassets/IIS.Common.TestLib/TimeoutExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting;
1010

1111
public static class TimeoutExtensions
1212
{
13-
public static TimeSpan DefaultTimeoutValue = TimeSpan.FromSeconds(300);
13+
public static TimeSpan DefaultTimeoutValue = TimeSpan.FromMinutes(10);
1414
}

src/Servers/IIS/IISIntegration/test/Tests/IISMiddlewareTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public async Task MiddlewareShutsdownGivenANCMShutdown(string pathBase, string r
135135
request.Headers.TryAddWithoutValidation("MS-ASPNETCORE-EVENT", shutdownEvent);
136136
var response = await server.CreateClient().SendAsync(request);
137137

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

197197
Assert.False(applicationStoppingFired.Task.IsCompleted);
198-
await requestExecuted.Task.TimeoutAfter(TimeSpan.FromSeconds(1));
198+
await requestExecuted.Task.TimeoutAfter(TimeSpan.FromSeconds(2));
199199
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
200200
}
201201

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

242242
Assert.False(applicationStoppingFired.Task.IsCompleted);
243-
await requestExecuted.Task.TimeoutAfter(TimeSpan.FromSeconds(1));
243+
await requestExecuted.Task.TimeoutAfter(TimeSpan.FromSeconds(2));
244244
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
245245
}
246246

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

287287
Assert.False(applicationStoppingFired.Task.IsCompleted);
288-
await requestExecuted.Task.TimeoutAfter(TimeSpan.FromSeconds(1));
288+
await requestExecuted.Task.TimeoutAfter(TimeSpan.FromSeconds(2));
289289
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
290290
}
291291

src/Servers/IIS/IntegrationTesting.IIS/src/IISDeploymentResult.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public HttpClient CreateClient(HttpMessageHandler messageHandler)
3333
{
3434
return new HttpClient(new LoggingHandler(messageHandler, Logger))
3535
{
36-
BaseAddress = base.HttpClient.BaseAddress
36+
BaseAddress = base.HttpClient.BaseAddress,
37+
Timeout = TimeSpan.FromSeconds(200),
3738
};
3839
}
3940

src/Servers/IIS/IntegrationTesting.IIS/src/IISExpressDeployer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class IISExpressDeployer : IISDeployerBase
2121
private const string FailedToInitializeBindingsMessage = "Failed to initialize site bindings";
2222
private const string UnableToStartIISExpressMessage = "Unable to start iisexpress.";
2323
private const int MaximumAttempts = 5;
24-
private readonly TimeSpan ShutdownTimeSpan = Debugger.IsAttached ? TimeSpan.FromMinutes(60) : TimeSpan.FromMinutes(1);
24+
private readonly TimeSpan ShutdownTimeSpan = Debugger.IsAttached ? TimeSpan.FromMinutes(60) : TimeSpan.FromMinutes(2);
2525
private static readonly Regex UrlDetectorRegex = new Regex(@"^\s*Successfully registered URL ""(?<url>[^""]+)"" for site.*$");
2626

2727
private Process _hostProcess;
@@ -234,10 +234,10 @@ private string CheckIfPublishIsRequired()
234234
}
235235

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

0 commit comments

Comments
 (0)