This commit is contained in:
John Luo 2017-10-23 14:27:19 -07:00
Родитель d3398b3ccf
Коммит 99fc843cc5
5 изменённых файлов: 23 добавлений и 24 удалений

Просмотреть файл

@ -176,7 +176,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
}
}
[ConditionalFact(Skip = "https://github.com/aspnet/HttpSysServer/issues/263")]
[ConditionalFact]
public async Task ResponseBody_WriteContentLengthNotEnoughWritten_Aborts()
{
string address;
@ -193,7 +193,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
}
}
[ConditionalFact(Skip = "https://github.com/aspnet/HttpSysServer/issues/263")]
[ConditionalFact]
public async Task ResponseBody_WriteContentLengthTooMuchWritten_Throws()
{
string address;
@ -305,7 +305,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
}
}
[ConditionalFact(Skip = "https://github.com/aspnet/HttpSysServer/issues/263")]
[ConditionalFact]
public async Task ResponseBodyWriteExceptions_FirstWriteAsyncWithCanceledCancellationToken_CancelsAndAborts()
{
string address;
@ -370,7 +370,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
}
}
[ConditionalFact(Skip = "https://github.com/aspnet/HttpSysServer/issues/263")]
[ConditionalFact]
public async Task ResponseBodyWriteExceptions_SecondWriteAsyncWithCanceledCancellationToken_CancelsAndAborts()
{
string address;
@ -392,7 +392,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
}
}
[ConditionalFact(Skip = "https://github.com/aspnet/HttpSysServer/issues/263")]
[ConditionalFact]
public async Task ResponseBody_SecondWriteAsyncWithCanceledCancellationToken_CancelsAndAborts()
{
string address;
@ -432,7 +432,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
Assert.Throws<IOException>(() =>
{
// It can take several tries before Write notices the disconnect.
for (int i = 0; i < 1000; i++)
for (int i = 0; i < Utilities.WriteRetryLimit; i++)
{
context.Response.Body.Write(new byte[1000], 0, 1000);
}
@ -464,7 +464,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
await Assert.ThrowsAsync<IOException>(async () =>
{
// It can take several tries before Write notices the disconnect.
for (int i = 0; i < 1000; i++)
for (int i = 0; i < Utilities.WriteRetryLimit; i++)
{
await context.Response.Body.WriteAsync(new byte[1000], 0, 1000);
}
@ -492,7 +492,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
await Assert.ThrowsAsync<TaskCanceledException>(() => responseTask);
Assert.True(context.DisconnectToken.WaitHandle.WaitOne(TimeSpan.FromSeconds(5)));
// It can take several tries before Write notices the disconnect.
for (int i = 0; i < 100; i++)
for (int i = 0; i < Utilities.WriteRetryLimit; i++)
{
context.Response.Body.Write(new byte[1000], 0, 1000);
}
@ -515,7 +515,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
await Assert.ThrowsAsync<TaskCanceledException>(() => responseTask);
Assert.True(context.DisconnectToken.WaitHandle.WaitOne(TimeSpan.FromSeconds(5)));
// It can take several tries before Write notices the disconnect.
for (int i = 0; i < 100; i++)
for (int i = 0; i < Utilities.WriteRetryLimit; i++)
{
await context.Response.Body.WriteAsync(new byte[1000], 0, 1000);
}
@ -523,7 +523,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
}
}
[ConditionalFact(Skip = "https://github.com/aspnet/HttpSysServer/issues/263")]
[ConditionalFact]
public async Task ResponseBodyWriteExceptions_ClientDisconnectsBeforeSecondWrite_WriteThrows()
{
string address;
@ -548,7 +548,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
Assert.Throws<IOException>(() =>
{
// It can take several tries before Write notices the disconnect.
for (int i = 0; i < 100; i++)
for (int i = 0; i < Utilities.WriteRetryLimit; i++)
{
context.Response.Body.Write(new byte[1000], 0, 1000);
}
@ -557,7 +557,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
}
}
[ConditionalFact(Skip = "https://github.com/aspnet/HttpSysServer/issues/263")]
[ConditionalFact]
public async Task ResponseBodyWriteExceptions_ClientDisconnectsBeforeSecondWriteAsync_WriteThrows()
{
string address;
@ -582,7 +582,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
await Assert.ThrowsAsync<IOException>(async () =>
{
// It can take several tries before Write notices the disconnect.
for (int i = 0; i < 100; i++)
for (int i = 0; i < Utilities.WriteRetryLimit; i++)
{
await context.Response.Body.WriteAsync(new byte[1000], 0, 1000);
}
@ -614,7 +614,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
Assert.True(context.DisconnectToken.WaitHandle.WaitOne(TimeSpan.FromSeconds(5)));
// It can take several tries before Write notices the disconnect.
for (int i = 0; i < 10; i++)
for (int i = 0; i < Utilities.WriteRetryLimit; i++)
{
context.Response.Body.Write(new byte[1000], 0, 1000);
}
@ -644,7 +644,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
Assert.True(context.DisconnectToken.WaitHandle.WaitOne(TimeSpan.FromSeconds(5)));
// It can take several tries before Write notices the disconnect.
for (int i = 0; i < 10; i++)
for (int i = 0; i < Utilities.WriteRetryLimit; i++)
{
await context.Response.Body.WriteAsync(new byte[1000], 0, 1000);
}

Просмотреть файл

@ -474,7 +474,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
await Assert.ThrowsAsync<IOException>(async () =>
{
// It can take several tries before Send notices the disconnect.
for (int i = 0; i < 1000; i++)
for (int i = 0; i < Utilities.WriteRetryLimit; i++)
{
await context.Response.SendFileAsync(AbsoluteFilePath, 0, null, CancellationToken.None);
}
@ -502,7 +502,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
await Assert.ThrowsAsync<TaskCanceledException>(() => responseTask);
Assert.True(context.DisconnectToken.WaitHandle.WaitOne(TimeSpan.FromSeconds(5)));
// It can take several tries before Send notices the disconnect.
for (int i = 0; i < 100; i++)
for (int i = 0; i < Utilities.WriteRetryLimit; i++)
{
await context.Response.SendFileAsync(AbsoluteFilePath, 0, null, CancellationToken.None);
}
@ -539,7 +539,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
await Assert.ThrowsAsync<IOException>(async () =>
{
// It can take several tries before Write notices the disconnect.
for (int i = 0; i < 100; i++)
for (int i = 0; i < Utilities.WriteRetryLimit; i++)
{
await context.Response.SendFileAsync(AbsoluteFilePath, 0, null, CancellationToken.None);
}
@ -574,7 +574,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
Assert.True(context.DisconnectToken.WaitHandle.WaitOne(TimeSpan.FromSeconds(5)));
// It can take several tries before Write notices the disconnect.
for (int i = 0; i < 10; i++)
for (int i = 0; i < Utilities.WriteRetryLimit; i++)
{
await context.Response.SendFileAsync(AbsoluteFilePath, 0, null, CancellationToken.None);
}

Просмотреть файл

@ -10,6 +10,8 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
{
internal static class Utilities
{
internal static readonly int WriteRetryLimit = 1000;
// When tests projects are run in parallel, overlapping port ranges can cause a race condition when looking for free
// ports during dynamic port allocation.
private const int BasePort = 8001;

Просмотреть файл

@ -49,7 +49,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.FunctionalTests
}
}
[ConditionalFact(Skip = "https://github.com/aspnet/HttpSysServer/issues/263")]
[ConditionalFact]
public async Task Caching_MaxAge_Cached()
{
var requestCount = 1;

Просмотреть файл

@ -9,12 +9,9 @@ using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Testing;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Xunit;
namespace Microsoft.AspNetCore.Server.HttpSys
@ -153,7 +150,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys
}
}
[ConditionalFact(Skip = "https://github.com/aspnet/HttpSysServer/issues/263")]
[ConditionalFact]
public void Server_MultipleOutstandingSyncRequests_Success()
{
int requestLimit = 10;