Call StopAsync before disposing (#6189)

This commit is contained in:
David Fowler 2018-12-30 01:36:30 -04:00 committed by GitHub
parent b12c33dbc3
commit 010c1f0c9f
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 ReceiveBadRequestResponse(connection, "400 Bad Request", server.Context.DateHeaderValue);
} }
await server.StopAsync();
} }
Assert.All(TestSink.Writes, w => Assert.InRange(w.LogLevel, LogLevel.Trace, LogLevel.Information)); 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 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 connection.SendAll(request);
await ReceiveBadRequestResponse(connection, expectedResponseStatusCode, server.Context.DateHeaderValue, expectedAllowHeader); await ReceiveBadRequestResponse(connection, expectedResponseStatusCode, server.Context.DateHeaderValue, expectedAllowHeader);
} }
await server.StopAsync();
} }
mockKestrelTrace.Verify(trace => trace.ConnectionBadRequest(It.IsAny<string>(), It.IsAny<BadHttpRequestException>())); 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"); "Goodbye");
} }
await server.StopAsync();
} }
} }
@ -168,6 +170,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"Hello World"); "Hello World");
} }
await server.StopAsync();
} }
} }
@ -253,6 +256,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.Send(fullRequest); await connection.Send(fullRequest);
await connection.Receive(expectedFullResponse); 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.Send(fullRequest);
await connection.Receive(expectedFullResponse); 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); var badReqEx = await exTcs.Task.TimeoutAfter(TestConstants.DefaultTimeout);
Assert.Equal(RequestRejectionReason.UnexpectedEndOfRequestContent, badReqEx.Reason); 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!"); "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!", "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!"); "Hello World!");
} }
await server.StopAsync();
} }
Assert.Equal(sendString.Length, adapter.BytesRead); Assert.Equal(sendString.Length, adapter.BytesRead);
@ -74,6 +75,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"Hello World!"); "Hello World!");
} }
await server.StopAsync();
} }
} }
@ -95,6 +97,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
connection.ShutdownSend(); connection.ShutdownSend();
await connection.WaitForConnectionClose(); await connection.WaitForConnectionClose();
} }
await server.StopAsync();
} }
} }
@ -116,6 +119,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
connection.ShutdownSend(); connection.ShutdownSend();
await connection.WaitForConnectionClose(); await connection.WaitForConnectionClose();
} }
await server.StopAsync();
} }
} }
@ -162,6 +166,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.WaitForConnectionClose(); 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)}.")); 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!"); "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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
@ -36,6 +36,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await context.Response.WriteAsync("Hello"); await context.Response.WriteAsync("Hello");
await requestTcs.Task; await requestTcs.Task;
}, counter)) }, counter))
{
using (var connection = server.CreateConnection()) using (var connection = server.CreateConnection())
{ {
await connection.SendEmptyGetAsKeepAlive(); ; await connection.SendEmptyGetAsKeepAlive(); ;
@ -44,6 +45,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
requestTcs.TrySetResult(null); requestTcs.TrySetResult(null);
} }
await server.StopAsync();
}
await releasedTcs.Task.DefaultTimeout(); await releasedTcs.Task.DefaultTimeout();
} }
@ -63,6 +67,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
} }
} }
}, max: 1)) }, max: 1))
{
using (var disposables = new DisposableStack<InMemoryConnection>()) using (var disposables = new DisposableStack<InMemoryConnection>())
{ {
var upgraded = server.CreateConnection(); var upgraded = server.CreateConnection();
@ -91,6 +96,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await rejected.WaitForConnectionClose(); await rejected.WaitForConnectionClose();
} }
} }
await server.StopAsync();
}
} }
[Fact] [Fact]
@ -104,6 +111,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await context.Response.WriteAsync("Hello"); await context.Response.WriteAsync("Hello");
await requestTcs.Task; await requestTcs.Task;
}, max)) }, max))
{
using (var disposables = new DisposableStack<InMemoryConnection>()) using (var disposables = new DisposableStack<InMemoryConnection>())
{ {
for (var i = 0; i < max; i++) for (var i = 0; i < max; i++)
@ -134,6 +142,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
requestTcs.TrySetResult(null); requestTcs.TrySetResult(null);
} }
await server.StopAsync();
}
} }
[Fact] [Fact]
@ -189,6 +199,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await closedTcs.Task.TimeoutAfter(TimeSpan.FromSeconds(120)); await closedTcs.Task.TimeoutAfter(TimeSpan.FromSeconds(120));
Assert.Equal(count, opened); Assert.Equal(count, opened);
Assert.Equal(count, closed); 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading.Tasks; 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Concurrent; using System.Collections.Concurrent;
@ -47,6 +47,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
.DefaultTimeout(); .DefaultTimeout();
await connection.Receive("HTTP/1.1 200"); await connection.Receive("HTTP/1.1 200");
} }
await server.StopAsync();
} }
// capture list here as other tests executing in parallel may log events // capture list here as other tests executing in parallel may log events

