From 99fc843cc5805bc734a0e18a3f8cb2d975bdffdb Mon Sep 17 00:00:00 2001 From: John Luo Date: Mon, 23 Oct 2017 14:27:19 -0700 Subject: [PATCH] Re-enable skipped tests --- .../Listener/ResponseBodyTests.cs | 30 +++++++++---------- .../Listener/ResponseSendFileTests.cs | 8 ++--- .../Listener/Utilities.cs | 2 ++ .../ResponseCachingTests.cs | 2 +- .../ServerTests.cs | 5 +--- 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseBodyTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseBodyTests.cs index c41ef37..2ea7910 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseBodyTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseBodyTests.cs @@ -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(() => { // 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(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(() => 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(() => 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(() => { // 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(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); } diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseSendFileTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseSendFileTests.cs index cf7bab0..f1c1f4b 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseSendFileTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseSendFileTests.cs @@ -474,7 +474,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener await Assert.ThrowsAsync(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(() => 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(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); } diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/Utilities.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/Utilities.cs index db41469..b3fb1b1 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/Utilities.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/Utilities.cs @@ -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; diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/ResponseCachingTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/ResponseCachingTests.cs index 8fa4448..6a2fe8c 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/ResponseCachingTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/ResponseCachingTests.cs @@ -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; diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/ServerTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/ServerTests.cs index 22d53e0..4a451bd 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/ServerTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/ServerTests.cs @@ -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;