Fix flaky AbortedStream test in Kestrel (#8010)
This commit is contained in:
parent
896c027010
commit
555e460c15
|
|
@ -25,6 +25,7 @@ using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.HPack;
|
|||
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
|
||||
using Microsoft.AspNetCore.Testing;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
|
@ -177,7 +178,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
_mockConnectionContext.Setup(c => c.Abort(It.IsAny<ConnectionAbortedException>())).Callback<ConnectionAbortedException>(ex =>
|
||||
{
|
||||
// Emulate transport abort so the _connectionTask completes.
|
||||
Task.Run(() => _pair.Application.Output.Complete(ex));
|
||||
Task.Run(() =>
|
||||
{
|
||||
TestApplicationErrorLogger.LogInformation(0, ex, "ConnectionContext.Abort() was called. Completing _pair.Application.Output.");
|
||||
_pair.Application.Output.Complete(ex);
|
||||
});
|
||||
});
|
||||
|
||||
_noopApplication = context => Task.CompletedTask;
|
||||
|
|
|
|||
|
|
@ -198,6 +198,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
|
|||
[InlineData(Http2FrameType.CONTINUATION)]
|
||||
public async Task AbortedStream_ResetsAndDrainsRequest_RefusesFramesAfterCooldownExpires(Http2FrameType finalFrameType)
|
||||
{
|
||||
// Remove callback that completes _pair.Application.Output on abort.
|
||||
_mockConnectionContext.Reset();
|
||||
|
||||
var mockSystemClock = _serviceContext.MockSystemClock;
|
||||
|
||||
var headers = new[]
|
||||
|
|
|
|||
Loading…
Reference in New Issue