Skip to content

Commit 555e460

Browse files
authored
Fix flaky AbortedStream test in Kestrel (#8010)
1 parent 896c027 commit 555e460

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2TestBase.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
2626
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
2727
using Microsoft.AspNetCore.Testing;
28+
using Microsoft.Extensions.Logging;
2829
using Microsoft.Net.Http.Headers;
2930
using Moq;
3031
using Xunit;
@@ -177,7 +178,11 @@ public Http2TestBase()
177178
_mockConnectionContext.Setup(c => c.Abort(It.IsAny<ConnectionAbortedException>())).Callback<ConnectionAbortedException>(ex =>
178179
{
179180
// Emulate transport abort so the _connectionTask completes.
180-
Task.Run(() => _pair.Application.Output.Complete(ex));
181+
Task.Run(() =>
182+
{
183+
TestApplicationErrorLogger.LogInformation(0, ex, "ConnectionContext.Abort() was called. Completing _pair.Application.Output.");
184+
_pair.Application.Output.Complete(ex);
185+
});
181186
});
182187

183188
_noopApplication = context => Task.CompletedTask;

src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2TimeoutTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ public async Task ResponseDrain_SlowerThanMinimumDataRate_AbortsConnection()
198198
[InlineData(Http2FrameType.CONTINUATION)]
199199
public async Task AbortedStream_ResetsAndDrainsRequest_RefusesFramesAfterCooldownExpires(Http2FrameType finalFrameType)
200200
{
201+
// Remove callback that completes _pair.Application.Output on abort.
202+
_mockConnectionContext.Reset();
203+
201204
var mockSystemClock = _serviceContext.MockSystemClock;
202205

203206
var headers = new[]

0 commit comments

Comments
 (0)