Call StopAsync before disposing (#6189) (#6866)

This commit is contained in:
John Luo 2019-01-18 18:30:54 -08:00 committed by GitHub
parent a2151cb89a
commit 8c06f04d50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 478 additions and 243 deletions

View File

@ -166,6 +166,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"");
await ReceiveBadRequestResponse(connection, "400 Bad Request", server.Context.DateHeaderValue);
}
await server.StopAsync();
}
Assert.All(TestSink.Writes, w => Assert.InRange(w.LogLevel, LogLevel.Trace, LogLevel.Information));
@ -185,6 +187,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await client.Receive("HTTP/1.1 400");
}
await server.StopAsync();
}
}
@ -206,6 +210,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.SendAll(request);
await ReceiveBadRequestResponse(connection, expectedResponseStatusCode, server.Context.DateHeaderValue, expectedAllowHeader);
}
await server.StopAsync();
}
mockKestrelTrace.Verify(trace => trace.ConnectionBadRequest(It.IsAny<string>(), It.IsAny<BadHttpRequestException>()));

View File

@ -114,6 +114,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Goodbye");
}
await server.StopAsync();
}
}
@ -168,6 +170,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Hello World");
}
await server.StopAsync();
}
}
@ -253,6 +256,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.Send(fullRequest);
await connection.Receive(expectedFullResponse);
}
await server.StopAsync();
}
}
@ -297,6 +302,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -338,6 +344,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -424,6 +431,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.Send(fullRequest);
await connection.Receive(expectedFullResponse);
}
await server.StopAsync();
}
}
@ -467,6 +475,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -511,6 +520,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -615,6 +625,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -662,6 +673,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var badReqEx = await exTcs.Task.TimeoutAfter(TestConstants.DefaultTimeout);
Assert.Equal(RequestRejectionReason.UnexpectedEndOfRequestContent, badReqEx.Reason);
}
await server.StopAsync();
}
}
}

View File

@ -47,6 +47,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -75,6 +76,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Hello World!");
}
await server.StopAsync();
}
}
@ -111,6 +113,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -147,6 +150,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -183,6 +187,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -227,6 +232,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -257,6 +263,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -290,6 +297,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"Hello World!",
"");
}
await server.StopAsync();
}
}
@ -322,6 +330,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -368,6 +377,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -406,6 +416,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
}

View File

@ -43,6 +43,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Hello World!");
}
await server.StopAsync();
}
Assert.Equal(sendString.Length, adapter.BytesRead);
@ -74,6 +75,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Hello World!");
}
await server.StopAsync();
}
}
@ -95,6 +97,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
connection.ShutdownSend();
await connection.WaitForConnectionClose();
}
await server.StopAsync();
}
}
@ -116,6 +119,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
connection.ShutdownSend();
await connection.WaitForConnectionClose();
}
await server.StopAsync();
}
}
@ -162,6 +166,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.WaitForConnectionClose();
}
await server.StopAsync();
}
Assert.Contains(TestApplicationErrorLogger.Messages, m => m.Message.Contains($"Uncaught exception from the {nameof(IConnectionAdapter.OnConnectionAsync)} method of an {nameof(IConnectionAdapter)}."));
@ -197,6 +202,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Hello World!");
}
await server.StopAsync();
}
}

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.
using System;
@ -36,6 +36,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await context.Response.WriteAsync("Hello");
await requestTcs.Task;
}, counter))
{
using (var connection = server.CreateConnection())
{
await connection.SendEmptyGetAsKeepAlive(); ;
@ -44,6 +45,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
requestTcs.TrySetResult(null);
}
await server.StopAsync();
}
await releasedTcs.Task.DefaultTimeout();
}
@ -63,6 +67,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
}
}
}, max: 1))
{
using (var disposables = new DisposableStack<InMemoryConnection>())
{
var upgraded = server.CreateConnection();
@ -91,6 +96,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await rejected.WaitForConnectionClose();
}
}
await server.StopAsync();
}
}
[Fact]
@ -104,6 +111,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await context.Response.WriteAsync("Hello");
await requestTcs.Task;
}, max))
{
using (var disposables = new DisposableStack<InMemoryConnection>())
{
for (var i = 0; i < max; i++)
@ -134,6 +142,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
requestTcs.TrySetResult(null);
}
await server.StopAsync();
}
}
[Fact]
@ -189,6 +199,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await closedTcs.Task.TimeoutAfter(TimeSpan.FromSeconds(120));
Assert.Equal(count, opened);
Assert.Equal(count, closed);
await server.StopAsync();
}
}

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.
using System.Threading.Tasks;
@ -45,6 +45,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
}

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.
using System.Collections.Concurrent;
@ -47,6 +47,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
.DefaultTimeout();
await connection.Receive("HTTP/1.1 200");
}
await server.StopAsync();
}
// capture list here as other tests executing in parallel may log events

View File

@ -67,6 +67,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests.Http2
await WaitForConnectionErrorAsync(reader, ignoreNonGoAwayFrames: false, expectedLastStreamId: 0, expectedErrorCode: Http2ErrorCode.INADEQUATE_SECURITY);
reader.Complete();
}
await server.StopAsync();
}
}

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.
using System;
@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
{
public class HttpConnectionManagerTests : LoggedTest
{
// This test causes MemoryPoolBlocks to be finalized which in turn causes an assert failure in debug builds.
// This test causes MemoryPoolBlocks to be finalized which in turn causes an assert failure in debug builds.
#if !DEBUG
[ConditionalFact]
[NoDebuggerCondition]
@ -69,6 +69,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
}
Assert.True(logWaitAttempts < 10);
await server.StopAsync();
}
}
#endif

View File

@ -70,6 +70,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.Send(request);
await connection.Receive(expectedResponse);
}
await server.StopAsync();
}
}
@ -88,6 +89,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
{
await connection.WaitForConnectionClose();
}
await server.StopAsync();
}
Assert.Single(TestApplicationErrorLogger.Messages, message => message.LogLevel == LogLevel.Error

View File

@ -50,6 +50,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
validateCertificate: false);
Assert.Equal("content=Hello+World%3F", result);
await server.StopAsync();
}
}
@ -81,6 +82,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
{
var result = await server.HttpClientSlim.GetStringAsync($"https://localhost:{server.Port}/", validateCertificate: false);
Assert.Equal("hello world", result);
await server.StopAsync();
}
}
@ -104,6 +106,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
{
await Assert.ThrowsAnyAsync<Exception>(
() => server.HttpClientSlim.GetStringAsync($"https://localhost:{server.Port}/"));
await server.StopAsync();
}
}
@ -132,6 +135,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
{
var result = await server.HttpClientSlim.GetStringAsync($"https://localhost:{server.Port}/", validateCertificate: false);
Assert.Equal("hello world", result);
await server.StopAsync();
}
}
@ -165,6 +169,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);
Assert.True(stream.RemoteCertificate.Equals(_x509Certificate2));
}
await server.StopAsync();
}
}
@ -207,6 +212,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
Assert.True(stream.RemoteCertificate.Equals(_x509Certificate2));
Assert.Equal(1, selectorCalled);
}
await server.StopAsync();
}
}
@ -263,6 +269,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
Assert.True(stream.RemoteCertificate.Equals(_x509Certificate2NoExt));
Assert.Equal(2, selectorCalled);
}
await server.StopAsync();
}
}
@ -296,6 +303,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false));
Assert.Equal(1, selectorCalled);
}
await server.StopAsync();
}
}
@ -339,6 +347,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
Assert.True(stream.RemoteCertificate.Equals(_x509Certificate2));
Assert.Equal(1, selectorCalled);
}
await server.StopAsync();
}
}
@ -372,6 +381,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false));
Assert.Equal(1, selectorCalled);
}
await server.StopAsync();
}
}
@ -412,6 +422,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);
await AssertConnectionResult(stream, true);
}
await server.StopAsync();
}
}
@ -430,6 +441,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
{
var result = await server.HttpClientSlim.GetStringAsync($"https://localhost:{server.Port}/", validateCertificate: false);
Assert.Equal("https", result);
await server.StopAsync();
}
}
@ -460,6 +472,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var ex = await Assert.ThrowsAsync<IOException>(
async () => await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls, false));
}
await server.StopAsync();
}
}
@ -497,6 +510,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await AssertConnectionResult(stream, true);
Assert.True(clientCertificateValidationCalled);
}
await server.StopAsync();
}
}
@ -526,6 +540,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);
await AssertConnectionResult(stream, false);
}
await server.StopAsync();
}
}
@ -554,6 +569,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);
await AssertConnectionResult(stream, false);
}
await server.StopAsync();
}
}
@ -594,6 +610,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);
await AssertConnectionResult(stream, true);
}
await server.StopAsync();
}
}

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.
using System;
@ -133,6 +133,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
}
await loggerProvider.FilterLogger.LogTcs.Task.DefaultTimeout();
await server.StopAsync();
}
Assert.Equal(1, loggerProvider.FilterLogger.LastEventId.Id);
@ -161,6 +162,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
}
await loggerProvider.FilterLogger.LogTcs.Task.DefaultTimeout();
await server.StopAsync();
}
Assert.Equal(1, loggerProvider.FilterLogger.LastEventId.Id);
@ -210,6 +212,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await sslStream.ReadAsync(new byte[32], 0, 32);
}
await server.StopAsync();
}
Assert.False(loggerProvider.ErrorLogger.ObjectDisposedExceptionLogged);
@ -279,6 +282,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
enabledSslProtocols: SslProtocols.Tls11 | SslProtocols.Tls12,
checkCertificateRevocation: false);
}
await server.StopAsync();
}
Assert.False(loggerProvider.ErrorLogger.ObjectDisposedExceptionLogged);
@ -286,7 +290,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
// Regression test for https://github.com/aspnet/KestrelHttpServer/pull/1197
[Fact]
public void ConnectionFilterDoesNotLeakBlock()
public async Task ConnectionFilterDoesNotLeakBlock()
{
var loggerProvider = new HandshakeErrorLoggerProvider();
LoggerFactory.AddProvider(loggerProvider);
@ -302,6 +306,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
{
connection.Reset();
}
await server.StopAsync();
}
}
@ -342,6 +347,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
Assert.Equal(0, await connection.Stream.ReadAsync(new byte[1], 0, 1).DefaultTimeout());
}
await server.StopAsync();
}
await loggerProvider.FilterLogger.LogTcs.Task.DefaultTimeout();
@ -371,6 +377,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
enabledSslProtocols: SslProtocols.Tls,
checkCertificateRevocation: false));
}
await server.StopAsync();
}
await loggerProvider.FilterLogger.LogTcs.Task.DefaultTimeout();

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.
using System;
@ -30,6 +30,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var heartbeatManager = new HeartbeatManager(testContext.ConnectionManager);
using (var server = CreateServer(testContext))
{
using (var connection = server.CreateConnection())
{
await connection.Send(
@ -45,6 +46,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.WaitForConnectionClose();
}
await server.StopAsync();
}
}
[Fact]
@ -54,6 +57,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var heartbeatManager = new HeartbeatManager(testContext.ConnectionManager);
using (var server = CreateServer(testContext))
{
using (var connection = server.CreateConnection())
{
for (var i = 0; i < 10; i++)
@ -70,6 +74,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
heartbeatManager.OnHeartbeat(testContext.SystemClock.UtcNow);
}
}
await server.StopAsync();
}
}
[Fact]
@ -79,6 +85,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var heartbeatManager = new HeartbeatManager(testContext.ConnectionManager);
using (var server = CreateServer(testContext))
{
using (var connection = server.CreateConnection())
{
await connection.Send(
@ -107,6 +114,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"");
await ReceiveResponse(connection, testContext);
}
await server.StopAsync();
}
}
[Fact]
@ -117,6 +126,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var cts = new CancellationTokenSource();
using (var server = CreateServer(testContext, longRunningCt: cts.Token))
{
using (var connection = server.CreateConnection())
{
await connection.Send(
@ -144,6 +154,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"");
await ReceiveResponse(connection, testContext);
}
await server.StopAsync();
}
}
[Fact]
@ -153,6 +165,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var heartbeatManager = new HeartbeatManager(testContext.ConnectionManager);
using (var server = CreateServer(testContext))
{
using (var connection = server.CreateConnection())
{
// Min amount of time between requests that triggers a keep-alive timeout.
@ -161,6 +174,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.WaitForConnectionClose();
}
await server.StopAsync();
}
}
[Fact]
@ -171,6 +186,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var cts = new CancellationTokenSource();
using (var server = CreateServer(testContext, upgradeCt: cts.Token))
{
using (var connection = server.CreateConnection())
{
await connection.Send(
@ -196,6 +212,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.Receive("hello, world");
}
await server.StopAsync();
}
}
private TestServer CreateServer(TestServiceContext context, CancellationToken longRunningCt = default, CancellationToken upgradeCt = default)

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.
using System.Threading.Tasks;
@ -28,6 +28,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
listenOptions.UseHttps(TestResources.GetTestCertificate());
listenOptions.UseConnectionLogging();
}))
{
{
var response = await server.HttpClientSlim.GetStringAsync($"https://localhost:{server.Port}/", validateCertificate: false)
.DefaultTimeout();
@ -35,6 +36,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
Assert.Equal("Hello World!", response);
}
await server.StopAsync();
}
}
}
}

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.
using System;
@ -48,6 +48,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
Assert.NotNull(requestRejectedEx);
@ -94,6 +95,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
Assert.NotNull(requestRejectedEx);
@ -137,6 +139,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"A");
}
await server.StopAsync();
}
}
@ -169,6 +172,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -209,6 +213,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
Assert.NotNull(invalidOpEx);
@ -248,6 +253,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"");
await connection.ReceiveEnd();
}
await server.StopAsync();
}
Assert.NotNull(invalidOpEx);
@ -287,6 +293,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
Assert.NotNull(requestRejectedEx1);
@ -334,6 +341,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
Assert.NotNull(requestRejectedEx);
@ -379,6 +387,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -447,6 +456,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
Assert.NotNull(requestRejectedEx);
@ -486,6 +496,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
Assert.NotNull(requestRejectedEx1);

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.
using System.Threading.Tasks;
@ -44,6 +44,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -67,6 +68,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.
using System;
@ -88,6 +88,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -133,6 +134,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
Assert.Contains(TestSink.Writes, w => w.EventId.Id == 32 && w.LogLevel == LogLevel.Information);
@ -206,6 +208,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"hello, world");
}
await server.StopAsync();
}
}
}

