[Kestrel] Deflake app abort test (#25484)
* [Kestrel] Deflake app abort test * better * fb
This commit is contained in:
parent
f7a76173e4
commit
83e31342a1
|
|
@ -2555,24 +2555,27 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/24164")]
|
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/24164")]
|
||||||
|
[Repeat(100)]
|
||||||
public async Task AppAbortViaIConnectionLifetimeFeatureIsLogged()
|
public async Task AppAbortViaIConnectionLifetimeFeatureIsLogged()
|
||||||
{
|
{
|
||||||
var testContext = new TestServiceContext(LoggerFactory);
|
var testContext = new TestServiceContext(LoggerFactory);
|
||||||
|
|
||||||
await using (var server = new TestServer(httpContext =>
|
var closeTaskTcs = new TaskCompletionSource<Task>(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
|
|
||||||
|
await using (var server = new TestServer(async httpContext =>
|
||||||
{
|
{
|
||||||
|
var closeTask = await closeTaskTcs.Task.DefaultTimeout();
|
||||||
var feature = httpContext.Features.Get<IConnectionLifetimeFeature>();
|
var feature = httpContext.Features.Get<IConnectionLifetimeFeature>();
|
||||||
feature.Abort();
|
feature.Abort();
|
||||||
|
|
||||||
// Ensure the response doesn't get flush before the abort is observed.
|
// Ensure the response doesn't get flush before the abort is observed.
|
||||||
var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
await closeTask;
|
||||||
feature.ConnectionClosed.Register(() => tcs.TrySetResult());
|
|
||||||
|
|
||||||
return tcs.Task;
|
|
||||||
}, testContext))
|
}, testContext))
|
||||||
{
|
{
|
||||||
using (var connection = server.CreateConnection())
|
using (var connection = server.CreateConnection())
|
||||||
{
|
{
|
||||||
|
closeTaskTcs.SetResult(connection.TransportConnection.WaitForCloseTask);
|
||||||
|
|
||||||
await connection.Send(
|
await connection.Send(
|
||||||
"GET / HTTP/1.1",
|
"GET / HTTP/1.1",
|
||||||
"Host:",
|
"Host:",
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,8 @@ namespace System.Buffers
|
||||||
{
|
{
|
||||||
SetAllBlocksReturned();
|
SetAllBlocksReturned();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_pool.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue