Make sure read is async first before cancelling. (#9832)
This commit is contained in:
parent
caf4374f83
commit
ba1f86d5bf
|
|
@ -138,7 +138,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
}
|
||||
|
||||
[ConditionalFact]
|
||||
public async Task WriterThrowsCancelledException()
|
||||
public async Task WriterThrowsCanceledException()
|
||||
{
|
||||
var requestStartedCompletionSource = CreateTaskCompletionSource();
|
||||
var requestCompletedCompletionSource = CreateTaskCompletionSource();
|
||||
|
|
@ -179,10 +179,10 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
}
|
||||
|
||||
[ConditionalFact]
|
||||
[Flaky("https://github.com/aspnet/AspNetCore-Internal/issues/1798", FlakyOn.All)]
|
||||
public async Task ReaderThrowsCancelledException()
|
||||
[Repeat]
|
||||
public async Task ReaderThrowsCanceledException()
|
||||
{
|
||||
var requestStartedCompletionSource = CreateTaskCompletionSource();
|
||||
var readIsAsyncCompletionSource = CreateTaskCompletionSource();
|
||||
var requestCompletedCompletionSource = CreateTaskCompletionSource();
|
||||
|
||||
Exception exception = null;
|
||||
|
|
@ -191,10 +191,11 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
var data = new byte[1024];
|
||||
using (var testServer = await TestServer.Create(async ctx =>
|
||||
{
|
||||
requestStartedCompletionSource.SetResult(true);
|
||||
try
|
||||
{
|
||||
await ctx.Request.Body.ReadAsync(data, cancellationTokenSource.Token);
|
||||
var task = ctx.Request.Body.ReadAsync(data, cancellationTokenSource.Token);
|
||||
readIsAsyncCompletionSource.SetResult(true);
|
||||
await task;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
@ -207,7 +208,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
|||
using (var connection = testServer.CreateConnection())
|
||||
{
|
||||
await SendContentLength1Post(connection);
|
||||
await requestStartedCompletionSource.Task.DefaultTimeout();
|
||||
await readIsAsyncCompletionSource.Task.DefaultTimeout();
|
||||
cancellationTokenSource.Cancel();
|
||||
await requestCompletedCompletionSource.Task.DefaultTimeout();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue