Fix flakiness in address-in-use test (#2267)
* Increase test timeouts * Use constant for default test timeout.
This commit is contained in:
parent
a57bc4b3bb
commit
30a68dec49
|
|
@ -589,7 +589,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
_http1Connection.StopProcessingNextRequest();
|
||||
Assert.IsNotType<Task<Task>>(requestProcessingTask);
|
||||
|
||||
await requestProcessingTask.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
await requestProcessingTask.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
_application.Output.Complete();
|
||||
}
|
||||
|
||||
|
|
@ -713,21 +713,21 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
var requestProcessingTask = _http1Connection.ProcessRequestsAsync<object>(null);
|
||||
|
||||
await _application.Output.WriteAsync(Encoding.ASCII.GetBytes("GET / HTTP/1.0\r\n"));
|
||||
await WaitForCondition(TimeSpan.FromSeconds(1), () => _http1Connection.RequestHeaders != null);
|
||||
await WaitForCondition(TestConstants.DefaultTimeout, () => _http1Connection.RequestHeaders != null);
|
||||
Assert.Equal(0, _http1Connection.RequestHeaders.Count);
|
||||
|
||||
await _application.Output.WriteAsync(Encoding.ASCII.GetBytes(headers0));
|
||||
await WaitForCondition(TimeSpan.FromSeconds(1), () => _http1Connection.RequestHeaders.Count >= header0Count);
|
||||
await WaitForCondition(TestConstants.DefaultTimeout, () => _http1Connection.RequestHeaders.Count >= header0Count);
|
||||
Assert.Equal(header0Count, _http1Connection.RequestHeaders.Count);
|
||||
|
||||
await _application.Output.WriteAsync(Encoding.ASCII.GetBytes(headers1));
|
||||
await WaitForCondition(TimeSpan.FromSeconds(1), () => _http1Connection.RequestHeaders.Count >= header0Count + header1Count);
|
||||
await WaitForCondition(TestConstants.DefaultTimeout, () => _http1Connection.RequestHeaders.Count >= header0Count + header1Count);
|
||||
Assert.Equal(header0Count + header1Count, _http1Connection.RequestHeaders.Count);
|
||||
|
||||
await _application.Output.WriteAsync(Encoding.ASCII.GetBytes("\r\n"));
|
||||
Assert.Equal(header0Count + header1Count, _http1Connection.RequestHeaders.Count);
|
||||
|
||||
await requestProcessingTask.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
await requestProcessingTask.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
@ -747,7 +747,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
var requestProcessingTask = _http1Connection.ProcessRequestsAsync<object>(null);
|
||||
|
||||
await _application.Output.WriteAsync(Encoding.ASCII.GetBytes("GET / HTTP/1.0\r\n"));
|
||||
await WaitForCondition(TimeSpan.FromSeconds(1), () => _http1Connection.RequestHeaders != null);
|
||||
await WaitForCondition(TestConstants.DefaultTimeout, () => _http1Connection.RequestHeaders != null);
|
||||
Assert.Equal(0, _http1Connection.RequestHeaders.Count);
|
||||
|
||||
var newRequestHeaders = new RequestHeadersWrapper(_http1Connection.RequestHeaders);
|
||||
|
|
@ -755,12 +755,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
Assert.Same(newRequestHeaders, _http1Connection.RequestHeaders);
|
||||
|
||||
await _application.Output.WriteAsync(Encoding.ASCII.GetBytes(headers0));
|
||||
await WaitForCondition(TimeSpan.FromSeconds(1), () => _http1Connection.RequestHeaders.Count >= header0Count);
|
||||
await WaitForCondition(TestConstants.DefaultTimeout, () => _http1Connection.RequestHeaders.Count >= header0Count);
|
||||
Assert.Same(newRequestHeaders, _http1Connection.RequestHeaders);
|
||||
Assert.Equal(header0Count, _http1Connection.RequestHeaders.Count);
|
||||
|
||||
await _application.Output.WriteAsync(Encoding.ASCII.GetBytes(headers1));
|
||||
await WaitForCondition(TimeSpan.FromSeconds(1), () => _http1Connection.RequestHeaders.Count >= header0Count + header1Count);
|
||||
await WaitForCondition(TestConstants.DefaultTimeout, () => _http1Connection.RequestHeaders.Count >= header0Count + header1Count);
|
||||
Assert.Same(newRequestHeaders, _http1Connection.RequestHeaders);
|
||||
Assert.Equal(header0Count + header1Count, _http1Connection.RequestHeaders.Count);
|
||||
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
sem.Release();
|
||||
});
|
||||
|
||||
await sem.WaitAsync().TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
await sem.WaitAsync().TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
};
|
||||
|
||||
_largeHeadersApplication = context =>
|
||||
|
|
@ -220,7 +220,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
sem.Release();
|
||||
});
|
||||
|
||||
await sem.WaitAsync().TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
await sem.WaitAsync().TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
|
||||
_runningStreams[streamIdFeature.StreamId].TrySetResult(null);
|
||||
};
|
||||
|
|
@ -240,7 +240,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
sem.Release();
|
||||
});
|
||||
|
||||
await sem.WaitAsync().TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
await sem.WaitAsync().TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
|
||||
await context.Response.Body.FlushAsync();
|
||||
|
||||
|
|
@ -2133,7 +2133,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
|
||||
private Task WaitForAllStreamsAsync()
|
||||
{
|
||||
return Task.WhenAll(_runningStreams.Values.Select(tcs => tcs.Task)).TimeoutAfter(TimeSpan.FromSeconds(30));
|
||||
return Task.WhenAll(_runningStreams.Values.Select(tcs => tcs.Task)).TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
|
||||
private async Task SendAsync(ArraySegment<byte> span)
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
unbind.Release();
|
||||
stop.Release();
|
||||
|
||||
await Task.WhenAll(new[] { stopTask1, stopTask2, stopTask3 }).TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
await Task.WhenAll(new[] { stopTask1, stopTask2, stopTask3 }).TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
|
||||
mockTransport.Verify(transport => transport.UnbindAsync(), Times.Once);
|
||||
mockTransport.Verify(transport => transport.StopAsync(), Times.Once);
|
||||
|
|
@ -317,7 +317,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
|
||||
unbind.Release();
|
||||
|
||||
var timeout = TimeSpan.FromSeconds(10);
|
||||
var timeout = TestConstants.DefaultTimeout;
|
||||
Assert.Same(unbindException, await Assert.ThrowsAsync<InvalidOperationException>(() => stopTask1.TimeoutAfter(timeout)));
|
||||
Assert.Same(unbindException, await Assert.ThrowsAsync<InvalidOperationException>(() => stopTask2.TimeoutAfter(timeout)));
|
||||
Assert.Same(unbindException, await Assert.ThrowsAsync<InvalidOperationException>(() => stopTask3.TimeoutAfter(timeout)));
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
|
||||
input.Add("\r\r\r\nHello\r\n0\r\n\r\n");
|
||||
|
||||
Assert.Equal(5, await readTask.TimeoutAfter(TimeSpan.FromSeconds(10)));
|
||||
Assert.Equal(5, await readTask.TimeoutAfter(TestConstants.DefaultTimeout));
|
||||
Assert.Equal(0, await stream.ReadAsync(buffer, 0, buffer.Length));
|
||||
|
||||
await body.StopAsync();
|
||||
|
|
@ -704,7 +704,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
|
||||
input.Fin();
|
||||
|
||||
Assert.True(logEvent.Wait(TimeSpan.FromSeconds(10)));
|
||||
Assert.True(logEvent.Wait(TestConstants.DefaultTimeout));
|
||||
|
||||
await body.StopAsync();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -618,14 +618,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
[Fact]
|
||||
public void ThrowsWhenBindingLocalhostToIPv4AddressInUse()
|
||||
{
|
||||
ThrowsWhenBindingLocalhostToAddressInUse(AddressFamily.InterNetwork, IPAddress.Loopback);
|
||||
ThrowsWhenBindingLocalhostToAddressInUse(AddressFamily.InterNetwork);
|
||||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[IPv6SupportedCondition]
|
||||
public void ThrowsWhenBindingLocalhostToIPv6AddressInUse()
|
||||
{
|
||||
ThrowsWhenBindingLocalhostToAddressInUse(AddressFamily.InterNetworkV6, IPAddress.IPv6Loopback);
|
||||
ThrowsWhenBindingLocalhostToAddressInUse(AddressFamily.InterNetworkV6);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -738,27 +738,74 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
}
|
||||
}
|
||||
|
||||
private void ThrowsWhenBindingLocalhostToAddressInUse(AddressFamily addressFamily, IPAddress address)
|
||||
private void ThrowsWhenBindingLocalhostToAddressInUse(AddressFamily addressFamily)
|
||||
{
|
||||
using (var socket = new Socket(addressFamily, SocketType.Stream, ProtocolType.Tcp))
|
||||
var addressInUseCount = 0;
|
||||
var wrongMessageCount = 0;
|
||||
|
||||
var address = addressFamily == AddressFamily.InterNetwork ? IPAddress.Loopback : IPAddress.IPv6Loopback;
|
||||
var otherAddressFamily = addressFamily == AddressFamily.InterNetwork ? AddressFamily.InterNetworkV6 : AddressFamily.InterNetwork;
|
||||
|
||||
while (addressInUseCount < 10 && wrongMessageCount < 10)
|
||||
{
|
||||
socket.Bind(new IPEndPoint(address, 0));
|
||||
socket.Listen(0);
|
||||
var port = ((IPEndPoint)socket.LocalEndPoint).Port;
|
||||
int port;
|
||||
|
||||
var hostBuilder = TransportSelector.GetWebHostBuilder()
|
||||
.ConfigureLogging(_configureLoggingDelegate)
|
||||
.UseKestrel()
|
||||
.UseUrls($"http://localhost:{port}")
|
||||
.Configure(ConfigureEchoAddress);
|
||||
|
||||
using (var host = hostBuilder.Build())
|
||||
using (var socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
var exception = Assert.Throws<IOException>(() => host.Start());
|
||||
Assert.Equal(
|
||||
CoreStrings.FormatEndpointAlreadyInUse($"http://{(addressFamily == AddressFamily.InterNetwork ? "127.0.0.1" : "[::1]")}:{port}"),
|
||||
exception.Message);
|
||||
// Bind first to IPv6Any to ensure both the IPv4 and IPv6 ports are avaiable.
|
||||
socket.Bind(new IPEndPoint(IPAddress.IPv6Any, 0));
|
||||
socket.Listen(0);
|
||||
port = ((IPEndPoint)socket.LocalEndPoint).Port;
|
||||
}
|
||||
|
||||
using (var socket = new Socket(addressFamily, SocketType.Stream, ProtocolType.Tcp))
|
||||
{
|
||||
try
|
||||
{
|
||||
socket.Bind(new IPEndPoint(address, port));
|
||||
socket.Listen(0);
|
||||
}
|
||||
catch (SocketException)
|
||||
{
|
||||
addressInUseCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
var hostBuilder = TransportSelector.GetWebHostBuilder()
|
||||
.ConfigureLogging(_configureLoggingDelegate)
|
||||
.UseKestrel()
|
||||
.UseUrls($"http://localhost:{port}")
|
||||
.Configure(ConfigureEchoAddress);
|
||||
|
||||
using (var host = hostBuilder.Build())
|
||||
{
|
||||
var exception = Assert.Throws<IOException>(() => host.Start());
|
||||
|
||||
var thisAddressString = $"http://{(addressFamily == AddressFamily.InterNetwork ? "127.0.0.1" : "[::1]")}:{port}";
|
||||
var otherAddressString = $"http://{(addressFamily == AddressFamily.InterNetworkV6? "127.0.0.1" : "[::1]")}:{port}";
|
||||
|
||||
if (exception.Message == CoreStrings.FormatEndpointAlreadyInUse(otherAddressString))
|
||||
{
|
||||
// Don't fail immediately, because it's possible that something else really did bind to the
|
||||
// same port for the other address family between the IPv6Any bind above and now.
|
||||
wrongMessageCount++;
|
||||
continue;
|
||||
}
|
||||
|
||||
Assert.Equal(CoreStrings.FormatEndpointAlreadyInUse(thisAddressString), exception.Message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (addressInUseCount >= 10)
|
||||
{
|
||||
Assert.True(false, $"The corresponding {otherAddressFamily} address was already in use 10 times.");
|
||||
}
|
||||
|
||||
if (wrongMessageCount >= 10)
|
||||
{
|
||||
Assert.True(false, $"An error for a conflict with {otherAddressFamily} was thrown 10 times.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,11 +37,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
{
|
||||
await connection.SendEmptyGetAsKeepAlive(); ;
|
||||
await connection.Receive("HTTP/1.1 200 OK");
|
||||
Assert.True(await lockedTcs.Task.TimeoutAfter(TimeSpan.FromSeconds(10)));
|
||||
Assert.True(await lockedTcs.Task.TimeoutAfter(TestConstants.DefaultTimeout));
|
||||
requestTcs.TrySetResult(null);
|
||||
}
|
||||
|
||||
await releasedTcs.Task.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
await releasedTcs.Task.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -85,7 +85,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
catch { }
|
||||
|
||||
// connection should close without sending any data
|
||||
await rejected.WaitForConnectionClose().TimeoutAfter(TimeSpan.FromSeconds(15));
|
||||
await rejected.WaitForConnectionClose().TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -124,7 +124,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
} catch { }
|
||||
|
||||
// connection should close without sending any data
|
||||
await connection.WaitForConnectionClose().TimeoutAfter(TimeSpan.FromSeconds(15));
|
||||
await connection.WaitForConnectionClose().TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
"Host:",
|
||||
"",
|
||||
"")
|
||||
.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
await connection.Receive("HTTP/1.1 200");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,14 +50,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
{
|
||||
await connection.SendEmptyGet();
|
||||
|
||||
Assert.True(await appStartedWh.WaitAsync(TimeSpan.FromSeconds(10)));
|
||||
Assert.True(await appStartedWh.WaitAsync(TestConstants.DefaultTimeout));
|
||||
|
||||
// Close connection without waiting for a response
|
||||
}
|
||||
|
||||
var logWaitAttempts = 0;
|
||||
|
||||
for (; !await logWh.WaitAsync(TimeSpan.FromSeconds(1)) && logWaitAttempts < 10; logWaitAttempts++)
|
||||
for (; !await logWh.WaitAsync(TimeSpan.FromSeconds(1)) && logWaitAttempts < 30; logWaitAttempts++)
|
||||
{
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
|
||||
using (var connection = new TestConnection(host.GetPort()))
|
||||
{
|
||||
await connection.WaitForConnectionClose().TimeoutAfter(TimeSpan.FromSeconds(30));
|
||||
await connection.WaitForConnectionClose().TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
// Close socket immediately
|
||||
}
|
||||
|
||||
await loggerProvider.FilterLogger.LogTcs.Task.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
await loggerProvider.FilterLogger.LogTcs.Task.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
|
||||
Assert.Equal(1, loggerProvider.FilterLogger.LastEventId.Id);
|
||||
|
|
@ -144,7 +144,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
await stream.WriteAsync(new byte[10], 0, 10);
|
||||
}
|
||||
|
||||
await loggerProvider.FilterLogger.LogTcs.Task.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
await loggerProvider.FilterLogger.LogTcs.Task.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
|
||||
Assert.Equal(1, loggerProvider.FilterLogger.LastEventId.Id);
|
||||
|
|
@ -251,7 +251,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
}
|
||||
}
|
||||
|
||||
await tcs.Task.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
await tcs.Task.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
|
||||
// Regression test for https://github.com/aspnet/KestrelHttpServer/issues/1693
|
||||
|
|
@ -345,11 +345,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
using (var stream = new NetworkStream(socket, ownsSocket: false))
|
||||
{
|
||||
// No data should be sent and the connection should be closed in well under 30 seconds.
|
||||
Assert.Equal(0, await stream.ReadAsync(new byte[1], 0, 1).TimeoutAfter(TimeSpan.FromSeconds(30)));
|
||||
Assert.Equal(0, await stream.ReadAsync(new byte[1], 0, 1).TimeoutAfter(TestConstants.DefaultTimeout));
|
||||
}
|
||||
}
|
||||
|
||||
await loggerProvider.FilterLogger.LogTcs.Task.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
await loggerProvider.FilterLogger.LogTcs.Task.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
Assert.Equal(2, loggerProvider.FilterLogger.LastEventId);
|
||||
Assert.Equal(LogLevel.Information, loggerProvider.FilterLogger.LastLogLevel);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
"",
|
||||
"");
|
||||
|
||||
Assert.True(appRunningEvent.Wait(TimeSpan.FromSeconds(10)));
|
||||
Assert.True(appRunningEvent.Wait(TestConstants.DefaultTimeout));
|
||||
systemClock.UtcNow += gracePeriod + TimeSpan.FromSeconds(1);
|
||||
|
||||
await connection.Receive(
|
||||
|
|
@ -100,7 +100,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
"",
|
||||
"");
|
||||
|
||||
Assert.True(appRunningEvent.Wait(TimeSpan.FromSeconds(10)));
|
||||
Assert.True(appRunningEvent.Wait(TestConstants.DefaultTimeout));
|
||||
|
||||
await connection.Receive(
|
||||
"HTTP/1.1 200 OK",
|
||||
|
|
@ -163,9 +163,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
"",
|
||||
"");
|
||||
|
||||
Assert.True(appRunningEvent.Wait(TimeSpan.FromSeconds(10)), "AppRunningEvent timed out.");
|
||||
Assert.True(appRunningEvent.Wait(TestConstants.DefaultTimeout), "AppRunningEvent timed out.");
|
||||
systemClock.UtcNow += gracePeriod + TimeSpan.FromSeconds(1);
|
||||
Assert.True(exceptionSwallowedEvent.Wait(TimeSpan.FromSeconds(10)), "ExceptionSwallowedEvent timed out.");
|
||||
Assert.True(exceptionSwallowedEvent.Wait(TestConstants.DefaultTimeout), "ExceptionSwallowedEvent timed out.");
|
||||
|
||||
await connection.Receive(
|
||||
"HTTP/1.1 200 OK",
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
using (var connection = server.CreateConnection())
|
||||
{
|
||||
// Wait until connection is established
|
||||
Assert.True(await connectionStarted.WaitAsync(TimeSpan.FromSeconds(10)));
|
||||
Assert.True(await connectionStarted.WaitAsync(TestConstants.DefaultTimeout));
|
||||
|
||||
// Force a reset
|
||||
connection.Socket.LingerState = new LingerOption(true, 0);
|
||||
|
|
@ -320,7 +320,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
// This check MUST come before disposing the server, otherwise there's a race where the RST
|
||||
// is still in flight when the connection is aborted, leading to the reset never being received
|
||||
// and therefore not logged.
|
||||
Assert.True(await connectionReset.WaitAsync(TimeSpan.FromSeconds(10)));
|
||||
Assert.True(await connectionReset.WaitAsync(TestConstants.DefaultTimeout));
|
||||
}
|
||||
|
||||
Assert.False(loggedHigherThanDebug);
|
||||
|
|
@ -388,7 +388,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
// This check MUST come before disposing the server, otherwise there's a race where the RST
|
||||
// is still in flight when the connection is aborted, leading to the reset never being received
|
||||
// and therefore not logged.
|
||||
Assert.True(await connectionReset.WaitAsync(TimeSpan.FromSeconds(10)));
|
||||
Assert.True(await connectionReset.WaitAsync(TestConstants.DefaultTimeout));
|
||||
}
|
||||
|
||||
Assert.False(loggedHigherThanDebug);
|
||||
|
|
@ -445,7 +445,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
await connection.SendEmptyGet();
|
||||
|
||||
// Wait until connection is established
|
||||
Assert.True(await requestStarted.WaitAsync(TimeSpan.FromSeconds(30)), "request should have started");
|
||||
Assert.True(await requestStarted.WaitAsync(TestConstants.DefaultTimeout), "request should have started");
|
||||
|
||||
// Force a reset
|
||||
connection.Socket.LingerState = new LingerOption(true, 0);
|
||||
|
|
@ -455,7 +455,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
// This check MUST come before disposing the server, otherwise there's a race where the RST
|
||||
// is still in flight when the connection is aborted, leading to the reset never being received
|
||||
// and therefore not logged.
|
||||
Assert.True(await connectionReset.WaitAsync(TimeSpan.FromSeconds(30)), "Connection reset event should have been logged");
|
||||
Assert.True(await connectionReset.WaitAsync(TestConstants.DefaultTimeout), "Connection reset event should have been logged");
|
||||
connectionClosing.Release();
|
||||
}
|
||||
|
||||
|
|
@ -523,7 +523,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
|
||||
var token = context.RequestAborted;
|
||||
token.Register(() => requestAborted.Release(2));
|
||||
await requestAborted.WaitAsync().TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
await requestAborted.WaitAsync().TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}));
|
||||
|
||||
using (var host = builder.Build())
|
||||
|
|
@ -536,7 +536,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
socket.Send(Encoding.ASCII.GetBytes("GET / HTTP/1.1\r\nHost:\r\n\r\n"));
|
||||
await appStarted.WaitAsync();
|
||||
socket.Shutdown(SocketShutdown.Send);
|
||||
await requestAborted.WaitAsync().TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
await requestAborted.WaitAsync().TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -620,9 +620,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
"",
|
||||
"4",
|
||||
"Done")
|
||||
.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
|
||||
await Task.WhenAll(pathTcs.Task, rawTargetTcs.Task, queryTcs.Task).TimeoutAfter(TimeSpan.FromSeconds(30));
|
||||
await Task.WhenAll(pathTcs.Task, rawTargetTcs.Task, queryTcs.Task).TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
Assert.Equal(new PathString(expectedPath), pathTcs.Task.Result);
|
||||
Assert.Equal(requestUrl, rawTargetTcs.Task.Result);
|
||||
if (queryValue == null)
|
||||
|
|
@ -648,7 +648,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
}))
|
||||
{
|
||||
var requestId = await HttpClientSlim.GetStringAsync($"http://{server.EndPoint}")
|
||||
.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
Assert.Equal(knownId, requestId);
|
||||
}
|
||||
}
|
||||
|
|
@ -689,7 +689,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
$"Date: {server.Context.DateHeaderValue}",
|
||||
$"Content-Length: {identifierLength}",
|
||||
"",
|
||||
"").TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
"").TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
|
||||
var read = await connection.Reader.ReadAsync(buffer, 0, identifierLength);
|
||||
Assert.Equal(identifierLength, read);
|
||||
|
|
@ -950,7 +950,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
using (var server = new TestServer(async httpContext =>
|
||||
{
|
||||
// This will hang if 0 content length is not assumed by the server
|
||||
Assert.Equal(0, await httpContext.Request.Body.ReadAsync(new byte[1], 0, 1).TimeoutAfter(TimeSpan.FromSeconds(10)));
|
||||
Assert.Equal(0, await httpContext.Request.Body.ReadAsync(new byte[1], 0, 1).TimeoutAfter(TestConstants.DefaultTimeout));
|
||||
}, testContext, listenOptions))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
|
|
@ -1169,7 +1169,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
var read = 0;
|
||||
while (read < message.Length)
|
||||
{
|
||||
read += await duplexStream.ReadAsync(buffer, read, buffer.Length - read).TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
read += await duplexStream.ReadAsync(buffer, read, buffer.Length - read).TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
|
||||
await duplexStream.WriteAsync(buffer, 0, read);
|
||||
|
|
@ -1476,7 +1476,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
"",
|
||||
"a");
|
||||
|
||||
Assert.True(appEvent.Wait(TimeSpan.FromSeconds(10)));
|
||||
Assert.True(appEvent.Wait(TestConstants.DefaultTimeout));
|
||||
|
||||
await Task.Delay(TimeSpan.FromSeconds(5));
|
||||
|
||||
|
|
|
|||
|
|
@ -368,7 +368,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
}
|
||||
}
|
||||
|
||||
var disposedStatusCode = await disposedTcs.Task.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
var disposedStatusCode = await disposedTcs.Task.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
Assert.Equal(expectedServerStatusCode, (HttpStatusCode)disposedStatusCode);
|
||||
}
|
||||
|
||||
|
|
@ -538,7 +538,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
// Wait for message to be logged before disposing the socket.
|
||||
// Disposing the socket will abort the connection and HttpProtocol._requestAborted
|
||||
// might be 1 by the time ProduceEnd() gets called and the message is logged.
|
||||
await logTcs.Task.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
await logTcs.Task.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -578,7 +578,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
"",
|
||||
"hello,");
|
||||
|
||||
await connection.WaitForConnectionClose().TimeoutAfter(TimeSpan.FromSeconds(30));
|
||||
await connection.WaitForConnectionClose().TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -740,10 +740,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
"hello, world");
|
||||
|
||||
// Wait for error message to be logged.
|
||||
await logTcs.Task.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
await logTcs.Task.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
|
||||
// The server should close the connection in this situation.
|
||||
await connection.WaitForConnectionClose().TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
await connection.WaitForConnectionClose().TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -772,7 +772,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
await httpContext.Response.WriteAsync("hello,");
|
||||
|
||||
// Wait until the request is aborted so we know HttpProtocol will skip the response content length check.
|
||||
Assert.True(await requestAborted.WaitAsync(TimeSpan.FromSeconds(10)));
|
||||
Assert.True(await requestAborted.WaitAsync(TestConstants.DefaultTimeout));
|
||||
}, new TestServiceContext { Log = mockTrace.Object }))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
|
|
@ -796,7 +796,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
// Await before disposing the server to prevent races between the
|
||||
// abort triggered by the connection RST and the abort called when
|
||||
// disposing the server.
|
||||
Assert.True(await requestAborted.WaitAsync(TimeSpan.FromSeconds(10)));
|
||||
Assert.True(await requestAborted.WaitAsync(TestConstants.DefaultTimeout));
|
||||
}
|
||||
|
||||
// With the server disposed we know all connections were drained and all messages were logged.
|
||||
|
|
@ -1111,12 +1111,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
|
||||
requestStarted.Wait();
|
||||
connection.Shutdown(SocketShutdown.Send);
|
||||
await connection.WaitForConnectionClose().TimeoutAfter(TimeSpan.FromSeconds(30));
|
||||
await connection.WaitForConnectionClose().TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
|
||||
connectionClosed.Set();
|
||||
|
||||
await tcs.Task.TimeoutAfter(TimeSpan.FromSeconds(30));
|
||||
await tcs.Task.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1150,7 +1150,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
"Transfer-Encoding: chunked",
|
||||
"",
|
||||
"gg");
|
||||
await responseWritten.WaitAsync().TimeoutAfter(TimeSpan.FromSeconds(30));
|
||||
await responseWritten.WaitAsync().TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
await connection.ReceiveEnd(
|
||||
"HTTP/1.1 400 Bad Request",
|
||||
$"Date: {server.Context.DateHeaderValue}",
|
||||
|
|
@ -1706,7 +1706,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
|
||||
using (var server = new TestServer(async httpContext =>
|
||||
{
|
||||
Assert.Equal(0, await httpContext.Request.Body.ReadAsync(new byte[1], 0, 1).TimeoutAfter(TimeSpan.FromSeconds(10)));
|
||||
Assert.Equal(0, await httpContext.Request.Body.ReadAsync(new byte[1], 0, 1).TimeoutAfter(TestConstants.DefaultTimeout));
|
||||
}, testContext, listenOptions))
|
||||
{
|
||||
using (var connection = server.CreateConnection())
|
||||
|
|
@ -2152,7 +2152,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
var lifetime = httpContext.Features.Get<IHttpRequestLifetimeFeature>();
|
||||
|
||||
lifetime.RequestAborted.Register(() => requestAbortedWh.Set());
|
||||
Assert.True(requestAbortedWh.Wait(TimeSpan.FromSeconds(10)));
|
||||
Assert.True(requestAbortedWh.Wait(TestConstants.DefaultTimeout));
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -2176,15 +2176,15 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
"",
|
||||
"");
|
||||
|
||||
Assert.True(requestStartWh.Wait(TimeSpan.FromSeconds(10)));
|
||||
Assert.True(requestStartWh.Wait(TestConstants.DefaultTimeout));
|
||||
}
|
||||
|
||||
// Write failed - can throw TaskCanceledException or OperationCanceledException,
|
||||
// dependending on how far the canceled write goes.
|
||||
await Assert.ThrowsAnyAsync<OperationCanceledException>(async () => await writeTcs.Task).TimeoutAfter(TimeSpan.FromSeconds(15));
|
||||
await Assert.ThrowsAnyAsync<OperationCanceledException>(async () => await writeTcs.Task).TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
|
||||
// RequestAborted tripped
|
||||
Assert.True(requestAbortedWh.Wait(TimeSpan.FromSeconds(1)));
|
||||
Assert.True(requestAbortedWh.Wait(TestConstants.DefaultTimeout));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2342,7 +2342,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
"hello, world");
|
||||
|
||||
// Wait for all callbacks to be called.
|
||||
await onStartingTcs.Task.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
await onStartingTcs.Task.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2394,7 +2394,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
"hello, world");
|
||||
|
||||
// Wait for all callbacks to be called.
|
||||
await onCompletedTcs.Task.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
await onCompletedTcs.Task.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2654,10 +2654,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
|
||||
using (var reader = new StreamReader(sslStream, encoding: Encoding.ASCII, detectEncodingFromByteOrderMarks: false, bufferSize: 1024, leaveOpen: false))
|
||||
{
|
||||
await reader.ReadToEndAsync().TimeoutAfter(TimeSpan.FromSeconds(30));
|
||||
await reader.ReadToEndAsync().TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
|
||||
Assert.True(messageLogged.Wait(TimeSpan.FromSeconds(10)));
|
||||
Assert.True(messageLogged.Wait(TestConstants.DefaultTimeout));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
"");
|
||||
|
||||
await connection.Receive("New protocol data");
|
||||
await upgrade.Task.TimeoutAfter(TimeSpan.FromSeconds(30));
|
||||
await upgrade.Task.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
var stream = await feature.UpgradeAsync();
|
||||
|
||||
var buffer = new byte[128];
|
||||
var read = await context.Request.Body.ReadAsync(buffer, 0, 128).TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
var read = await context.Request.Body.ReadAsync(buffer, 0, 128).TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
Assert.Equal(0, read);
|
||||
|
||||
using (var reader = new StreamReader(stream))
|
||||
|
|
@ -108,7 +108,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
await connection.Send(send + "\r\n");
|
||||
await connection.Receive(recv);
|
||||
|
||||
await upgrade.Task.TimeoutAfter(TimeSpan.FromSeconds(30));
|
||||
await upgrade.Task.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -145,10 +145,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
$"Date: {server.Context.DateHeaderValue}",
|
||||
"",
|
||||
"");
|
||||
await connection.WaitForConnectionClose().TimeoutAfter(TimeSpan.FromSeconds(15));
|
||||
await connection.WaitForConnectionClose().TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
|
||||
var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await upgradeTcs.Task.TimeoutAfter(TimeSpan.FromSeconds(15)));
|
||||
var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await upgradeTcs.Task.TimeoutAfter(TestConstants.DefaultTimeout));
|
||||
Assert.Equal(CoreStrings.UpgradeCannotBeCalledMultipleTimes, ex.Message);
|
||||
}
|
||||
|
||||
|
|
@ -250,7 +250,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
|
|||
}
|
||||
}
|
||||
|
||||
var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await upgradeTcs.Task).TimeoutAfter(TimeSpan.FromSeconds(15));
|
||||
var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await upgradeTcs.Task).TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
Assert.Equal(CoreStrings.CannotUpgradeNonUpgradableRequest, ex.Message);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
|||
}
|
||||
finally
|
||||
{
|
||||
await thread.StopAsync(TimeSpan.FromSeconds(1));
|
||||
await thread.StopAsync(TimeSpan.FromSeconds(5));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
|||
// Now complete the output writer so that the connection closes
|
||||
mockConnectionHandler.Output.Writer.Complete();
|
||||
|
||||
await connectionTask.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
await connectionTask.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
|
||||
// Assert that we don't try to start reading
|
||||
Assert.Null(mockLibuv.AllocCallback);
|
||||
|
|
@ -105,7 +105,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
|||
}
|
||||
finally
|
||||
{
|
||||
await thread.StopAsync(TimeSpan.FromSeconds(1));
|
||||
await thread.StopAsync(TimeSpan.FromSeconds(5));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
|||
// Now complete the output writer and wait for the connection to close
|
||||
mockConnectionHandler.Output.Writer.Complete();
|
||||
|
||||
await connectionTask.TimeoutAfter(TimeSpan.FromSeconds(10));
|
||||
await connectionTask.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
|
||||
// Assert that we don't try to start reading
|
||||
Assert.Null(mockLibuv.AllocCallback);
|
||||
|
|
@ -184,7 +184,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
|||
}
|
||||
finally
|
||||
{
|
||||
await thread.StopAsync(TimeSpan.FromSeconds(1));
|
||||
await thread.StopAsync(TimeSpan.FromSeconds(5));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -219,7 +219,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
|||
}
|
||||
finally
|
||||
{
|
||||
await thread.StopAsync(TimeSpan.FromSeconds(1));
|
||||
await thread.StopAsync(TimeSpan.FromSeconds(5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
|||
|
||||
public void Dispose()
|
||||
{
|
||||
_libuvThread.StopAsync(TimeSpan.FromSeconds(1)).Wait();
|
||||
_libuvThread.StopAsync(TimeSpan.FromSeconds(5)).Wait();
|
||||
_memoryPool.Dispose();
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
|||
var writeTask = outputProducer.WriteDataAsync(buffer);
|
||||
|
||||
// Assert
|
||||
await writeTask.TimeoutAfter(TimeSpan.FromSeconds(5));
|
||||
await writeTask.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
|||
var writeTask = outputProducer.WriteDataAsync(buffer);
|
||||
|
||||
// Assert
|
||||
await writeTask.TimeoutAfter(TimeSpan.FromSeconds(5));
|
||||
await writeTask.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
|
||||
// Cleanup
|
||||
outputProducer.Dispose();
|
||||
|
|
@ -173,7 +173,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
|||
await _libuvThread.PostAsync(cb => cb(0), triggerNextCompleted);
|
||||
|
||||
// Assert
|
||||
await writeTask.TimeoutAfter(TimeSpan.FromSeconds(5));
|
||||
await writeTask.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
|
||||
// Cleanup
|
||||
outputProducer.Dispose();
|
||||
|
|
@ -235,7 +235,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
|||
await _libuvThread.PostAsync(cb => cb(0), triggerNextCompleted);
|
||||
|
||||
// Finishing the first write should allow the second write to pre-complete.
|
||||
await writeTask2.TimeoutAfter(TimeSpan.FromSeconds(5));
|
||||
await writeTask2.TimeoutAfter(TestConstants.DefaultTimeout);
|
||||
|
||||
// Cleanup
|
||||
outputProducer.Dispose();
|
||||
|
|
@ -309,7 +309,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
|||
await _libuvThread.PostAsync(cb => cb(0), triggerNextCompleted);
|
||||
}
|
||||
|
||||
var timeout = TimeSpan.FromSeconds(5);
|
||||
var timeout = TestConstants.DefaultTimeout;
|
||||
|
||||
await writeTask2.TimeoutAfter(timeout);
|
||||
await writeTask3.TimeoutAfter(timeout);
|
||||
|
|
@ -629,7 +629,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
|||
await _libuvThread.PostAsync(cb => cb(0), triggerNextCompleted);
|
||||
}
|
||||
|
||||
var timeout = TimeSpan.FromSeconds(5);
|
||||
var timeout = TestConstants.DefaultTimeout;
|
||||
|
||||
// Assert
|
||||
// Too many bytes are already pre-completed for the third but not the second write to pre-complete.
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
|||
var listenerSecondary = new ListenerSecondary(transportContextSecondary);
|
||||
await listenerSecondary.StartAsync(pipeName, pipeMessage, listenOptions, libuvThreadSecondary);
|
||||
|
||||
var maxWait = Task.Delay(TimeSpan.FromSeconds(30));
|
||||
var maxWait = Task.Delay(TestConstants.DefaultTimeout);
|
||||
// wait for ListenerPrimary.ReadCallback to add the secondary pipe
|
||||
while (listenerPrimary.UvPipeCount == listenerCount)
|
||||
{
|
||||
|
|
@ -85,10 +85,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
|||
Assert.Equal("Primary", await HttpClientSlim.GetStringAsync(address));
|
||||
|
||||
await listenerSecondary.DisposeAsync();
|
||||
await libuvThreadSecondary.StopAsync(TimeSpan.FromSeconds(1));
|
||||
await libuvThreadSecondary.StopAsync(TimeSpan.FromSeconds(5));
|
||||
|
||||
await listenerPrimary.DisposeAsync();
|
||||
await libuvThreadPrimary.StopAsync(TimeSpan.FromSeconds(1));
|
||||
await libuvThreadPrimary.StopAsync(TimeSpan.FromSeconds(5));
|
||||
}
|
||||
|
||||
// https://github.com/aspnet/KestrelHttpServer/issues/1182
|
||||
|
|
@ -191,10 +191,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
|||
Assert.Equal("Primary", await HttpClientSlim.GetStringAsync(address));
|
||||
|
||||
await listenerSecondary.DisposeAsync();
|
||||
await libuvThreadSecondary.StopAsync(TimeSpan.FromSeconds(1));
|
||||
await libuvThreadSecondary.StopAsync(TimeSpan.FromSeconds(5));
|
||||
|
||||
await listenerPrimary.DisposeAsync();
|
||||
await libuvThreadPrimary.StopAsync(TimeSpan.FromSeconds(1));
|
||||
await libuvThreadPrimary.StopAsync(TimeSpan.FromSeconds(5));
|
||||
|
||||
Assert.Equal(1, logger.TotalErrorsLogged);
|
||||
var errorMessage = logger.Messages.First(m => m.LogLevel == LogLevel.Error);
|
||||
|
|
@ -258,10 +258,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
|
|||
Assert.Equal("Primary", await HttpClientSlim.GetStringAsync(address));
|
||||
|
||||
await listenerSecondary.DisposeAsync();
|
||||
await libuvThreadSecondary.StopAsync(TimeSpan.FromSeconds(1));
|
||||
await libuvThreadSecondary.StopAsync(TimeSpan.FromSeconds(5));
|
||||
|
||||
await listenerPrimary.DisposeAsync();
|
||||
await libuvThreadPrimary.StopAsync(TimeSpan.FromSeconds(1));
|
||||
await libuvThreadPrimary.StopAsync(TimeSpan.FromSeconds(5));
|
||||
|
||||
Assert.Equal(1, logger.TotalErrorsLogged);
|
||||
var errorMessage = logger.Messages.First(m => m.LogLevel == LogLevel.Error);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests.TestHelpers
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AspNetCore.Testing
|
||||
{
|
||||
public class TestConstants
|
||||
{
|
||||
public const int EOF = -4095;
|
||||
public static TimeSpan DefaultTimeout = TimeSpan.FromSeconds(30);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue