diff --git a/test/DeploymentHelpers/Common/RetryHelper.cs b/test/DeploymentHelpers/Common/RetryHelper.cs index 4be9fb946b..7f392c5598 100644 --- a/test/DeploymentHelpers/Common/RetryHelper.cs +++ b/test/DeploymentHelpers/Common/RetryHelper.cs @@ -2,6 +2,7 @@ using System.Net; using System.Net.Http; using System.Threading; +using System.Threading.Tasks; using Microsoft.Framework.Logging; namespace DeploymentHelpers @@ -15,8 +16,8 @@ namespace DeploymentHelpers /// /// /// - public static HttpResponseMessage RetryRequest( - Func retryBlock, + public static async Task RetryRequest( + Func> retryBlock, ILogger logger, CancellationToken cancellationToken = default(CancellationToken), int retryCount = 60) @@ -31,7 +32,7 @@ namespace DeploymentHelpers } logger.LogWarning("Retry count {retryCount}..", retry + 1); - var response = retryBlock(); + var response = await retryBlock(); if (response.StatusCode == HttpStatusCode.ServiceUnavailable) { diff --git a/test/E2ETests/NtlmAuthentationTest.cs b/test/E2ETests/NtlmAuthentationTest.cs index 537703dfca..24cd95f193 100644 --- a/test/E2ETests/NtlmAuthentationTest.cs +++ b/test/E2ETests/NtlmAuthentationTest.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Net.Http; +using System.Threading.Tasks; using DeploymentHelpers; using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.Logging; @@ -17,7 +18,7 @@ namespace E2ETests [InlineData(ServerType.IISExpress, RuntimeFlavor.coreclr, RuntimeArchitecture.x86, "http://localhost:5050/")] [InlineData(ServerType.IISExpress, RuntimeFlavor.clr, RuntimeArchitecture.x64, "http://localhost:5051/")] [InlineData(ServerType.WebListener, RuntimeFlavor.coreclr, RuntimeArchitecture.x64, "http://localhost:5052/")] - public void NtlmAuthenticationTest(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) + public async Task NtlmAuthenticationTest(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) { var logger = new LoggerFactory() .AddConsole() @@ -57,9 +58,9 @@ namespace E2ETests var httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) }; // Request to base address and check if various parts of the body are rendered & measure the cold startup time. - var response = RetryHelper.RetryRequest(() => + var response = await RetryHelper.RetryRequest(async () => { - return httpClient.GetAsync(string.Empty).Result; + return await httpClient.GetAsync(string.Empty); }, logger: logger, cancellationToken: deploymentResult.HostShutdownToken); var validator = new Validator(httpClient, httpClientHandler, logger, deploymentResult); diff --git a/test/E2ETests/OpenIdConnectTests.cs b/test/E2ETests/OpenIdConnectTests.cs index 6366f884fd..1f7454484c 100644 --- a/test/E2ETests/OpenIdConnectTests.cs +++ b/test/E2ETests/OpenIdConnectTests.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Net.Http; +using System.Threading.Tasks; using DeploymentHelpers; using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.Logging; @@ -15,20 +16,20 @@ namespace E2ETests [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData(ServerType.IISExpress, RuntimeFlavor.clr, RuntimeArchitecture.x86, "http://localhost:5040/")] [InlineData(ServerType.IISExpress, RuntimeFlavor.coreclr, RuntimeArchitecture.x64, "http://localhost:5041/")] - public void OpenIdConnect_OnX86(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) + public async Task OpenIdConnect_OnX86(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) { - OpenIdConnectTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); + await OpenIdConnectTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); } [ConditionalTheory, Trait("E2Etests", "E2Etests")] [FrameworkSkipCondition(RuntimeFrameworks.DotNet)] [InlineData(ServerType.Kestrel, RuntimeFlavor.mono, RuntimeArchitecture.x86, "http://localhost:5042/")] - public void OpenIdConnect_OnMono(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) + public async Task OpenIdConnect_OnMono(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) { - OpenIdConnectTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); + await OpenIdConnectTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); } - private void OpenIdConnectTestSuite(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) + private async Task OpenIdConnectTestSuite(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) { var logger = new LoggerFactory() .AddConsole() @@ -66,9 +67,9 @@ namespace E2ETests var httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) }; // Request to base address and check if various parts of the body are rendered & measure the cold startup time. - var response = RetryHelper.RetryRequest(() => + var response = await RetryHelper.RetryRequest(async () => { - return httpClient.GetAsync(string.Empty).Result; + return await httpClient.GetAsync(string.Empty); }, logger: logger, cancellationToken: deploymentResult.HostShutdownToken); var validator = new Validator(httpClient, httpClientHandler, logger, deploymentResult); diff --git a/test/E2ETests/PublishAndRunTests.cs b/test/E2ETests/PublishAndRunTests.cs index 4c8fe841af..d12e180f7f 100644 --- a/test/E2ETests/PublishAndRunTests.cs +++ b/test/E2ETests/PublishAndRunTests.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Net.Http; +using System.Threading.Tasks; using DeploymentHelpers; using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.Logging; @@ -17,10 +18,10 @@ namespace E2ETests [InlineData(ServerType.WebListener, RuntimeFlavor.clr, RuntimeArchitecture.x64, "http://localhost:5025/", false)] //https://github.com/aspnet/KRuntime/issues/642 //[InlineData(ServerType.Helios, RuntimeFlavor.CoreClr, RuntimeArchitecture.amd64, "http://localhost:5026/")] - public void Publish_And_Run_Tests_On_AMD64(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, bool noSource) + public async Task Publish_And_Run_Tests_On_AMD64(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, bool noSource) { var testRunner = new PublishAndRunTests(); - testRunner.Publish_And_Run_Tests(serverType, runtimeFlavor, architecture, applicationBaseUrl, noSource); + await testRunner.Publish_And_Run_Tests(serverType, runtimeFlavor, architecture, applicationBaseUrl, noSource); } } @@ -30,26 +31,26 @@ namespace E2ETests [FrameworkSkipCondition(RuntimeFrameworks.Mono)] [InlineData(ServerType.IISExpress, RuntimeFlavor.clr, RuntimeArchitecture.x86, "http://localhost:5027/", false)] [InlineData(ServerType.IISExpress, RuntimeFlavor.clr, RuntimeArchitecture.x86, "http://localhost:5028/", true)] - public void Publish_And_Run_Tests_On_X86(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, bool noSource) + public async Task Publish_And_Run_Tests_On_X86(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, bool noSource) { var testRunner = new PublishAndRunTests(); - testRunner.Publish_And_Run_Tests(serverType, runtimeFlavor, architecture, applicationBaseUrl, noSource); + await testRunner.Publish_And_Run_Tests(serverType, runtimeFlavor, architecture, applicationBaseUrl, noSource); } [ConditionalTheory, Trait("E2Etests", "E2Etests")] [FrameworkSkipCondition(RuntimeFrameworks.DotNet)] [InlineData(ServerType.Kestrel, RuntimeFlavor.mono, RuntimeArchitecture.x86, "http://localhost:5029/", false)] [InlineData(ServerType.Kestrel, RuntimeFlavor.mono, RuntimeArchitecture.x86, "http://localhost:5030/", true)] - public void Publish_And_Run_Tests_On_Mono(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, bool noSource) + public async Task Publish_And_Run_Tests_On_Mono(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, bool noSource) { var testRunner = new PublishAndRunTests(); - testRunner.Publish_And_Run_Tests(serverType, runtimeFlavor, architecture, applicationBaseUrl, noSource); + await testRunner.Publish_And_Run_Tests(serverType, runtimeFlavor, architecture, applicationBaseUrl, noSource); } } public class PublishAndRunTests { - public void Publish_And_Run_Tests(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, bool noSource) + public async Task Publish_And_Run_Tests(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl, bool noSource) { var logger = new LoggerFactory() .AddConsole() @@ -89,9 +90,9 @@ namespace E2ETests // Request to base address and check if various parts of the body are rendered & measure the cold startup time. // Add retry logic since tests are flaky on mono due to connection issues - var response = RetryHelper.RetryRequest(() => + var response = await RetryHelper.RetryRequest(async () => { - return httpClient.GetAsync(string.Empty).Result; + return await httpClient.GetAsync(string.Empty); }, logger: logger, cancellationToken: deploymentResult.HostShutdownToken); var validator = new Validator(httpClient, httpClientHandler, logger, deploymentResult); diff --git a/test/E2ETests/SmokeTests.cs b/test/E2ETests/SmokeTests.cs index c0f2927dd0..715118909c 100644 --- a/test/E2ETests/SmokeTests.cs +++ b/test/E2ETests/SmokeTests.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Net.Http; +using System.Threading.Tasks; using DeploymentHelpers; using Microsoft.AspNet.Testing.xunit; using Microsoft.Framework.Logging; @@ -16,10 +17,10 @@ namespace E2ETests [InlineData(ServerType.IISExpress, RuntimeFlavor.clr, RuntimeArchitecture.x86, "http://localhost:5001/")] [InlineData(ServerType.WebListener, RuntimeFlavor.clr, RuntimeArchitecture.x86, "http://localhost:5002/")] [InlineData(ServerType.Kestrel, RuntimeFlavor.clr, RuntimeArchitecture.x86, "http://localhost:5003/")] - public void SmokeTestSuite_OnX86_clr(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) + public async Task SmokeTestSuite_OnX86_clr(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) { var smokeTestRunner = new SmokeTests(); - smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); + await smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); } } @@ -30,10 +31,10 @@ namespace E2ETests [InlineData(ServerType.IISExpress, RuntimeFlavor.coreclr, RuntimeArchitecture.x86, "http://localhost:5004/")] [InlineData(ServerType.WebListener, RuntimeFlavor.coreclr, RuntimeArchitecture.x86, "http://localhost:5005/")] [InlineData(ServerType.Kestrel, RuntimeFlavor.coreclr, RuntimeArchitecture.x86, "http://localhost:5006/")] - public void SmokeTestSuite_OnX86_coreclr(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) + public async Task SmokeTestSuite_OnX86_coreclr(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) { var smokeTestRunner = new SmokeTests(); - smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); + await smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); } } @@ -45,10 +46,10 @@ namespace E2ETests [InlineData(ServerType.WebListener, RuntimeFlavor.clr, RuntimeArchitecture.x64, "http://localhost:5007/")] [InlineData(ServerType.IISExpress, RuntimeFlavor.coreclr, RuntimeArchitecture.x64, "http://localhost:5008/")] [InlineData(ServerType.Kestrel, RuntimeFlavor.coreclr, RuntimeArchitecture.x64, "http://localhost:5009/")] - public void SmokeTestSuite_OnAMD64(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) + public async Task SmokeTestSuite_OnAMD64(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) { var smokeTestRunner = new SmokeTests(); - smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); + await smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); } } @@ -57,10 +58,10 @@ namespace E2ETests [ConditionalTheory, Trait("E2Etests", "E2Etests")] [FrameworkSkipCondition(RuntimeFrameworks.DotNet)] [InlineData(ServerType.Kestrel, RuntimeFlavor.mono, RuntimeArchitecture.x86, "http://localhost:5010/")] - public void SmokeTestSuite_OnMono(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) + public async Task SmokeTestSuite_OnMono(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) { var smokeTestRunner = new SmokeTests(); - smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); + await smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); } } @@ -72,10 +73,10 @@ namespace E2ETests [OSSkipCondition(OperatingSystems.Win7And2008R2 | OperatingSystems.MacOSX | OperatingSystems.Unix)] [SkipIfCurrentRuntimeIsCoreClr] [InlineData(ServerType.IISNativeModule, RuntimeFlavor.coreclr, RuntimeArchitecture.x86, "http://localhost:5011/")] - public void SmokeTestSuite_On_NativeModule_X86(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) + public async Task SmokeTestSuite_On_NativeModule_X86(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) { var smokeTestRunner = new SmokeTests(); - smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); + await smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); } [ConditionalTheory, Trait("E2Etests", "E2Etests")] @@ -85,10 +86,10 @@ namespace E2ETests [SkipOn32BitOS] [SkipIfCurrentRuntimeIsCoreClr] [InlineData(ServerType.IISNativeModule, RuntimeFlavor.coreclr, RuntimeArchitecture.x64, "http://localhost:5012/")] - public void SmokeTestSuite_On_NativeModule_AMD64(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) + public async Task SmokeTestSuite_On_NativeModule_AMD64(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) { var smokeTestRunner = new SmokeTests(); - smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); + await smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl); } } @@ -101,16 +102,16 @@ namespace E2ETests [SkipIfIISVariationsNotEnabled] [InlineData(ServerType.IIS, RuntimeFlavor.clr, RuntimeArchitecture.x86, "http://localhost:5013/")] [InlineData(ServerType.IIS, RuntimeFlavor.coreclr, RuntimeArchitecture.x64, "http://localhost:5013/")] - public void SmokeTestSuite_On_IIS_X86(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) + public async Task SmokeTestSuite_On_IIS_X86(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, string applicationBaseUrl) { var smokeTestRunner = new SmokeTests(); - smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl, noSource: true); + await smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl, noSource: true); } } public class SmokeTests { - public void SmokeTestSuite( + public async Task SmokeTestSuite( ServerType serverType, RuntimeFlavor donetFlavor, RuntimeArchitecture architecture, @@ -157,9 +158,9 @@ namespace E2ETests var httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) }; // Request to base address and check if various parts of the body are rendered & measure the cold startup time. - var response = RetryHelper.RetryRequest(() => + var response = await RetryHelper.RetryRequest(async () => { - return httpClient.GetAsync(string.Empty).Result; + return await httpClient.GetAsync(string.Empty); }, logger: logger, cancellationToken: deploymentResult.HostShutdownToken); var validator = new Validator(httpClient, httpClientHandler, logger, deploymentResult);