From fb61be479e85aeb27023a38cf37ae6e316ca6b5c Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Wed, 9 Jun 2021 17:32:58 +0200 Subject: [PATCH] [wasm][testing] hosting echo server in xharness process (#52923) - move tests to inner loop - include echo middleware in xharness server - improve doc - more granular ActiveIssue https://github.com/dotnet/runtime/issues/53592 for lack of TRACE - more granular ActiveIssue https://github.com/dotnet/runtime/issues/53591 for content on GET/HEAD - more granular ActiveIssue https://github.com/dotnet/runtime/issues/53874 for HttpRequestMessage.Headers.Host - more granular ActiveIssue https://github.com/dotnet/runtime/issues/53872 for NPE on System.Net.Http.BrowserHttpHandler - more granular ActiveIssue https://github.com/dotnet/runtime/issues/53876 - include middleware in Helix correlation payload --- .../testing/libraries/testing-wasm.md | 6 +- .../tests/System/Net/Configuration.Http.cs | 5 +- .../Common/tests/System/Net/Configuration.cs | 19 ++++ .../HttpClientHandlerTest.RemoteServer.cs | 94 ++++++++++--------- .../tests/System/Net/Http/PostScenarioTest.cs | 32 +++---- .../System/Net/Http/ResponseStreamTest.cs | 18 ++-- .../Net/Prerequisites/LocalEchoServer.props | 17 ++++ .../NetCoreServer/GenericHandler.cs | 2 +- .../NetCoreServer/NetCoreServer.csproj | 2 +- .../Prerequisites/NetCoreServer/Startup.cs | 9 ++ .../TestUtilities/System/PlatformDetection.cs | 3 + .../HttpClientHandlerTest.Headers.cs | 14 ++- .../tests/FunctionalTests/HttpClientTest.cs | 4 +- .../System.Net.Http.Functional.Tests.csproj | 8 ++ .../tests/CancelTest.cs | 16 ++-- .../tests/CloseTest.cs | 26 ++--- .../tests/ConnectTest.cs | 16 ++-- .../tests/SendReceiveTest.cs | 20 ++-- .../System.Net.WebSockets.Client.Tests.csproj | 8 ++ src/libraries/sendtohelixhelp.proj | 5 + 20 files changed, 202 insertions(+), 122 deletions(-) create mode 100644 src/libraries/Common/tests/System/Net/Prerequisites/LocalEchoServer.props diff --git a/docs/workflow/testing/libraries/testing-wasm.md b/docs/workflow/testing/libraries/testing-wasm.md index a8d7eb1a7934d..da752eb2d5974 100644 --- a/docs/workflow/testing/libraries/testing-wasm.md +++ b/docs/workflow/testing/libraries/testing-wasm.md @@ -100,11 +100,11 @@ The following shows how to run tests for a specific library - `$(WasmXHarnessArgs)` - xharness command arguments - Example: `WasmXHarnessArgs="--xyz"` -> becomes `dotnet xharness wasm test --xyz` + Example: `WasmXHarnessArgs="--set-web-server-http-env=DOTNET_TEST_WEBSOCKETHOST"` -> becomes `dotnet xharness wasm test --set-web-server-http-env=DOTNET_TEST_WEBSOCKETHOST` -- `$(WasmXHarnessMonoArgs)` - arguments to mono +- `$(WasmXHarnessMonoArgs)` - arguments and variables for mono - Example: `WasmXHarnessMonoArgs="--runtime-arg=--trace=E"` + Example: `WasmXHarnessMonoArgs="--runtime-arg=--trace=E --setenv=MONO_LOG_LEVEL=debug"` - `$(WasmTestAppArgs)` - arguments for the test app itself diff --git a/src/libraries/Common/tests/System/Net/Configuration.Http.cs b/src/libraries/Common/tests/System/Net/Configuration.Http.cs index 69e1094128771..e43c2c0e385e9 100644 --- a/src/libraries/Common/tests/System/Net/Configuration.Http.cs +++ b/src/libraries/Common/tests/System/Net/Configuration.Http.cs @@ -12,11 +12,12 @@ public static partial class Http { private static readonly string DefaultHttp2AzureServer = "corefx-net-http2.azurewebsites.net"; + // for the local server hosted in XHarness we are passing also port as part of the environment variables, because it's bound to random port number public static string Host => GetValue("DOTNET_TEST_HTTPHOST", DefaultAzureServer); - public static string SecureHost => GetValue("DOTNET_TEST_SECUREHTTPHOST", DefaultAzureServer); - public static string Http2Host => GetValue("DOTNET_TEST_HTTP2HOST", DefaultHttp2AzureServer); + public static int Port = GetPortValue("DOTNET_TEST_HTTPHOST", 80); + public static int SecurePort = GetPortValue("DOTNET_TEST_SECUREHTTPHOST", 443); // This server doesn't use HTTP/2 server push (push promise) feature. Some HttpClient implementations // don't support servers that use push right now. diff --git a/src/libraries/Common/tests/System/Net/Configuration.cs b/src/libraries/Common/tests/System/Net/Configuration.cs index 62e860b2efecf..9cb9c75f78acd 100644 --- a/src/libraries/Common/tests/System/Net/Configuration.cs +++ b/src/libraries/Common/tests/System/Net/Configuration.cs @@ -21,6 +21,25 @@ private static string GetValue(string envName, string defaultValue=null) return Environment.ExpandEnvironmentVariables(envValue); } + private static int GetPortValue(string envName, int defaultValue) + { + string envValue = Environment.GetEnvironmentVariable(envName); + + if (string.IsNullOrWhiteSpace(envValue)) + { + return defaultValue; + } + envValue = Environment.ExpandEnvironmentVariables(envValue); + + var split = envValue.Split(':'); + if (split.Length<2) + { + return defaultValue; + } + + return int.Parse(split[1]); + } + private static Uri GetUriValue(string envName, Uri defaultValue=null) { string envValue = GetValue(envName, null); diff --git a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.RemoteServer.cs b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.RemoteServer.cs index fcf578b63cd63..70d56f44a6e29 100644 --- a/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.RemoteServer.cs +++ b/src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.RemoteServer.cs @@ -77,9 +77,9 @@ public async Task UseDefaultCredentials_SetToFalseAndServerNeedsAuth_StatusCodeU } } - [OuterLoop("Uses external servers")] - [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task SendAsync_SimpleGet_Success(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -95,9 +95,8 @@ public async Task SendAsync_SimpleGet_Success(Configuration.Http.RemoteServer re } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] public async Task SendAsync_MultipleRequestsReusingSameClient_Success(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -112,9 +111,9 @@ public async Task SendAsync_MultipleRequestsReusingSameClient_Success(Configurat } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task GetAsync_ResponseContentAfterClientAndHandlerDispose_Success(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -162,9 +161,8 @@ public async Task GetAsync_ServerNeedsAuthAndSetCredential_StatusCodeOK(Configur } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] public async Task GetAsync_ServerNeedsAuthAndNoCredential_StatusCodeUnauthorized(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -177,10 +175,10 @@ public async Task GetAsync_ServerNeedsAuthAndNoCredential_StatusCodeUnauthorized } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory] [MemberData(nameof(RemoteServersAndHeaderEchoUrisMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/53872", TestPlatforms.Browser)] public async Task GetAsync_RequestHeadersAddCustomHeaders_HeaderAndEmptyValueSent(Configuration.Http.RemoteServer remoteServer, Uri uri) { if (IsWinHttpHandler && !PlatformDetection.IsWindows10Version1709OrGreater) @@ -204,9 +202,8 @@ public async Task GetAsync_RequestHeadersAddCustomHeaders_HeaderAndEmptyValueSen } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersHeaderValuesAndUris))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] public async Task GetAsync_RequestHeadersAddCustomHeaders_HeaderAndValueSent(Configuration.Http.RemoteServer remoteServer, string name, string value, Uri uri) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -223,9 +220,8 @@ public async Task GetAsync_RequestHeadersAddCustomHeaders_HeaderAndValueSent(Con } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersAndHeaderEchoUrisMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] public async Task GetAsync_LargeRequestHeader_HeadersAndValuesSent(Configuration.Http.RemoteServer remoteServer, Uri uri) { // Unfortunately, our remote servers seem to have pretty strict limits (around 16K?) @@ -291,9 +287,9 @@ public static IEnumerable<(Configuration.Http.RemoteServer remoteServer, Uri uri public static IEnumerable RemoteServersAndHeaderEchoUrisMemberData() => RemoteServersAndHeaderEchoUris().Select(x => new object[] { x.remoteServer, x.uri }); - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task GetAsync_ResponseHeadersRead_ReadFromEachIterativelyDoesntDeadlock(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -317,9 +313,9 @@ public async Task GetAsync_ResponseHeadersRead_ReadFromEachIterativelyDoesntDead } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task SendAsync_HttpRequestMsgResponseHeadersRead_StatusCodeOK(Configuration.Http.RemoteServer remoteServer) { // Sync API supported only up to HTTP/1.1 @@ -344,7 +340,7 @@ public async Task SendAsync_HttpRequestMsgResponseHeadersRead_StatusCodeOK(Confi } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostAsync_CallMethodTwice_StringContent(Configuration.Http.RemoteServer remoteServer) @@ -370,7 +366,7 @@ public async Task PostAsync_CallMethodTwice_StringContent(Configuration.Http.Rem } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostAsync_CallMethod_UnicodeStringContent(Configuration.Http.RemoteServer remoteServer) @@ -388,7 +384,7 @@ public async Task PostAsync_CallMethod_UnicodeStringContent(Configuration.Http.R } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(VerifyUploadServersStreamsAndExpectedData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostAsync_CallMethod_StreamContent(Configuration.Http.RemoteServer remoteServer, HttpContent content, byte[] expectedData) @@ -528,9 +524,9 @@ public static IEnumerable VerifyUploadServersStreamsAndExpectedData } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostAsync_CallMethod_NullContent(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -550,9 +546,9 @@ public async Task PostAsync_CallMethod_NullContent(Configuration.Http.RemoteServ } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostAsync_CallMethod_EmptyContent(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -581,10 +577,10 @@ public static IEnumerable ExpectContinueVersion() select new object[] {expect, version}; } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory] [MemberData(nameof(ExpectContinueVersion))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/53876", TestPlatforms.Browser)] public async Task PostAsync_ExpectContinue_Success(bool? expectContinue, Version version) { // Sync API supported only up to HTTP/1.1 @@ -622,9 +618,8 @@ public async Task PostAsync_ExpectContinue_Success(bool? expectContinue, Version } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] public async Task PostAsync_Redirect_ResultingGetFormattedCorrectly(Configuration.Http.RemoteServer remoteServer) { const string ContentString = "This is the content string."; @@ -644,7 +639,7 @@ public async Task PostAsync_Redirect_ResultingGetFormattedCorrectly(Configuratio } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostAsync_RedirectWith307_LargePayload(Configuration.Http.RemoteServer remoteServer) @@ -660,7 +655,7 @@ public async Task PostAsync_RedirectWith307_LargePayload(Configuration.Http.Remo await PostAsync_Redirect_LargePayload_Helper(remoteServer, 307, true); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostAsync_RedirectWith302_LargePayload(Configuration.Http.RemoteServer remoteServer) @@ -716,9 +711,9 @@ private async Task PostAsync_Redirect_LargePayload_Helper(Configuration.Http.Rem } #if !NETFRAMEWORK - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostAsync_ReuseRequestContent_Success(Configuration.Http.RemoteServer remoteServer) { const string ContentString = "This is the content string."; @@ -737,14 +732,17 @@ public async Task PostAsync_ReuseRequestContent_Success(Configuration.Http.Remot } #endif - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(HttpMethods))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53592", TestPlatforms.Browser)] public async Task SendAsync_SendRequestUsingMethodToEchoServerWithNoContent_MethodCorrectlySent( string method, Uri serverUri) { + if (method == "TRACE" && PlatformDetection.IsBrowser) + { + // [ActiveIssue("https://github.com/dotnet/runtime/issues/53592", TestPlatforms.Browser)] + return; + } using (HttpClient client = CreateHttpClient()) { var request = new HttpRequestMessage( @@ -759,9 +757,10 @@ public async Task PostAsync_ReuseRequestContent_Success(Configuration.Http.Remot } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(HttpMethodsThatAllowContent))] [ActiveIssue("https://github.com/dotnet/runtime/issues/53591", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task SendAsync_SendRequestUsingMethodToEchoServerWithContent_Success( string method, Uri serverUri) @@ -789,14 +788,23 @@ public async Task PostAsync_ReuseRequestContent_Success(Configuration.Http.Remot } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(HttpMethodsThatDontAllowContent))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53591", TestPlatforms.Browser)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53592", TestPlatforms.Browser)] public async Task SendAsync_SendRequestUsingNoBodyMethodToEchoServerWithContent_NoBodySent( string method, Uri serverUri) { + if (method == "TRACE" && PlatformDetection.IsBrowser) + { + // [ActiveIssue("https://github.com/dotnet/runtime/issues/53592", TestPlatforms.Browser)] + return; + } + if (method == "HEAD" && PlatformDetection.IsBrowser) + { + // [ActiveIssue("https://github.com/dotnet/runtime/issues/53591", TestPlatforms.Browser)] + return; + } + using (HttpClient client = CreateHttpClient()) { var request = new HttpRequestMessage( @@ -836,9 +844,8 @@ public static IEnumerable SendAsync_SendSameRequestMultipleTimesDirect } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(SendAsync_SendSameRequestMultipleTimesDirectlyOnHandler_Success_MemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] public async Task SendAsync_SendSameRequestMultipleTimesDirectlyOnHandler_Success(Configuration.Http.RemoteServer remoteServer, string stringContent, int startingPosition) { using (var handler = new HttpMessageInvoker(CreateHttpClientHandler())) @@ -869,10 +876,9 @@ public async Task SendAsync_SendSameRequestMultipleTimesDirectlyOnHandler_Succes } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory] [MemberData(nameof(Http2Servers))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] public async Task SendAsync_RequestVersion20_ResponseVersion20IfHttp2Supported(Uri server) { // Sync API supported only up to HTTP/1.1 diff --git a/src/libraries/Common/tests/System/Net/Http/PostScenarioTest.cs b/src/libraries/Common/tests/System/Net/Http/PostScenarioTest.cs index 0d75e65aea91a..c6654ec7d36dc 100644 --- a/src/libraries/Common/tests/System/Net/Http/PostScenarioTest.cs +++ b/src/libraries/Common/tests/System/Net/Http/PostScenarioTest.cs @@ -28,9 +28,9 @@ public abstract class PostScenarioTest : HttpClientHandlerTestBase public PostScenarioTest(ITestOutputHelper output) : base(output) { } #if !NETFRAMEWORK - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostRewindableStreamContentMultipleTimes_StreamContentFullySent(Configuration.Http.RemoteServer remoteServer) { const string requestBody = "ABC"; @@ -53,17 +53,17 @@ public async Task PostRewindableStreamContentMultipleTimes_StreamContentFullySen } #endif - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [MemberData(nameof(RemoteServersMemberData))] [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupportedOrNotBrowser))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostNoContentUsingContentLengthSemantics_Success(Configuration.Http.RemoteServer remoteServer) { await PostHelper(remoteServer, string.Empty, null, useContentLengthUpload: true, useChunkedEncodingUpload: false); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostEmptyContentUsingContentLengthSemantics_Success(Configuration.Http.RemoteServer remoteServer) @@ -72,7 +72,7 @@ public async Task PostEmptyContentUsingContentLengthSemantics_Success(Configurat useContentLengthUpload: true, useChunkedEncodingUpload: false); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostEmptyContentUsingChunkedEncoding_Success(Configuration.Http.RemoteServer remoteServer) @@ -81,7 +81,7 @@ public async Task PostEmptyContentUsingChunkedEncoding_Success(Configuration.Htt useContentLengthUpload: false, useChunkedEncodingUpload: true); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostEmptyContentUsingConflictingSemantics_Success(Configuration.Http.RemoteServer remoteServer) @@ -90,7 +90,7 @@ public async Task PostEmptyContentUsingConflictingSemantics_Success(Configuratio useContentLengthUpload: true, useChunkedEncodingUpload: true); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostUsingContentLengthSemantics_Success(Configuration.Http.RemoteServer remoteServer) @@ -99,7 +99,7 @@ public async Task PostUsingContentLengthSemantics_Success(Configuration.Http.Rem useContentLengthUpload: true, useChunkedEncodingUpload: false); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostUsingChunkedEncoding_Success(Configuration.Http.RemoteServer remoteServer) @@ -108,7 +108,7 @@ public async Task PostUsingChunkedEncoding_Success(Configuration.Http.RemoteServ useContentLengthUpload: false, useChunkedEncodingUpload: true); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostSyncBlockingContentUsingChunkedEncoding_Success(Configuration.Http.RemoteServer remoteServer) @@ -117,7 +117,7 @@ public async Task PostSyncBlockingContentUsingChunkedEncoding_Success(Configurat useContentLengthUpload: false, useChunkedEncodingUpload: true); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostRepeatedFlushContentUsingChunkedEncoding_Success(Configuration.Http.RemoteServer remoteServer) @@ -126,7 +126,7 @@ public async Task PostRepeatedFlushContentUsingChunkedEncoding_Success(Configura useContentLengthUpload: false, useChunkedEncodingUpload: true); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostUsingUsingConflictingSemantics_UsesChunkedSemantics(Configuration.Http.RemoteServer remoteServer) @@ -135,7 +135,7 @@ public async Task PostUsingUsingConflictingSemantics_UsesChunkedSemantics(Config useContentLengthUpload: true, useChunkedEncodingUpload: true); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostUsingNoSpecifiedSemantics_UsesChunkedSemantics(Configuration.Http.RemoteServer remoteServer) @@ -154,7 +154,7 @@ public static IEnumerable RemoteServersAndLargeContentSizes() } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory] [MemberData(nameof(RemoteServersAndLargeContentSizes))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] @@ -223,10 +223,10 @@ public async Task PostNonRewindableContentUsingAuth_PreAuthenticate_Success(Conf await PostUsingAuthHelper(remoteServer, ExpectedContent, content, credential, preAuthenticate: true); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [MemberData(nameof(RemoteServersMemberData))] [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupportedOrNotBrowser))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task PostAsync_EmptyContent_ContentTypeHeaderNotSent(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) diff --git a/src/libraries/Common/tests/System/Net/Http/ResponseStreamTest.cs b/src/libraries/Common/tests/System/Net/Http/ResponseStreamTest.cs index 3b01e68198c64..40638272b6373 100644 --- a/src/libraries/Common/tests/System/Net/Http/ResponseStreamTest.cs +++ b/src/libraries/Common/tests/System/Net/Http/ResponseStreamTest.cs @@ -30,9 +30,9 @@ public static IEnumerable RemoteServersAndReadModes() } } - [OuterLoop("Uses external servers")] + + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersAndReadModes))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] public async Task GetStreamAsync_ReadToEnd_Success(Configuration.Http.RemoteServer remoteServer, int readMode) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -126,9 +126,9 @@ public async Task GetStreamAsync_ReadToEnd_Success(Configuration.Http.RemoteServ } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task GetAsync_UseResponseHeadersReadAndCallLoadIntoBuffer_Success(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -146,9 +146,9 @@ public async Task GetAsync_UseResponseHeadersReadAndCallLoadIntoBuffer_Success(C } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task GetAsync_UseResponseHeadersReadAndCopyToMemoryStream_Success(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -171,9 +171,8 @@ public async Task GetAsync_UseResponseHeadersReadAndCopyToMemoryStream_Success(C } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] public async Task GetStreamAsync_ReadZeroBytes_Success(Configuration.Http.RemoteServer remoteServer) { using (HttpClient client = CreateHttpClientForRemoteServer(remoteServer)) @@ -187,9 +186,8 @@ public async Task GetStreamAsync_ReadZeroBytes_Success(Configuration.Http.Remote } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory, MemberData(nameof(RemoteServersMemberData))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] public async Task ReadAsStreamAsync_Cancel_TaskIsCanceled(Configuration.Http.RemoteServer remoteServer) { var cts = new CancellationTokenSource(); diff --git a/src/libraries/Common/tests/System/Net/Prerequisites/LocalEchoServer.props b/src/libraries/Common/tests/System/Net/Prerequisites/LocalEchoServer.props new file mode 100644 index 0000000000000..97bdbf298b842 --- /dev/null +++ b/src/libraries/Common/tests/System/Net/Prerequisites/LocalEchoServer.props @@ -0,0 +1,17 @@ + + + WasmTestOnBrowser + $(TestArchiveRoot)browseronly/ + $(TestArchiveTestsRoot)$(OSPlatformConfig)/ + + + <_TestEchoMiddleware Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(OS)' == 'Windows_NT'">%HELIX_CORRELATION_PAYLOAD%/xharness/TestEchoMiddleware + <_TestEchoMiddleware Condition="'$(ContinuousIntegrationBuild)' == 'true' and '$(OS)' != 'Windows_NT'">$HELIX_CORRELATION_PAYLOAD/xharness/TestEchoMiddleware + <_TestEchoMiddleware Condition="'$(ContinuousIntegrationBuild)' != 'true'">$(ArtifactsDir)bin/NetCoreServer/$(NetCoreAppCurrent)-$(Configuration) + + $(WasmXHarnessArgs) --web-server-use-cors --web-server-use-https + $(WasmXHarnessArgs) --set-web-server-http-env=DOTNET_TEST_WEBSOCKETHOST,DOTNET_TEST_HTTPHOST + $(WasmXHarnessArgs) --set-web-server-https-env=DOTNET_TEST_SECUREWEBSOCKETHOST,DOTNET_TEST_SECUREHTTPHOST,DOTNET_TEST_HTTP2HOST + $(WasmXHarnessArgs) --web-server-middleware=$(_TestEchoMiddleware)/NetCoreServer.dll,GenericHandler + + diff --git a/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/GenericHandler.cs b/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/GenericHandler.cs index 6efc71033a308..f129157b1d916 100644 --- a/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/GenericHandler.cs +++ b/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/GenericHandler.cs @@ -13,7 +13,7 @@ public class GenericHandler // Must have constructor with this signature, otherwise exception at run time. public GenericHandler(RequestDelegate next) { - // This is an HTTP Handler, so no need to store next. + // This catch all HTTP Handler, so no need to store next. } public async Task Invoke(HttpContext context) diff --git a/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/NetCoreServer.csproj b/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/NetCoreServer.csproj index d9b272d4d3241..875277b02d31a 100644 --- a/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/NetCoreServer.csproj +++ b/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/NetCoreServer.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + $(AspNetCoreAppCurrent) InProcess Exe false diff --git a/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/Startup.cs b/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/Startup.cs index 3ebe39a7d2c51..5819ff9f25ef3 100644 --- a/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/Startup.cs +++ b/src/libraries/Common/tests/System/Net/Prerequisites/NetCoreServer/Startup.cs @@ -11,11 +11,20 @@ public class Startup { public void ConfigureServices(IServiceCollection services) { + services.AddCors(o => o.AddPolicy("AnyCors", builder => + { + builder.AllowAnyOrigin() + .AllowAnyMethod() + .AllowAnyHeader() + .WithExposedHeaders("*") + ; + })); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { + app.UseCors("AnyCors"); app.UseWebSockets(); app.UseGenericHandler(); } diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index e63e0d0d5e946..aa44cfe53f1b0 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -9,6 +9,7 @@ using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using Microsoft.Win32; +using Xunit; namespace System { @@ -59,6 +60,8 @@ public static partial class PlatformDetection public static bool IsBrowserDomSupported => GetIsBrowserDomSupported(); public static bool IsBrowserDomSupportedOrNotBrowser => IsNotBrowser || GetIsBrowserDomSupported(); public static bool IsNotBrowserDomSupported => !IsBrowserDomSupported; + public static bool LocalEchoServerIsNotAvailable => !LocalEchoServerIsAvailable; + public static bool LocalEchoServerIsAvailable => IsBrowser; public static bool IsUsingLimitedCultures => !IsNotMobile; public static bool IsNotUsingLimitedCultures => IsNotMobile; diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Headers.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Headers.cs index eb57adbbfc635..60300e8afff70 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Headers.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Headers.cs @@ -343,11 +343,11 @@ public async Task SendAsync_RequestHeaderInResponse_Success(string name, string }); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Theory] [InlineData(false)] [InlineData(true)] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/37669", TestPlatforms.Browser)] public async Task SendAsync_GetWithValidHostHeader_Success(bool withPort) { if (UseVersion == HttpVersion.Version30) @@ -355,9 +355,14 @@ public async Task SendAsync_GetWithValidHostHeader_Success(bool withPort) // External servers do not support HTTP3 currently. return; } + if (PlatformDetection.LocalEchoServerIsAvailable && !withPort) + { + // we always have custom port with the local echo server, so we couldn't test without it + return; + } var m = new HttpRequestMessage(HttpMethod.Get, Configuration.Http.SecureRemoteEchoServer) { Version = UseVersion }; - m.Headers.Host = withPort ? Configuration.Http.SecureHost + ":443" : Configuration.Http.SecureHost; + m.Headers.Host = withPort ? Configuration.Http.SecureHost + ":" + Configuration.Http.SecurePort : Configuration.Http.SecureHost; using (HttpClient client = CreateHttpClient()) using (HttpResponseMessage response = await client.SendAsync(TestAsync, m)) @@ -372,8 +377,9 @@ public async Task SendAsync_GetWithValidHostHeader_Success(bool withPort) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/53874", TestPlatforms.Browser)] public async Task SendAsync_GetWithInvalidHostHeader_ThrowsException() { if (LoopbackServerFactory.Version >= HttpVersion.Version20) diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.cs index fcc3f0514747d..94d59d89b03ff 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientTest.cs @@ -1213,10 +1213,10 @@ public async Task SendAsync_CorrectVersionSelected_LoopbackServer(Version reques }); } + [Theory] [OuterLoop("Uses external servers")] [MemberData(nameof(VersionSelectionMemberData))] - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsBrowserDomSupportedOrNotBrowser))] - [ActiveIssue("https://github.com/dotnet/runtime/issues/53018", TestPlatforms.Browser)] + [SkipOnPlatform(TestPlatforms.Browser, "Version is ignored on Browser")] public async Task SendAsync_CorrectVersionSelected_ExternalServer(Version requestVersion, HttpVersionPolicy versionPolicy, Version serverVersion, bool useSsl, object expectedResult) { RemoteServer remoteServer = null; diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj b/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj index a5ae70bbb2feb..76469218e27d4 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj @@ -8,11 +8,19 @@ true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-OSX + WasmTestOnBrowser $(TestArchiveRoot)browseronly/ $(TestArchiveTestsRoot)$(OSPlatformConfig)/ + + + + + + + diff --git a/src/libraries/System.Net.WebSockets.Client/tests/CancelTest.cs b/src/libraries/System.Net.WebSockets.Client/tests/CancelTest.cs index 8c74513e0a0c8..da80a1678346b 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/CancelTest.cs +++ b/src/libraries/System.Net.WebSockets.Client/tests/CancelTest.cs @@ -13,7 +13,7 @@ public class CancelTest : ClientWebSocketTestBase { public CancelTest(ITestOutputHelper output) : base(output) { } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task ConnectAsync_Cancel_ThrowsCancellationException(Uri server) { @@ -29,7 +29,7 @@ public async Task ConnectAsync_Cancel_ThrowsCancellationException(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task SendAsync_Cancel_Success(Uri server) { @@ -44,7 +44,7 @@ public async Task SendAsync_Cancel_Success(Uri server) }, server); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] [ActiveIssue("https://github.com/dotnet/runtime/issues/19217")] public async Task ReceiveAsync_Cancel_Success(Uri server) @@ -67,7 +67,7 @@ public async Task ReceiveAsync_Cancel_Success(Uri server) }, server); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseAsync_Cancel_Success(Uri server) { @@ -89,7 +89,7 @@ public async Task CloseAsync_Cancel_Success(Uri server) }, server); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseOutputAsync_Cancel_Success(Uri server) { @@ -112,7 +112,7 @@ public async Task CloseOutputAsync_Cancel_Success(Uri server) }, server); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task ReceiveAsync_CancelThenReceive_ThrowsOperationCanceledException(Uri server) { @@ -128,7 +128,7 @@ public async Task ReceiveAsync_CancelThenReceive_ThrowsOperationCanceledExceptio } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task ReceiveAsync_ReceiveThenCancel_ThrowsOperationCanceledException(Uri server) { @@ -144,7 +144,7 @@ public async Task ReceiveAsync_ReceiveThenCancel_ThrowsOperationCanceledExceptio } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task ReceiveAsync_AfterCancellationDoReceiveAsync_ThrowsWebSocketException(Uri server) { diff --git a/src/libraries/System.Net.WebSockets.Client/tests/CloseTest.cs b/src/libraries/System.Net.WebSockets.Client/tests/CloseTest.cs index bee31155b396f..68773696bfcdb 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/CloseTest.cs +++ b/src/libraries/System.Net.WebSockets.Client/tests/CloseTest.cs @@ -18,7 +18,7 @@ public class CloseTest : ClientWebSocketTestBase public CloseTest(ITestOutputHelper output) : base(output) { } [ActiveIssue("https://github.com/dotnet/runtime/issues/28957")] - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServersAndBoolean))] public async Task CloseAsync_ServerInitiatedClose_Success(Uri server, bool useCloseOutputAsync) { @@ -65,7 +65,7 @@ public async Task CloseAsync_ServerInitiatedClose_Success(Uri server, bool useCl } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseAsync_ClientInitiatedClose_Success(Uri server) { @@ -87,7 +87,7 @@ public async Task CloseAsync_ClientInitiatedClose_Success(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseAsync_CloseDescriptionIsMaxLength_Success(Uri server) { @@ -101,7 +101,7 @@ public async Task CloseAsync_CloseDescriptionIsMaxLength_Success(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseAsync_CloseDescriptionIsMaxLengthPlusOne_ThrowsArgumentException(Uri server) { @@ -126,7 +126,7 @@ public async Task CloseAsync_CloseDescriptionIsMaxLengthPlusOne_ThrowsArgumentEx } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseAsync_CloseDescriptionHasUnicode_Success(Uri server) { @@ -145,7 +145,7 @@ public async Task CloseAsync_CloseDescriptionHasUnicode_Success(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseAsync_CloseDescriptionIsNull_Success(Uri server) { @@ -161,7 +161,7 @@ public async Task CloseAsync_CloseDescriptionIsNull_Success(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseOutputAsync_ExpectedStates(Uri server) { @@ -180,7 +180,7 @@ public async Task CloseOutputAsync_ExpectedStates(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseAsync_CloseOutputAsync_Throws(Uri server) { @@ -205,7 +205,7 @@ public async Task CloseAsync_CloseOutputAsync_Throws(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseOutputAsync_ClientInitiated_CanReceive_CanClose(Uri server) { @@ -245,7 +245,7 @@ public async Task CloseOutputAsync_ClientInitiated_CanReceive_CanClose(Uri serve } [ActiveIssue("https://github.com/dotnet/runtime/issues/28957")] - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseOutputAsync_ServerInitiated_CanSend(Uri server) { @@ -292,7 +292,7 @@ public async Task CloseOutputAsync_ServerInitiated_CanSend(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseOutputAsync_CloseDescriptionIsNull_Success(Uri server) { @@ -308,7 +308,7 @@ public async Task CloseOutputAsync_CloseDescriptionIsNull_Success(Uri server) } [ActiveIssue("https://github.com/dotnet/runtime/issues/22000", TargetFrameworkMonikers.Netcoreapp)] - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseOutputAsync_DuringConcurrentReceiveAsync_ExpectedStates(Uri server) { @@ -345,7 +345,7 @@ public async Task CloseOutputAsync_DuringConcurrentReceiveAsync_ExpectedStates(U } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task CloseAsync_DuringConcurrentReceiveAsync_ExpectedStates(Uri server) { diff --git a/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs b/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs index 1f3f37f1a3710..443166cafec66 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs +++ b/src/libraries/System.Net.WebSockets.Client/tests/ConnectTest.cs @@ -17,7 +17,7 @@ public class ConnectTest : ClientWebSocketTestBase public ConnectTest(ITestOutputHelper output) : base(output) { } [ActiveIssue("https://github.com/dotnet/runtime/issues/1895")] - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(UnavailableWebSocketServers))] public async Task ConnectAsync_NotWebSocketServer_ThrowsWebSocketExceptionWithMessage(Uri server, string exceptionMessage, WebSocketError errorCode) { @@ -42,21 +42,21 @@ public async Task ConnectAsync_NotWebSocketServer_ThrowsWebSocketExceptionWithMe } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task EchoBinaryMessage_Success(Uri server) { await WebSocketHelper.TestEcho(server, WebSocketMessageType.Binary, TimeOutMilliseconds, _output); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task EchoTextMessage_Success(Uri server) { await WebSocketHelper.TestEcho(server, WebSocketMessageType.Text, TimeOutMilliseconds, _output); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoHeadersServers))] [SkipOnPlatform(TestPlatforms.Browser, "CustomHeaders not supported on browser")] public async Task ConnectAsync_AddCustomHeaders_Success(Uri server) @@ -118,7 +118,7 @@ public async Task ConnectAsync_AddHostHeader_Success() }), new LoopbackServer.Options { WebSocketEndpoint = true }); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoHeadersServers))] [SkipOnPlatform(TestPlatforms.Browser, "Cookies not supported on browser")] public async Task ConnectAsync_CookieHeaders_Success(Uri server) @@ -168,7 +168,7 @@ public async Task ConnectAsync_CookieHeaders_Success(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] [ActiveIssue("https://github.com/dotnet/runtime/issues/45583", TestPlatforms.Browser)] public async Task ConnectAsync_PassNoSubProtocol_ServerRequires_ThrowsWebSocketException(Uri server) @@ -194,7 +194,7 @@ public async Task ConnectAsync_PassNoSubProtocol_ServerRequires_ThrowsWebSocketE } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task ConnectAsync_PassMultipleSubProtocols_ServerRequires_ConnectionUsesAgreedSubProtocol(Uri server) { @@ -235,7 +235,7 @@ public async Task ConnectAsync_NonStandardRequestHeaders_HeadersAddedWithoutVali }), new LoopbackServer.Options { WebSocketEndpoint = true }); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] [ActiveIssue("https://github.com/dotnet/runtime/issues/42852", TestPlatforms.Browser)] public async Task ConnectAndCloseAsync_UseProxyServer_ExpectedClosedState(Uri server) diff --git a/src/libraries/System.Net.WebSockets.Client/tests/SendReceiveTest.cs b/src/libraries/System.Net.WebSockets.Client/tests/SendReceiveTest.cs index 5d36a8c6c32bd..d3a04bdbeef96 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/SendReceiveTest.cs +++ b/src/libraries/System.Net.WebSockets.Client/tests/SendReceiveTest.cs @@ -49,7 +49,7 @@ public abstract class SendReceiveTest : ClientWebSocketTestBase public SendReceiveTest(ITestOutputHelper output) : base(output) { } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task SendReceive_PartialMessageDueToSmallReceiveBuffer_Success(Uri server) { @@ -86,7 +86,7 @@ public async Task SendReceive_PartialMessageDueToSmallReceiveBuffer_Success(Uri } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] [SkipOnPlatform(TestPlatforms.Browser, "JS Websocket does not support see issue https://github.com/dotnet/runtime/issues/46983")] public async Task SendReceive_PartialMessageBeforeCompleteMessageArrives_Success(Uri server) @@ -128,7 +128,7 @@ public async Task SendReceive_PartialMessageBeforeCompleteMessageArrives_Success } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task SendAsync_SendCloseMessageType_ThrowsArgumentExceptionWithMessage(Uri server) { @@ -156,7 +156,7 @@ public async Task SendAsync_SendCloseMessageType_ThrowsArgumentExceptionWithMess } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task SendAsync_MultipleOutstandingSendOperations_Throws(Uri server) { @@ -215,7 +215,7 @@ public async Task SendAsync_MultipleOutstandingSendOperations_Throws(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task ReceiveAsync_MultipleOutstandingReceiveOperations_Throws(Uri server) { @@ -279,7 +279,7 @@ public async Task ReceiveAsync_MultipleOutstandingReceiveOperations_Throws(Uri s } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task SendAsync_SendZeroLengthPayloadAsEndOfMessage_Success(Uri server) { @@ -318,7 +318,7 @@ public async Task SendAsync_SendZeroLengthPayloadAsEndOfMessage_Success(Uri serv } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task SendReceive_VaryingLengthBuffers_Success(Uri server) { @@ -358,7 +358,7 @@ public async Task SendReceive_VaryingLengthBuffers_Success(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task SendReceive_Concurrent_Success(Uri server) { @@ -387,7 +387,7 @@ public async Task SendReceive_Concurrent_Success(Uri server) } } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalFact(nameof(WebSocketsSupported))] [ActiveIssue("https://github.com/dotnet/runtime/issues/42852", TestPlatforms.Browser)] public async Task SendReceive_ConnectionClosedPrematurely_ReceiveAsyncFailsAndWebSocketStateUpdated() @@ -457,7 +457,7 @@ public async Task SendReceive_ConnectionClosedPrematurely_ReceiveAsyncFailsAndWe }, options); } - [OuterLoop("Uses external servers")] + [OuterLoop("Uses external servers", typeof(PlatformDetection), nameof(PlatformDetection.LocalEchoServerIsNotAvailable))] [ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))] public async Task ZeroByteReceive_CompletesWhenDataAvailable(Uri server) { diff --git a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj index 3da2d56665aeb..22b43cc0edcf9 100644 --- a/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj +++ b/src/libraries/System.Net.WebSockets.Client/tests/System.Net.WebSockets.Client.Tests.csproj @@ -4,11 +4,19 @@ $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser $(DefineConstants);NETSTANDARD + WasmTestOnBrowser $(TestArchiveRoot)browseronly/ $(TestArchiveTestsRoot)$(OSPlatformConfig)/ + + + + + + + diff --git a/src/libraries/sendtohelixhelp.proj b/src/libraries/sendtohelixhelp.proj index 4c9ca394a9c48..be54bdadc1960 100644 --- a/src/libraries/sendtohelixhelp.proj +++ b/src/libraries/sendtohelixhelp.proj @@ -297,6 +297,7 @@ https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/$(ChromiumRevision)/chromedriver_linux64.zip $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'src', 'mono', 'wasm', 'emsdk')) $([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'src', 'mono', 'wasm', 'build')) + $([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'bin', 'NetCoreServer', '$(NetCoreAppCurrent)-$(Configuration)')) @@ -329,6 +330,10 @@ + + + +