View File

@ -43,6 +43,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -75,6 +76,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -98,6 +100,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -122,6 +125,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}

View File

@ -29,6 +29,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var heartbeatManager = new HeartbeatManager(testContext.ConnectionManager);
using (var server = CreateServer(testContext))
{
using (var connection = server.CreateConnection())
{
await connection.Send(
@ -41,6 +42,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await ReceiveTimeoutResponse(connection, testContext);
}
await server.StopAsync();
}
}
[Fact]
@ -50,6 +53,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var heartbeatManager = new HeartbeatManager(testContext.ConnectionManager);
using (var server = CreateServer(testContext))
{
using (var connection = server.CreateConnection())
{
await connection.Send(
@ -68,6 +72,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await ReceiveResponse(connection, testContext);
}
await server.StopAsync();
}
}
[Theory]
@ -79,6 +85,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var heartbeatManager = new HeartbeatManager(testContext.ConnectionManager);
using (var server = CreateServer(testContext))
{
using (var connection = server.CreateConnection())
{
await connection.Send(requestLine);
@ -89,6 +96,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await ReceiveTimeoutResponse(connection, testContext);
}
await server.StopAsync();
}
}
[Fact]
@ -101,6 +110,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
testContext.ServerOptions.Limits.MinResponseDataRate = null;
using (var server = CreateServer(testContext))
{
using (var connection = server.CreateConnection())
{
foreach (var ch in "POST / HTTP/1.1\r\nHost:\r\n\r\n")
@ -115,6 +125,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.WaitForConnectionClose();
}
await server.StopAsync();
}
}
private TestServer CreateServer(TestServiceContext context)

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.
using System.Threading.Tasks;
@ -42,6 +42,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Hello World");
}
await server.StopAsync();
}
}
@ -87,6 +88,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Hello World");
}
await server.StopAsync();
}
}
@ -126,6 +128,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Hello World");
}
await server.StopAsync();
}
}
}

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.
using System;
@ -53,6 +53,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
Assert.False(requestBodyPersisted);
Assert.False(responseBodyPersisted);
await server.StopAsync();
}
}
@ -121,6 +123,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Read cancelled");
}
await server.StopAsync();
}
}
@ -155,6 +158,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
Assert.True(dataRead);
@ -226,6 +230,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
Assert.Equal(queryValue, queryTcs.Task.Result["q"]);
}
}
await server.StopAsync();
}
}
@ -241,6 +246,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
{
var requestId = await server.HttpClientSlim.GetStringAsync($"http://localhost:{server.Port}/");
Assert.Equal(knownId, requestId);
await server.StopAsync();
}
}
@ -297,6 +303,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
usedIds.Add(id);
}
}
await server.StopAsync();
}
}
@ -331,6 +338,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Goodbye");
}
await server.StopAsync();
}
}
@ -371,6 +379,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Hello World");
}
await server.StopAsync();
}
}
@ -405,6 +414,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Goodbye");
}
await server.StopAsync();
}
}
@ -444,6 +454,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Goodbye");
}
await server.StopAsync();
}
}
@ -500,6 +511,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Goodbye");
}
await server.StopAsync();
}
}
@ -532,6 +544,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Hello World");
}
await server.StopAsync();
}
}
@ -581,6 +594,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -610,6 +624,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
connection.ShutdownSend();
await connection.ReceiveEnd();
}
await server.StopAsync();
}
}
@ -660,6 +675,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -697,6 +713,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
message);
}
await server.StopAsync();
}
}
@ -773,6 +790,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
Assert.Equal(1, streamCount);
Assert.Equal(1, requestHeadersCount);
Assert.Equal(1, responseHeadersCount);
await server.StopAsync();
}
}
@ -791,6 +809,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.Receive("HTTP/1.1 200 OK");
}
await server.StopAsync();
}
}
@ -832,6 +851,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -880,6 +900,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -906,6 +927,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -938,6 +960,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"goodbye");
}
await server.StopAsync();
}
}
@ -998,6 +1021,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"hello");
}
await server.StopAsync();
}
}
@ -1073,6 +1097,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Hello2");
}
await server.StopAsync();
}
}
@ -1117,6 +1142,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.
using System;
@ -79,6 +79,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
Assert.Single(TestApplicationErrorLogger.Messages, w => w.EventId.Id == 28 && w.LogLevel == LogLevel.Information);
}
await server.StopAsync();
}
}
}

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.
using System;
@ -62,6 +62,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await onCompletedTcs.Task.DefaultTimeout();
Assert.False(onStartingCalled);
}
await server.StopAsync();
}
}
@ -97,6 +98,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
Assert.NotNull(ex);
}
await server.StopAsync();
}
}
@ -164,6 +166,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await Assert.ThrowsAsync<OperationCanceledException>(() => appTcs.Task).DefaultTimeout();
}
await server.StopAsync();
}
}
@ -289,6 +292,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -326,6 +330,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
}
delayTcs.SetResult(null);
await server.StopAsync();
}
}
@ -359,6 +364,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
await onCompletedTcs.Task.DefaultTimeout();
@ -391,6 +397,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
Assert.NotNull(readException);
@ -428,6 +435,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -456,6 +464,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -480,6 +489,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -518,6 +528,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
// might be 1 by the time ProduceEnd() gets called and the message is logged.
await logTcs.Task.DefaultTimeout();
}
await server.StopAsync();
}
mockKestrelTrace.Verify(kestrelTrace =>
@ -556,6 +567,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.WaitForConnectionClose();
}
await server.StopAsync();
}
var logMessage = Assert.Single(TestApplicationErrorLogger.Messages, message => message.LogLevel == LogLevel.Error);
@ -592,6 +604,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"hello,");
}
await server.StopAsync();
}
var logMessage = Assert.Single(TestApplicationErrorLogger.Messages, message => message.LogLevel == LogLevel.Error);
@ -631,6 +644,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
var logMessage = Assert.Single(TestApplicationErrorLogger.Messages, message => message.LogLevel == LogLevel.Error);
@ -666,6 +680,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
var logMessage = Assert.Single(TestApplicationErrorLogger.Messages, message => message.LogLevel == LogLevel.Error);
@ -717,6 +732,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
// The server should close the connection in this situation.
await connection.WaitForConnectionClose();
}
await server.StopAsync();
}
mockTrace.Verify(trace =>
@ -769,6 +785,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
// abort triggered by the connection RST and the abort called when
// disposing the server.
await requestAborted.Task.DefaultTimeout();
await server.StopAsync();
}
// With the server disposed we know all connections were drained and all messages were logged.
@ -807,6 +824,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
var error = TestApplicationErrorLogger.Messages.Where(message => message.LogLevel == LogLevel.Error);
@ -845,6 +863,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
Assert.Empty(TestApplicationErrorLogger.Messages.Where(message => message.LogLevel == LogLevel.Error));
@ -881,6 +900,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"hello, world");
}
await server.StopAsync();
}
Assert.Empty(TestApplicationErrorLogger.Messages.Where(message => message.LogLevel == LogLevel.Error));
@ -917,6 +937,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"hello, world");
}
await server.StopAsync();
}
Assert.Empty(TestApplicationErrorLogger.Messages.Where(message => message.LogLevel == LogLevel.Error));
@ -945,6 +966,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -976,6 +998,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
flushed.SetResult(null);
}
await server.StopAsync();
}
}
@ -1009,6 +1032,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
flushed.SetResult(null);
}
await server.StopAsync();
}
}
@ -1043,6 +1067,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.Receive("hello, world");
}
await server.StopAsync();
}
}
@ -1084,6 +1109,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
expectedResponse);
}
await server.StopAsync();
}
}
@ -1129,6 +1155,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"hello, world");
}
await server.StopAsync();
}
}
@ -1175,6 +1202,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"hello, world");
}
await server.StopAsync();
}
}
@ -1218,6 +1246,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"hello, world");
}
await server.StopAsync();
}
}
@ -1261,6 +1290,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -1307,6 +1337,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -1347,6 +1378,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -1390,6 +1422,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -1427,6 +1460,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -1455,6 +1489,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
Assert.Contains(TestApplicationErrorLogger.Messages, w => w.EventId.Id == 17 && w.LogLevel == LogLevel.Information && w.Exception is BadHttpRequestException
@ -1525,6 +1560,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.ReceiveEnd();
}
await server.StopAsync();
}
Assert.True(foundMessage, "Expected log not found");
@ -1568,6 +1604,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
Assert.Contains(TestApplicationErrorLogger.Messages, w => w.EventId.Id == 17 && w.LogLevel == LogLevel.Information && w.Exception is BadHttpRequestException
@ -1618,6 +1655,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -1642,6 +1680,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Hello World");
}
await server.StopAsync();
}
}
@ -1674,6 +1713,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -1718,6 +1758,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -1741,6 +1782,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -1797,6 +1839,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -1843,6 +1886,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"hello, world");
}
await server.StopAsync();
}
}
@ -1890,6 +1934,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
Assert.False(onStartingCalled);
@ -1946,6 +1991,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
// The first registered OnStarting callback should have been called,
@ -1996,6 +2042,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Hello World");
}
await server.StopAsync();
}
// All OnCompleted callbacks should be called even if they throw.
@ -2039,6 +2086,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Hello World");
}
await server.StopAsync();
}
Assert.True(onStartingCalled);
@ -2080,6 +2128,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Hello");
}
await server.StopAsync();
}
Assert.True(onStartingCalled);
@ -2113,6 +2162,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Hello World");
}
await server.StopAsync();
}
Assert.Empty(TestApplicationErrorLogger.Messages.Where(message => message.LogLevel == LogLevel.Error));
@ -2138,6 +2188,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"");
await connection.ReceiveEnd();
}
await server.StopAsync();
}
}
@ -2188,6 +2239,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -2236,6 +2288,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
// Wait for all callbacks to be called.
await onStartingTcs.Task.DefaultTimeout();
}
await server.StopAsync();
}
Assert.Equal(1, callOrder.Pop());
@ -2287,6 +2340,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
// Wait for all callbacks to be called.
await onCompletedTcs.Task.DefaultTimeout();
}
await server.StopAsync();
}
Assert.Equal(1, callOrder.Pop());
@ -2341,6 +2395,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Hello2");
}
await server.StopAsync();
}
}
@ -2380,6 +2435,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"Hello!");
}
await server.StopAsync();
}
}
@ -2409,6 +2465,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
@ -2495,6 +2552,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var disposedStatusCode = await disposedTcs.Task.DefaultTimeout();
Assert.Equal(expectedServerStatusCode, (HttpStatusCode)disposedStatusCode);
await server.StopAsync();
}
if (sendMalformedRequest)

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.
using System;
@ -90,7 +90,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests.TestTrans
});
_host = hostBuilder.Build();
_host.Start();
}

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.
using System;
@ -50,6 +50,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.Receive("New protocol data");
await upgrade.Task.DefaultTimeout();
}
await server.StopAsync();
}
}
@ -104,6 +105,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await upgrade.Task.DefaultTimeout();
}
await server.StopAsync();
}
}
@ -131,6 +133,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await Task.Delay(100);
}
}, new TestServiceContext(LoggerFactory)))
{
using (var connection = server.CreateConnection())
{
await connection.SendEmptyGetWithUpgrade();
@ -141,6 +144,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"");
await connection.WaitForConnectionClose();
}
await server.StopAsync();
}
var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await upgradeTcs.Task.DefaultTimeout());
Assert.Equal(CoreStrings.UpgradeCannotBeCalledMultipleTimes, ex.Message);
@ -150,6 +155,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
public async Task RejectsRequestWithContentLengthAndUpgrade()
{
using (var server = new TestServer(context => Task.CompletedTask, new TestServiceContext(LoggerFactory)))
{
using (var connection = server.CreateConnection())
{
await connection.Send("POST / HTTP/1.1",
@ -167,6 +173,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
[Fact]
@ -190,6 +198,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.SendEmptyGetWithUpgrade();
await connection.Receive("HTTP/1.1 200 OK");
}
await server.StopAsync();
}
}
@ -197,6 +206,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
public async Task RejectsRequestWithChunkedEncodingAndUpgrade()
{
using (var server = new TestServer(context => Task.CompletedTask, new TestServiceContext(LoggerFactory)))
{
using (var connection = server.CreateConnection())
{
await connection.Send("POST / HTTP/1.1",
@ -213,6 +223,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"",
"");
}
await server.StopAsync();
}
}
[Fact]
@ -242,6 +254,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.SendEmptyGet();
await connection.Receive("HTTP/1.1 200 OK");
}
await server.StopAsync();
}
var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await upgradeTcs.Task).DefaultTimeout();
@ -293,6 +306,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.Receive("HTTP/1.1 200");
}
}
await server.StopAsync();
}
var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => await upgradeTcs.Task.TimeoutAfter(TimeSpan.FromSeconds(60)));
@ -333,6 +347,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
}
await appCompletedTcs.Task.DefaultTimeout();
await server.StopAsync();
}
}
}