Skip to content

Commit c450fd0

Browse files
davidshakoeplinger
authored andcommitted
Clean up some tests and move to new Azure endpoint (dotnet#41603)
* Test only fixes * Port PR dotnet#36018 from master branch This PR changes the Azure test endpoint to use Azure App Service instead of the classic Azure Cloud Service endpoint. The use of the classic Azure Cloud Service is no longer recommended since it is harder to maintain. Once all remaining branches are converted, we will shut down the corefx-net.cloudapp.net endpoint. This PR also includes some other test fixes and tests disabled due to active issues.
1 parent 3baa35f commit c450fd0

9 files changed

Lines changed: 47 additions & 33 deletions

File tree

src/Common/tests/System/Net/Configuration.Http.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public static partial class Configuration
88
{
99
public static partial class Http
1010
{
11-
private static readonly string DefaultAzureServer = "corefx-net.cloudapp.net";
11+
private static readonly string DefaultAzureServer = "corefx-net-http11.azurewebsites.net";
1212

1313
public static string Host => GetValue("COREFX_HTTPHOST", DefaultAzureServer);
1414

src/Common/tests/System/Net/Configuration.Security.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public static partial class Configuration
88
{
99
public static partial class Security
1010
{
11-
private static readonly string DefaultAzureServer = "corefx-net.cloudapp.net";
11+
private static readonly string DefaultAzureServer = "corefx-net-http11.azurewebsites.net";
1212

1313
public static string ActiveDirectoryName => GetValue("COREFX_NET_AD_DOMAINNAME");
1414

src/Common/tests/System/Net/Configuration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace System.Net.Test.Common
77
public static partial class Configuration
88
{
99
#pragma warning disable 414
10-
private static readonly string DefaultAzureServer = "corefx-net.cloudapp.net";
10+
private static readonly string DefaultAzureServer = "corefx-net-http11.azurewebsites.net";
1111
#pragma warning restore 414
1212

1313
private static string GetValue(string envName, string defaultValue=null)

src/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.ServerCertificates.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ public async Task NoCallback_BadCertificate_ThrowsException(string url)
311311
}
312312
}
313313

314+
[ActiveIssue(41108)]
314315
[SkipOnTargetFramework(TargetFrameworkMonikers.Uap, "UAP doesn't allow revocation checking to be turned off")]
315316
[OuterLoop] // TODO: Issue #11345
316317
[ConditionalFact(nameof(ClientSupportsDHECipherSuites), nameof(BackendSupportsX509Chain))]

src/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2701,17 +2701,16 @@ public async Task PostAsync_ReuseRequestContent_Success(Uri remoteServer)
27012701
[InlineData(HttpStatusCode.MethodNotAllowed, "")]
27022702
public async Task GetAsync_CallMethod_ExpectedStatusLine(HttpStatusCode statusCode, string reasonPhrase)
27032703
{
2704-
using (HttpClient client = CreateHttpClient())
2704+
await LoopbackServer.CreateClientAndServerAsync(async uri =>
27052705
{
2706-
using (HttpResponseMessage response = await client.GetAsync(Configuration.Http.StatusCodeUri(
2707-
false,
2708-
(int)statusCode,
2709-
reasonPhrase)))
2706+
using (HttpClient client = CreateHttpClient())
2707+
using (HttpResponseMessage response = await client.GetAsync(uri))
27102708
{
27112709
Assert.Equal(statusCode, response.StatusCode);
27122710
Assert.Equal(reasonPhrase, response.ReasonPhrase);
27132711
}
2714-
}
2712+
}, server => server.AcceptConnectionSendCustomResponseAndCloseAsync(
2713+
$"HTTP/1.1 {(int)statusCode} {reasonPhrase}\r\nContent-Length: 0\r\n\r\n"));
27152714
}
27162715

27172716
#endregion

src/System.Net.Requests/tests/HttpWebRequestTest.cs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -456,31 +456,35 @@ public void KeepAlive_SetThenGetBoolean_ValuesMatch(Uri remoteServer)
456456
[InlineData(false)]
457457
[InlineData(true)]
458458
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "dotnet/corefx #19225")]
459-
public void KeepAlive_CorrectConnectionHeaderSent(bool? keepAlive)
459+
public async Task KeepAlive_CorrectConnectionHeaderSent(bool? keepAlive)
460460
{
461-
HttpWebRequest request = WebRequest.CreateHttp(Test.Common.Configuration.Http.RemoteEchoServer);
462-
463-
if (keepAlive.HasValue)
461+
await LoopbackServer.CreateServerAsync(async (server, url) =>
464462
{
465-
request.KeepAlive = keepAlive.Value;
466-
}
463+
HttpWebRequest request = WebRequest.CreateHttp(url);
464+
request.Proxy = null; // Don't use a proxy since it might interfere with the Connection: headers.
465+
if (keepAlive.HasValue)
466+
{
467+
request.KeepAlive = keepAlive.Value;
468+
}
467469

468-
using (var response = (HttpWebResponse)request.GetResponse())
469-
using (var body = new StreamReader(response.GetResponseStream()))
470-
{
471-
string content = body.ReadToEnd();
470+
Task<WebResponse> getResponseTask = request.GetResponseAsync();
471+
Task<List<string>> serverTask = server.AcceptConnectionSendResponseAndCloseAsync();
472+
473+
await TaskTimeoutExtensions.WhenAllOrAnyFailed(new Task[] { getResponseTask, serverTask });
474+
475+
List<string> requestLines = await serverTask;
472476
if (!keepAlive.HasValue || keepAlive.Value)
473477
{
474-
// Validate that the request doesn't contain Connection: "close", but we can't validate
475-
// that it does contain Connection: "keep-alive", as that's optional as of HTTP 1.1.
476-
Assert.DoesNotContain("\"Connection\": \"close\"", content, StringComparison.OrdinalIgnoreCase);
478+
// Validate that the request doesn't contain "Connection: close", but we can't validate
479+
// that it does contain "Connection: Keep-Alive", as that's optional as of HTTP 1.1.
480+
Assert.DoesNotContain("Connection: close", requestLines, StringComparer.OrdinalIgnoreCase);
477481
}
478482
else
479483
{
480-
Assert.Contains("\"Connection\": \"close\"", content, StringComparison.OrdinalIgnoreCase);
481-
Assert.DoesNotContain("\"Keep-Alive\"", content, StringComparison.OrdinalIgnoreCase);
484+
Assert.Contains("Connection: close", requestLines, StringComparer.OrdinalIgnoreCase);
485+
Assert.DoesNotContain("Keep-Alive", requestLines, StringComparer.OrdinalIgnoreCase);
482486
}
483-
}
487+
});
484488
}
485489