View File

@ -65,6 +65,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests.Http2
await WaitForConnectionErrorAsync(reader, ignoreNonGoAwayFrames: false, expectedLastStreamId: 0, expectedErrorCode: Http2ErrorCode.INADEQUATE_SECURITY); await WaitForConnectionErrorAsync(reader, ignoreNonGoAwayFrames: false, expectedLastStreamId: 0, expectedErrorCode: Http2ErrorCode.INADEQUATE_SECURITY);
reader.Complete(); 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
{ {
public class HttpConnectionManagerTests : LoggedTest 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 #if !DEBUG
[ConditionalFact] [ConditionalFact]
[NoDebuggerCondition] [NoDebuggerCondition]
@ -69,6 +69,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
} }
Assert.True(logWaitAttempts < 10); Assert.True(logWaitAttempts < 10);
await server.StopAsync();
} }
} }
#endif #endif

View File

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

View File

@ -50,6 +50,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
validateCertificate: false); validateCertificate: false);
Assert.Equal("content=Hello+World%3F", result); 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); var result = await server.HttpClientSlim.GetStringAsync($"https://localhost:{server.Port}/", validateCertificate: false);
Assert.Equal("hello world", result); Assert.Equal("hello world", result);
await server.StopAsync();
} }
} }
@ -104,6 +106,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
{ {
await Assert.ThrowsAnyAsync<Exception>( await Assert.ThrowsAnyAsync<Exception>(
() => server.HttpClientSlim.GetStringAsync($"https://localhost:{server.Port}/")); () => 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); var result = await server.HttpClientSlim.GetStringAsync($"https://localhost:{server.Port}/", validateCertificate: false);
Assert.Equal("hello world", result); 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); await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);
Assert.True(stream.RemoteCertificate.Equals(_x509Certificate2)); Assert.True(stream.RemoteCertificate.Equals(_x509Certificate2));
} }
await server.StopAsync();
} }
} }
@ -201,6 +206,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
Assert.True(stream.RemoteCertificate.Equals(_x509Certificate2)); Assert.True(stream.RemoteCertificate.Equals(_x509Certificate2));
Assert.Equal(1, selectorCalled); Assert.Equal(1, selectorCalled);
} }
await server.StopAsync();
} }
} }
@ -251,6 +257,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
Assert.True(stream.RemoteCertificate.Equals(_x509Certificate2NoExt)); Assert.True(stream.RemoteCertificate.Equals(_x509Certificate2NoExt));
Assert.Equal(2, selectorCalled); Assert.Equal(2, selectorCalled);
} }
await server.StopAsync();
} }
} }
@ -284,6 +291,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false)); stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false));
Assert.Equal(1, selectorCalled); Assert.Equal(1, selectorCalled);
} }
await server.StopAsync();
} }
} }
@ -321,6 +329,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
Assert.True(stream.RemoteCertificate.Equals(_x509Certificate2)); Assert.True(stream.RemoteCertificate.Equals(_x509Certificate2));
Assert.Equal(1, selectorCalled); Assert.Equal(1, selectorCalled);
} }
await server.StopAsync();
} }
} }
@ -354,6 +363,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false)); stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false));
Assert.Equal(1, selectorCalled); Assert.Equal(1, selectorCalled);
} }
await server.StopAsync();
} }
} }
@ -394,6 +404,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false); await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);
await AssertConnectionResult(stream, true); await AssertConnectionResult(stream, true);
} }
await server.StopAsync();
} }
} }
@ -412,6 +423,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
{ {
var result = await server.HttpClientSlim.GetStringAsync($"https://localhost:{server.Port}/", validateCertificate: false); var result = await server.HttpClientSlim.GetStringAsync($"https://localhost:{server.Port}/", validateCertificate: false);
Assert.Equal("https", result); Assert.Equal("https", result);
await server.StopAsync();
} }
} }
@ -442,6 +454,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var ex = await Assert.ThrowsAsync<IOException>( var ex = await Assert.ThrowsAsync<IOException>(
async () => await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls, false)); async () => await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls, false));
} }
await server.StopAsync();
} }
} }
@ -479,6 +492,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await AssertConnectionResult(stream, true); await AssertConnectionResult(stream, true);
Assert.True(clientCertificateValidationCalled); Assert.True(clientCertificateValidationCalled);
} }
await server.StopAsync();
} }
} }
@ -508,6 +522,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false); await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);
await AssertConnectionResult(stream, false); await AssertConnectionResult(stream, false);
} }
await server.StopAsync();
} }
} }
@ -536,6 +551,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false); await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);
await AssertConnectionResult(stream, false); await AssertConnectionResult(stream, false);
} }
await server.StopAsync();
} }
} }
@ -576,6 +592,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false); await stream.AuthenticateAsClientAsync("localhost", new X509CertificateCollection(), SslProtocols.Tls12 | SslProtocols.Tls11, false);
await AssertConnectionResult(stream, true); 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
@ -134,6 +134,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
} }
await loggerProvider.FilterLogger.LogTcs.Task.DefaultTimeout(); await loggerProvider.FilterLogger.LogTcs.Task.DefaultTimeout();
await server.StopAsync();
} }
Assert.Equal(1, loggerProvider.FilterLogger.LastEventId.Id); Assert.Equal(1, loggerProvider.FilterLogger.LastEventId.Id);
@ -162,6 +163,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
} }
await loggerProvider.FilterLogger.LogTcs.Task.DefaultTimeout(); await loggerProvider.FilterLogger.LogTcs.Task.DefaultTimeout();
await server.StopAsync();
} }
Assert.Equal(1, loggerProvider.FilterLogger.LastEventId.Id); Assert.Equal(1, loggerProvider.FilterLogger.LastEventId.Id);
@ -211,6 +213,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await sslStream.ReadAsync(new byte[32], 0, 32); await sslStream.ReadAsync(new byte[32], 0, 32);
} }
await server.StopAsync();
} }
Assert.False(loggerProvider.ErrorLogger.ObjectDisposedExceptionLogged); Assert.False(loggerProvider.ErrorLogger.ObjectDisposedExceptionLogged);
@ -280,6 +283,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
enabledSslProtocols: SslProtocols.Tls11 | SslProtocols.Tls12, enabledSslProtocols: SslProtocols.Tls11 | SslProtocols.Tls12,
checkCertificateRevocation: false); checkCertificateRevocation: false);
} }
await server.StopAsync();
} }
Assert.False(loggerProvider.ErrorLogger.ObjectDisposedExceptionLogged); Assert.False(loggerProvider.ErrorLogger.ObjectDisposedExceptionLogged);
@ -287,7 +291,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
// Regression test for https://github.com/aspnet/KestrelHttpServer/pull/1197 // Regression test for https://github.com/aspnet/KestrelHttpServer/pull/1197
[Fact] [Fact]
public void ConnectionFilterDoesNotLeakBlock() public async Task ConnectionFilterDoesNotLeakBlock()
{ {
var loggerProvider = new HandshakeErrorLoggerProvider(); var loggerProvider = new HandshakeErrorLoggerProvider();
LoggerFactory.AddProvider(loggerProvider); LoggerFactory.AddProvider(loggerProvider);
@ -303,6 +307,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
{ {
connection.Reset(); connection.Reset();
} }
await server.StopAsync();
} }
} }
@ -343,6 +348,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
Assert.Equal(0, await connection.Stream.ReadAsync(new byte[1], 0, 1).DefaultTimeout()); Assert.Equal(0, await connection.Stream.ReadAsync(new byte[1], 0, 1).DefaultTimeout());
} }
await server.StopAsync();
} }
await loggerProvider.FilterLogger.LogTcs.Task.DefaultTimeout(); await loggerProvider.FilterLogger.LogTcs.Task.DefaultTimeout();
@ -372,6 +378,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
enabledSslProtocols: SslProtocols.Tls, enabledSslProtocols: SslProtocols.Tls,
checkCertificateRevocation: false)); checkCertificateRevocation: false));
} }
await server.StopAsync();
} }
await loggerProvider.FilterLogger.LogTcs.Task.DefaultTimeout(); 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
@ -30,6 +30,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var heartbeatManager = new HeartbeatManager(testContext.ConnectionManager); var heartbeatManager = new HeartbeatManager(testContext.ConnectionManager);
using (var server = CreateServer(testContext)) using (var server = CreateServer(testContext))
{
using (var connection = server.CreateConnection()) using (var connection = server.CreateConnection())
{ {
await connection.Send( await connection.Send(
@ -45,6 +46,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.WaitForConnectionClose(); await connection.WaitForConnectionClose();
} }
await server.StopAsync();
}
} }
[Fact] [Fact]
@ -54,6 +57,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var heartbeatManager = new HeartbeatManager(testContext.ConnectionManager); var heartbeatManager = new HeartbeatManager(testContext.ConnectionManager);
using (var server = CreateServer(testContext)) using (var server = CreateServer(testContext))
{
using (var connection = server.CreateConnection()) using (var connection = server.CreateConnection())
{ {
for (var i = 0; i < 10; i++) for (var i = 0; i < 10; i++)
@ -70,6 +74,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
heartbeatManager.OnHeartbeat(testContext.SystemClock.UtcNow); heartbeatManager.OnHeartbeat(testContext.SystemClock.UtcNow);
} }
} }
await server.StopAsync();
}
} }
[Fact] [Fact]
@ -79,6 +85,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var heartbeatManager = new HeartbeatManager(testContext.ConnectionManager); var heartbeatManager = new HeartbeatManager(testContext.ConnectionManager);
using (var server = CreateServer(testContext)) using (var server = CreateServer(testContext))
{
using (var connection = server.CreateConnection()) using (var connection = server.CreateConnection())
{ {
await connection.Send( await connection.Send(
@ -107,6 +114,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
""); "");
await ReceiveResponse(connection, testContext); await ReceiveResponse(connection, testContext);
} }
await server.StopAsync();
}
} }
[Fact] [Fact]
@ -117,6 +126,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var cts = new CancellationTokenSource(); var cts = new CancellationTokenSource();
using (var server = CreateServer(testContext, longRunningCt: cts.Token)) using (var server = CreateServer(testContext, longRunningCt: cts.Token))
{
using (var connection = server.CreateConnection()) using (var connection = server.CreateConnection())
{ {
await connection.Send( await connection.Send(
@ -144,6 +154,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
""); "");
await ReceiveResponse(connection, testContext); await ReceiveResponse(connection, testContext);
} }
await server.StopAsync();
}
} }
[Fact] [Fact]
@ -153,6 +165,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var heartbeatManager = new HeartbeatManager(testContext.ConnectionManager); var heartbeatManager = new HeartbeatManager(testContext.ConnectionManager);
using (var server = CreateServer(testContext)) using (var server = CreateServer(testContext))
{
using (var connection = server.CreateConnection()) using (var connection = server.CreateConnection())
{ {
// Min amount of time between requests that triggers a keep-alive timeout. // 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 connection.WaitForConnectionClose();
} }
await server.StopAsync();
}
} }
[Fact] [Fact]
@ -171,6 +186,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var cts = new CancellationTokenSource(); var cts = new CancellationTokenSource();
using (var server = CreateServer(testContext, upgradeCt: cts.Token)) using (var server = CreateServer(testContext, upgradeCt: cts.Token))
{
using (var connection = server.CreateConnection()) using (var connection = server.CreateConnection())
{ {
await connection.Send( await connection.Send(
@ -196,6 +212,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.Receive("hello, world"); await connection.Receive("hello, world");
} }
await server.StopAsync();
}
} }
private TestServer CreateServer(TestServiceContext context, CancellationToken longRunningCt = default, CancellationToken upgradeCt = default) 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading.Tasks; using System.Threading.Tasks;
@ -28,6 +28,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
listenOptions.UseHttps(TestResources.GetTestCertificate()); listenOptions.UseHttps(TestResources.GetTestCertificate());
listenOptions.UseConnectionLogging(); listenOptions.UseConnectionLogging();
})) }))
{
{ {
var response = await server.HttpClientSlim.GetStringAsync($"https://localhost:{server.Port}/", validateCertificate: false) var response = await server.HttpClientSlim.GetStringAsync($"https://localhost:{server.Port}/", validateCertificate: false)
.DefaultTimeout(); .DefaultTimeout();
@ -35,6 +36,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
Assert.Equal("Hello World!", response); 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
@ -48,6 +48,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
Assert.NotNull(requestRejectedEx); Assert.NotNull(requestRejectedEx);
@ -94,6 +95,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
Assert.NotNull(requestRejectedEx); Assert.NotNull(requestRejectedEx);
@ -137,6 +139,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"A"); "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); Assert.NotNull(invalidOpEx);
@ -248,6 +253,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
""); "");
await connection.ReceiveEnd(); await connection.ReceiveEnd();
} }
await server.StopAsync();
} }
Assert.NotNull(invalidOpEx); Assert.NotNull(invalidOpEx);
@ -287,6 +293,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
Assert.NotNull(requestRejectedEx1); Assert.NotNull(requestRejectedEx1);
@ -334,6 +341,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
Assert.NotNull(requestRejectedEx); 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); Assert.NotNull(requestRejectedEx);
@ -486,6 +496,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
Assert.NotNull(requestRejectedEx1); 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading.Tasks; 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; 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); 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"); "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); var heartbeatManager = new HeartbeatManager(testContext.ConnectionManager);
using (var server = CreateServer(testContext)) using (var server = CreateServer(testContext))
{
using (var connection = server.CreateConnection()) using (var connection = server.CreateConnection())
{ {
await connection.Send( await connection.Send(
@ -41,6 +42,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await ReceiveTimeoutResponse(connection, testContext); await ReceiveTimeoutResponse(connection, testContext);
} }
await server.StopAsync();
}
} }
[Fact] [Fact]
@ -50,6 +53,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var heartbeatManager = new HeartbeatManager(testContext.ConnectionManager); var heartbeatManager = new HeartbeatManager(testContext.ConnectionManager);
using (var server = CreateServer(testContext)) using (var server = CreateServer(testContext))
{
using (var connection = server.CreateConnection()) using (var connection = server.CreateConnection())
{ {
await connection.Send( await connection.Send(
@ -68,6 +72,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await ReceiveResponse(connection, testContext); await ReceiveResponse(connection, testContext);
} }
await server.StopAsync();
}
} }
[Theory] [Theory]
@ -79,6 +85,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var heartbeatManager = new HeartbeatManager(testContext.ConnectionManager); var heartbeatManager = new HeartbeatManager(testContext.ConnectionManager);
using (var server = CreateServer(testContext)) using (var server = CreateServer(testContext))
{
using (var connection = server.CreateConnection()) using (var connection = server.CreateConnection())
{ {
await connection.Send(requestLine); await connection.Send(requestLine);
@ -89,6 +96,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await ReceiveTimeoutResponse(connection, testContext); await ReceiveTimeoutResponse(connection, testContext);
} }
await server.StopAsync();
}
} }
[Fact] [Fact]
@ -101,6 +110,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
testContext.ServerOptions.Limits.MinResponseDataRate = null; testContext.ServerOptions.Limits.MinResponseDataRate = null;
using (var server = CreateServer(testContext)) using (var server = CreateServer(testContext))
{
using (var connection = server.CreateConnection()) using (var connection = server.CreateConnection())
{ {
foreach (var ch in "POST / HTTP/1.1\r\nHost:\r\n\r\n") 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 connection.WaitForConnectionClose();
} }
await server.StopAsync();
}
} }
private TestServer CreateServer(TestServiceContext context) 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading.Tasks; using System.Threading.Tasks;
@ -42,6 +42,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"Hello World"); "Hello World");
} }
await server.StopAsync();
} }
} }
@ -87,6 +88,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"Hello World"); "Hello World");
} }
await server.StopAsync();
} }
} }
@ -126,6 +128,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"Hello World"); "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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
@ -53,6 +53,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
Assert.False(requestBodyPersisted); Assert.False(requestBodyPersisted);
Assert.False(responseBodyPersisted); Assert.False(responseBodyPersisted);
await server.StopAsync();
} }
} }
@ -119,6 +121,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"Read cancelled"); "Read cancelled");
} }
await server.StopAsync();
} }
} }
@ -153,6 +156,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
Assert.True(dataRead); Assert.True(dataRead);
@ -224,6 +228,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
Assert.Equal(queryValue, queryTcs.Task.Result["q"]); Assert.Equal(queryValue, queryTcs.Task.Result["q"]);
} }
} }
await server.StopAsync();
} }
} }
@ -239,6 +244,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
{ {
var requestId = await server.HttpClientSlim.GetStringAsync($"http://localhost:{server.Port}/"); var requestId = await server.HttpClientSlim.GetStringAsync($"http://localhost:{server.Port}/");
Assert.Equal(knownId, requestId); Assert.Equal(knownId, requestId);
await server.StopAsync();
} }
} }
@ -295,6 +301,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
usedIds.Add(id); usedIds.Add(id);
} }
} }
await server.StopAsync();
} }
} }
@ -329,6 +336,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"Goodbye"); "Goodbye");
} }
await server.StopAsync();
} }
} }
@ -369,6 +377,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"Hello World"); "Hello World");
} }
await server.StopAsync();
} }
} }
@ -403,6 +412,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"Goodbye"); "Goodbye");
} }
await server.StopAsync();
} }
} }
@ -442,6 +452,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"Goodbye"); "Goodbye");
} }
await server.StopAsync();
} }
} }
@ -498,6 +509,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"Goodbye"); "Goodbye");
} }
await server.StopAsync();
} }
} }
@ -530,6 +542,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"Hello World"); "Hello World");
} }
await server.StopAsync();
} }
} }
@ -579,6 +592,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -608,6 +622,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
connection.ShutdownSend(); connection.ShutdownSend();
await connection.ReceiveEnd(); await connection.ReceiveEnd();
} }
await server.StopAsync();
} }
} }
@ -658,6 +673,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -695,6 +711,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
message); message);
} }
await server.StopAsync();
} }
} }
@ -771,6 +788,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
Assert.Equal(1, streamCount); Assert.Equal(1, streamCount);
Assert.Equal(1, requestHeadersCount); Assert.Equal(1, requestHeadersCount);
Assert.Equal(1, responseHeadersCount); Assert.Equal(1, responseHeadersCount);
await server.StopAsync();
} }
} }
@ -789,6 +807,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.Receive("HTTP/1.1 200 OK"); await connection.Receive("HTTP/1.1 200 OK");
} }
await server.StopAsync();
} }
} }
@ -830,6 +849,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -878,6 +898,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -904,6 +925,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -936,6 +958,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"goodbye"); "goodbye");
} }
await server.StopAsync();
} }
} }
@ -996,6 +1019,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"hello"); "hello");
} }
await server.StopAsync();
} }
} }
@ -1071,6 +1095,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"Hello2"); "Hello2");
} }
await server.StopAsync();
} }
} }
@ -1115,6 +1140,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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; 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); 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
@ -62,6 +62,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await onCompletedTcs.Task.DefaultTimeout(); await onCompletedTcs.Task.DefaultTimeout();
Assert.False(onStartingCalled); Assert.False(onStartingCalled);
} }
await server.StopAsync();
} }
} }
@ -97,6 +98,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
Assert.NotNull(ex); Assert.NotNull(ex);
} }
await server.StopAsync();
} }
} }
@ -154,6 +156,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await Assert.ThrowsAsync<OperationCanceledException>(() => appTcs.Task).DefaultTimeout(); await Assert.ThrowsAsync<OperationCanceledException>(() => appTcs.Task).DefaultTimeout();
} }
await server.StopAsync();
} }
} }
@ -279,6 +282,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -316,6 +320,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
} }
delayTcs.SetResult(null); delayTcs.SetResult(null);
await server.StopAsync();
} }
} }
@ -349,6 +354,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
await onCompletedTcs.Task.DefaultTimeout(); await onCompletedTcs.Task.DefaultTimeout();
@ -381,6 +387,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
Assert.NotNull(readException); Assert.NotNull(readException);
@ -418,6 +425,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -446,6 +454,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -470,6 +479,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -508,6 +518,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
// might be 1 by the time ProduceEnd() gets called and the message is logged. // might be 1 by the time ProduceEnd() gets called and the message is logged.
await logTcs.Task.DefaultTimeout(); await logTcs.Task.DefaultTimeout();
} }
await server.StopAsync();
} }
mockKestrelTrace.Verify(kestrelTrace => mockKestrelTrace.Verify(kestrelTrace =>
@ -546,6 +557,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.WaitForConnectionClose(); await connection.WaitForConnectionClose();
} }
await server.StopAsync();
} }
var logMessage = Assert.Single(TestApplicationErrorLogger.Messages, message => message.LogLevel == LogLevel.Error); var logMessage = Assert.Single(TestApplicationErrorLogger.Messages, message => message.LogLevel == LogLevel.Error);
@ -582,6 +594,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"hello,"); "hello,");
} }
await server.StopAsync();
} }
var logMessage = Assert.Single(TestApplicationErrorLogger.Messages, message => message.LogLevel == LogLevel.Error); var logMessage = Assert.Single(TestApplicationErrorLogger.Messages, message => message.LogLevel == LogLevel.Error);
@ -621,6 +634,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
var logMessage = Assert.Single(TestApplicationErrorLogger.Messages, message => message.LogLevel == LogLevel.Error); var logMessage = Assert.Single(TestApplicationErrorLogger.Messages, message => message.LogLevel == LogLevel.Error);
@ -656,6 +670,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
var logMessage = Assert.Single(TestApplicationErrorLogger.Messages, message => message.LogLevel == LogLevel.Error); var logMessage = Assert.Single(TestApplicationErrorLogger.Messages, message => message.LogLevel == LogLevel.Error);
@ -707,6 +722,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
// The server should close the connection in this situation. // The server should close the connection in this situation.
await connection.WaitForConnectionClose(); await connection.WaitForConnectionClose();
} }
await server.StopAsync();
} }
mockTrace.Verify(trace => mockTrace.Verify(trace =>
@ -759,6 +775,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
// abort triggered by the connection RST and the abort called when // abort triggered by the connection RST and the abort called when
// disposing the server. // disposing the server.
await requestAborted.Task.DefaultTimeout(); await requestAborted.Task.DefaultTimeout();
await server.StopAsync();
} }
// With the server disposed we know all connections were drained and all messages were logged. // With the server disposed we know all connections were drained and all messages were logged.
@ -797,6 +814,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
var error = TestApplicationErrorLogger.Messages.Where(message => message.LogLevel == LogLevel.Error); var error = TestApplicationErrorLogger.Messages.Where(message => message.LogLevel == LogLevel.Error);
@ -835,6 +853,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
Assert.Empty(TestApplicationErrorLogger.Messages.Where(message => message.LogLevel == LogLevel.Error)); Assert.Empty(TestApplicationErrorLogger.Messages.Where(message => message.LogLevel == LogLevel.Error));
@ -871,6 +890,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"hello, world"); "hello, world");
} }
await server.StopAsync();
} }
Assert.Empty(TestApplicationErrorLogger.Messages.Where(message => message.LogLevel == LogLevel.Error)); Assert.Empty(TestApplicationErrorLogger.Messages.Where(message => message.LogLevel == LogLevel.Error));
@ -907,6 +927,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"hello, world"); "hello, world");
} }
await server.StopAsync();
} }
Assert.Empty(TestApplicationErrorLogger.Messages.Where(message => message.LogLevel == LogLevel.Error)); Assert.Empty(TestApplicationErrorLogger.Messages.Where(message => message.LogLevel == LogLevel.Error));
@ -935,6 +956,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -966,6 +988,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
flushed.SetResult(null); flushed.SetResult(null);
} }
await server.StopAsync();
} }
} }
@ -999,6 +1022,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
flushed.SetResult(null); flushed.SetResult(null);
} }
await server.StopAsync();
} }
} }
@ -1033,6 +1057,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.Receive("hello, world"); await connection.Receive("hello, world");
} }
await server.StopAsync();
} }
} }
@ -1074,6 +1099,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
expectedResponse); expectedResponse);
} }
await server.StopAsync();
} }
} }
@ -1119,6 +1145,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"hello, world"); "hello, world");
} }
await server.StopAsync();
} }
} }
@ -1165,6 +1192,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"hello, world"); "hello, world");
} }
await server.StopAsync();
} }
} }
@ -1208,6 +1236,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"hello, world"); "hello, world");
} }
await server.StopAsync();
} }
} }
@ -1251,6 +1280,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -1297,6 +1327,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -1337,6 +1368,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -1380,6 +1412,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -1417,6 +1450,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -1445,6 +1479,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 Assert.Contains(TestApplicationErrorLogger.Messages, w => w.EventId.Id == 17 && w.LogLevel == LogLevel.Information && w.Exception is BadHttpRequestException
@ -1515,6 +1550,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.ReceiveEnd(); await connection.ReceiveEnd();
} }
await server.StopAsync();
} }
Assert.True(foundMessage, "Expected log not found"); Assert.True(foundMessage, "Expected log not found");
@ -1558,6 +1594,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 Assert.Contains(TestApplicationErrorLogger.Messages, w => w.EventId.Id == 17 && w.LogLevel == LogLevel.Information && w.Exception is BadHttpRequestException
@ -1608,6 +1645,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -1632,6 +1670,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"Hello World"); "Hello World");
} }
await server.StopAsync();
} }
} }
@ -1664,6 +1703,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -1708,6 +1748,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -1731,6 +1772,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -1787,6 +1829,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -1833,6 +1876,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"hello, world"); "hello, world");
} }
await server.StopAsync();
} }
} }
@ -1880,6 +1924,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
Assert.False(onStartingCalled); Assert.False(onStartingCalled);
@ -1936,6 +1981,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
// The first registered OnStarting callback should have been called, // The first registered OnStarting callback should have been called,
@ -1986,6 +2032,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"Hello World"); "Hello World");
} }
await server.StopAsync();
} }
// All OnCompleted callbacks should be called even if they throw. // All OnCompleted callbacks should be called even if they throw.
@ -2029,6 +2076,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"Hello World"); "Hello World");
} }
await server.StopAsync();
} }
Assert.True(onStartingCalled); Assert.True(onStartingCalled);
@ -2070,6 +2118,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"Hello"); "Hello");
} }
await server.StopAsync();
} }
Assert.True(onStartingCalled); Assert.True(onStartingCalled);
@ -2103,6 +2152,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"Hello World"); "Hello World");
} }
await server.StopAsync();
} }
Assert.Empty(TestApplicationErrorLogger.Messages.Where(message => message.LogLevel == LogLevel.Error)); Assert.Empty(TestApplicationErrorLogger.Messages.Where(message => message.LogLevel == LogLevel.Error));
@ -2128,6 +2178,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
""); "");
await connection.ReceiveEnd(); await connection.ReceiveEnd();
} }
await server.StopAsync();
} }
} }
@ -2178,6 +2229,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -2226,6 +2278,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
// Wait for all callbacks to be called. // Wait for all callbacks to be called.
await onStartingTcs.Task.DefaultTimeout(); await onStartingTcs.Task.DefaultTimeout();
} }
await server.StopAsync();
} }
Assert.Equal(1, callOrder.Pop()); Assert.Equal(1, callOrder.Pop());
@ -2277,6 +2330,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
// Wait for all callbacks to be called. // Wait for all callbacks to be called.
await onCompletedTcs.Task.DefaultTimeout(); await onCompletedTcs.Task.DefaultTimeout();
} }
await server.StopAsync();
} }
Assert.Equal(1, callOrder.Pop()); Assert.Equal(1, callOrder.Pop());
@ -2331,6 +2385,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"Hello2"); "Hello2");
} }
await server.StopAsync();
} }
} }
@ -2370,6 +2425,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
"Hello!"); "Hello!");
} }
await server.StopAsync();
} }
} }
@ -2399,6 +2455,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
} }
} }
@ -2485,6 +2542,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
var disposedStatusCode = await disposedTcs.Task.DefaultTimeout(); var disposedStatusCode = await disposedTcs.Task.DefaultTimeout();
Assert.Equal(expectedServerStatusCode, (HttpStatusCode)disposedStatusCode); Assert.Equal(expectedServerStatusCode, (HttpStatusCode)disposedStatusCode);
await server.StopAsync();
} }
if (sendMalformedRequest) 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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
@ -90,7 +90,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests.TestTrans
}); });
_host = hostBuilder.Build(); _host = hostBuilder.Build();
_host.Start(); _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. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System; using System;
@ -50,6 +50,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.Receive("New protocol data"); await connection.Receive("New protocol data");
await upgrade.Task.DefaultTimeout(); await upgrade.Task.DefaultTimeout();
} }
await server.StopAsync();
} }
} }
@ -104,6 +105,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await upgrade.Task.DefaultTimeout(); await upgrade.Task.DefaultTimeout();
} }
await server.StopAsync();
} }
} }
@ -131,6 +133,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await Task.Delay(100); await Task.Delay(100);
} }
}, new TestServiceContext(LoggerFactory))) }, new TestServiceContext(LoggerFactory)))
{
using (var connection = server.CreateConnection()) using (var connection = server.CreateConnection())
{ {
await connection.SendEmptyGetWithUpgrade(); await connection.SendEmptyGetWithUpgrade();
@ -141,6 +144,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
""); "");
await connection.WaitForConnectionClose(); await connection.WaitForConnectionClose();
} }
await server.StopAsync();
}
var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await upgradeTcs.Task.DefaultTimeout()); var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await upgradeTcs.Task.DefaultTimeout());
Assert.Equal(CoreStrings.UpgradeCannotBeCalledMultipleTimes, ex.Message); Assert.Equal(CoreStrings.UpgradeCannotBeCalledMultipleTimes, ex.Message);
@ -150,6 +155,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
public async Task RejectsRequestWithContentLengthAndUpgrade() public async Task RejectsRequestWithContentLengthAndUpgrade()
{ {
using (var server = new TestServer(context => Task.CompletedTask, new TestServiceContext(LoggerFactory))) using (var server = new TestServer(context => Task.CompletedTask, new TestServiceContext(LoggerFactory)))
{
using (var connection = server.CreateConnection()) using (var connection = server.CreateConnection())
{ {
await connection.Send("POST / HTTP/1.1", await connection.Send("POST / HTTP/1.1",
@ -167,6 +173,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
}
} }
[Fact] [Fact]
@ -190,6 +198,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.SendEmptyGetWithUpgrade(); await connection.SendEmptyGetWithUpgrade();
await connection.Receive("HTTP/1.1 200 OK"); 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() public async Task RejectsRequestWithChunkedEncodingAndUpgrade()
{ {
using (var server = new TestServer(context => Task.CompletedTask, new TestServiceContext(LoggerFactory))) using (var server = new TestServer(context => Task.CompletedTask, new TestServiceContext(LoggerFactory)))
{
using (var connection = server.CreateConnection()) using (var connection = server.CreateConnection())
{ {
await connection.Send("POST / HTTP/1.1", await connection.Send("POST / HTTP/1.1",
@ -213,6 +223,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
"", "",
""); "");
} }
await server.StopAsync();
}
} }
[Fact] [Fact]
@ -242,6 +254,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
await connection.SendEmptyGet(); await connection.SendEmptyGet();
await connection.Receive("HTTP/1.1 200 OK"); await connection.Receive("HTTP/1.1 200 OK");
} }
await server.StopAsync();
} }
var ex = await Assert.ThrowsAsync<InvalidOperationException>(async () => await upgradeTcs.Task).DefaultTimeout(); 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 connection.Receive("HTTP/1.1 200");
} }
} }
await server.StopAsync();
} }
var exception = await Assert.ThrowsAsync<InvalidOperationException>(async () => await upgradeTcs.Task.TimeoutAfter(TimeSpan.FromSeconds(60))); 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 appCompletedTcs.Task.DefaultTimeout();
await server.StopAsync();
} }
} }
} }