Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm][testing] hosting echo server in xharness process #52923

Merged
merged 6 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/workflow/testing/libraries/testing-wasm.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
pavelsavara marked this conversation as resolved.
Show resolved Hide resolved

- `$(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

Expand Down
25 changes: 15 additions & 10 deletions src/libraries/Common/tests/System/Net/Configuration.Http.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ 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 string Http2SecureHost => GetValue("DOTNET_TEST_HTTP2SECUREHOST", DefaultHttp2AzureServer);
pavelsavara marked this conversation as resolved.
Show resolved Hide resolved

public static int Port = GetPortValue("DOTNET_TEST_HTTPHOST", 80);
public static int SecurePort = GetPortValue("DOTNET_TEST_SECUREHTTPHOST", 443);
pavelsavara marked this conversation as resolved.
Show resolved Hide resolved

// This server doesn't use HTTP/2 server push (push promise) feature. Some HttpClient implementations
// don't support servers that use push right now.
Expand Down Expand Up @@ -53,32 +56,34 @@ public static partial class Http

public static readonly Uri RemoteEchoServer = new Uri("http://" + Host + "/" + EchoHandler);
public static readonly Uri SecureRemoteEchoServer = new Uri("https://" + SecureHost + "/" + EchoHandler);
public static readonly Uri Http2RemoteEchoServer = new Uri("https://" + Http2Host + "/" + EchoHandler);
public static readonly Uri[] EchoServerList = new Uri[] { RemoteEchoServer, SecureRemoteEchoServer, Http2RemoteEchoServer };
public static readonly Uri Http2RemoteEchoServer = new Uri("http://" + Http2Host + "/" + EchoHandler);
public static readonly Uri Http2SecureRemoteEchoServer = new Uri("https://" + Http2SecureHost + "/" + EchoHandler);
public static readonly Uri[] EchoServerList = new Uri[] { RemoteEchoServer, SecureRemoteEchoServer, Http2RemoteEchoServer, Http2SecureRemoteEchoServer };

public static readonly Uri RemoteVerifyUploadServer = new Uri("http://" + Host + "/" + VerifyUploadHandler);
public static readonly Uri SecureRemoteVerifyUploadServer = new Uri("https://" + SecureHost + "/" + VerifyUploadHandler);
public static readonly Uri Http2RemoteVerifyUploadServer = new Uri("https://" + Http2Host + "/" + VerifyUploadHandler);
public static readonly Uri Http2RemoteVerifyUploadServer = new Uri("https://" + Http2SecureHost + "/" + VerifyUploadHandler);
pavelsavara marked this conversation as resolved.
Show resolved Hide resolved
public static readonly Uri[] VerifyUploadServerList = new Uri[] { RemoteVerifyUploadServer, SecureRemoteVerifyUploadServer, Http2RemoteVerifyUploadServer };

public static readonly Uri RemoteEmptyContentServer = new Uri("http://" + Host + "/" + EmptyContentHandler);
public static readonly Uri RemoteDeflateServer = new Uri("http://" + Host + "/" + DeflateHandler);
public static readonly Uri RemoteGZipServer = new Uri("http://" + Host + "/" + GZipHandler);
public static readonly Uri Http2RemoteDeflateServer = new Uri("https://" + Http2Host + "/" + DeflateHandler);
public static readonly Uri Http2RemoteGZipServer = new Uri("https://" + Http2Host + "/" + GZipHandler);
public static readonly Uri Http2RemoteDeflateServer = new Uri("https://" + Http2SecureHost + "/" + DeflateHandler);
public static readonly Uri Http2RemoteGZipServer = new Uri("https://" + Http2SecureHost + "/" + GZipHandler);

public static readonly object[][] EchoServers = EchoServerList.Select(x => new object[] { x }).ToArray();
public static readonly object[][] VerifyUploadServers = { new object[] { RemoteVerifyUploadServer }, new object[] { SecureRemoteVerifyUploadServer }, new object[] { Http2RemoteVerifyUploadServer } };
public static readonly object[][] CompressedServers = { new object[] { RemoteDeflateServer }, new object[] { RemoteGZipServer }, new object[] { Http2RemoteDeflateServer }, new object[] { Http2RemoteGZipServer } };

public static readonly object[][] Http2Servers = { new object[] { new Uri("https://" + Http2Host) } };
public static readonly object[][] Http2Servers = { new object[] { new Uri("https://" + Http2SecureHost) } };
public static readonly object[][] Http2NoPushServers = { new object[] { new Uri("https://" + Http2NoPushHost) } };

public static readonly RemoteServer RemoteHttp11Server = new RemoteServer(new Uri("http://" + Host + "/"), HttpVersion.Version11);
public static readonly RemoteServer RemoteSecureHttp11Server = new RemoteServer(new Uri("https://" + SecureHost + "/"), HttpVersion.Version11);
public static readonly RemoteServer RemoteHttp2Server = new RemoteServer(new Uri("https://" + Http2Host + "/"), new Version(2, 0));
public static readonly RemoteServer RemoteSecureHttp2Server = new RemoteServer(new Uri("https://" + Http2SecureHost + "/"), new Version(2, 0));
public static readonly RemoteServer RemoteHttp2Server = new RemoteServer(new Uri("http://" + Http2Host + "/"), new Version(2, 0));

public static readonly IEnumerable<RemoteServer> RemoteServers = new RemoteServer[] { RemoteHttp11Server, RemoteSecureHttp11Server, RemoteHttp2Server };
public static readonly IEnumerable<RemoteServer> RemoteServers = new RemoteServer[] { RemoteHttp11Server, RemoteSecureHttp11Server, RemoteSecureHttp2Server };

public static readonly IEnumerable<object[]> RemoteServersMemberData = RemoteServers.Select(s => new object[] { s });

Expand Down
19 changes: 19 additions & 0 deletions src/libraries/Common/tests/System/Net/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading