Wait for server connection to end (#11256)

This commit is contained in:
David Fowler 2019-06-17 17:42:16 +02:00 committed by GitHub
parent ab52a1d3ed
commit b47b3e5ac6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -37,6 +37,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
try
{
var serverConnectionCompletedTcs = new TaskCompletionSource<object>(TaskContinuationOptions.RunContinuationsAsynchronously);
async Task EchoServer(ConnectionContext connection)
{
// For graceful shutdown
@ -63,6 +65,10 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
{
Logger.LogDebug("Graceful shutdown triggered for {connectionId}.", connection.ConnectionId);
}
finally
{
serverConnectionCompletedTcs.TrySetResult(null);
}
}
var hostBuilder = TransportSelector.GetWebHostBuilder()
@ -97,6 +103,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
Assert.Equal(data, buffer);
}
// Wait for the server to complete the loop because of the FIN
await serverConnectionCompletedTcs.Task.DefaultTimeout();
await host.StopAsync();
}
}