Fix flakiness in RequestsCanBeAbortedMidRead (#4881)

Addresses aspnet/AspNetCore-Internal#1521
This commit is contained in:
Stephen Halter 2018-12-14 16:26:54 -08:00 committed by GitHub
parent 68f0aff144
commit 019ba081d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -1206,7 +1206,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
}
}
await Assert.ThrowsAsync<TaskCanceledException>(async () => await readTcs.Task);
var thrownEx = await Assert.ThrowsAnyAsync<Exception>(async () => await readTcs.Task);
// https://github.com/aspnet/AspNetCore-Internal/issues/1521
// In more recent versions of Kestrel, we expect this to always be a TaskCanceledException,
// but without the changes in https://github.com/aspnet/KestrelHttpServer/pull/2844, this is flaky.
Assert.True(thrownEx is TaskCanceledException || thrownEx is IOException, $"{thrownEx} is neither a TaskCanceledException nor IOException.");
// The cancellation token for only the last request should be triggered.
var abortedRequestId = await registrationTcs.Task;