486490
[Theory, MemberData(nameof(EchoServers))]

src/System.Net.WebClient/tests/WebClientTest.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System;
6+
using System.Collections.Generic;
67
using System.Collections.Specialized;
78
using System.IO;
89
using System.Linq;
@@ -15,6 +16,8 @@
1516

1617
namespace System.Net.Tests
1718
{
19+
using Configuration = System.Net.Test.Common.Configuration;
20+
1821
public class WebClientTest
1922
{
2023
[Fact]
@@ -393,21 +396,26 @@ public static async Task RequestHeaders_AddDisallowedHeaderAndSendRequest_Throws
393396
await Assert.ThrowsAsync<WebException>(() => wc.DownloadStringTaskAsync(System.Net.Test.Common.Configuration.Http.RemoteEchoServer));
394397
}
395398

396-
[OuterLoop("Networking test talking to remote server: issue #11345")]
399+
public static IEnumerable<object[]> RequestHeaders_AddHostHeaderAndSendRequest_ExpectedResult_MemberData()
400+
{
401+
yield return new object[] { $"http://{Configuration.Http.Host}", true };
402+
yield return new object[] { Configuration.Http.Host, false };
403+
}
404+
405+
[OuterLoop("Uses external servers")]
397406
[Theory]
398-
[InlineData("http://localhost", true)]
399-
[InlineData("localhost", false)]
407+
[MemberData(nameof(RequestHeaders_AddHostHeaderAndSendRequest_ExpectedResult_MemberData))]
400408
public static async Task RequestHeaders_AddHostHeaderAndSendRequest_ExpectedResult(string hostHeaderValue, bool throwsWebException)
401409
{
402410
var wc = new WebClient();
403411
wc.Headers["Host"] = hostHeaderValue;
404412
if (throwsWebException)
405413
{
406-
await Assert.ThrowsAsync<WebException>(() => wc.DownloadStringTaskAsync(System.Net.Test.Common.Configuration.Http.RemoteEchoServer));
414+
await Assert.ThrowsAsync<WebException>(() => wc.DownloadStringTaskAsync(Configuration.Http.RemoteEchoServer));
407415
}
408416
else
409417
{
410-
await wc.DownloadStringTaskAsync(System.Net.Test.Common.Configuration.Http.RemoteEchoServer);
418+
await wc.DownloadStringTaskAsync(Configuration.Http.RemoteEchoServer);
411419
}
412420
}
413421

src/System.Net.WebSockets.Client/tests/CloseTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class CloseTest : ClientWebSocketTestBase
1717
{
1818
public CloseTest(ITestOutputHelper output) : base(output) { }
1919

20+
[ActiveIssue(36016)]
2021
[OuterLoop] // TODO: Issue #11345
2122
[ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))]
2223
public async Task CloseAsync_ServerInitiatedClose_Success(Uri server)
@@ -194,6 +195,7 @@ public async Task CloseOutputAsync_ClientInitiated_CanReceive_CanClose(Uri serve
194195
}
195196
}
196197

198+
[ActiveIssue(36016)]
197199
[OuterLoop] // TODO: Issue #11345
198200
[ConditionalTheory(nameof(WebSocketsSupported)), MemberData(nameof(EchoServers))]
199201
public async Task CloseOutputAsync_ServerInitiated_CanSend(Uri server)

src/System.Net.WebSockets.Client/tests/ConnectTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ public async Task ConnectAsync_AddHostHeader_Success()
9292
{
9393
Uri server = System.Net.Test.Common.Configuration.WebSockets.RemoteEchoServer;
9494

95-
// Send via the physical address such as "corefx-net.cloudapp.net"
96-
// Set the Host header to logical address like "subdomain.corefx-net.cloudapp.net"
97-
// Verify the scenario works and the remote server received "Host: subdomain.corefx-net.cloudapp.net"
95+
// Send via the physical address such as "corefx-net-http11.azurewebsites.net"
96+
// Set the Host header to logical address like "subdomain.corefx-net-http11.azurewebsites.net"
97+
// Verify the scenario works and the remote server received "Host: subdomain.corefx-net-http11.azurewebsites.net"
9898
string logicalHost = "subdomain." + server.Host;
9999

100100
using (var cws = new ClientWebSocket())

0 commit comments

Comments
 (0)