From d6f410bf42e898d742bf6d146917706357f1ae4f Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Thu, 9 Aug 2018 09:21:02 -0700 Subject: [PATCH 1/4] Add locked app_oflline file test and remove retrying client (#1178) * Add locked app_oflline file test and remove retrying client * Write bytes to file --- .../IISDeploymentResult.cs | 14 ---------- .../Common.FunctionalTests/AppOfflineTests.cs | 27 ++++++++++++++++++- .../Inprocess/LoggingTests.cs | 8 +++--- .../Inprocess/StartupExceptionTests.cs | 4 +-- .../OutOfProcess/HelloWorldTest.cs | 2 +- .../Utilities/Helpers.cs | 4 +-- .../InProcess/AuthenticationTests.cs | 8 +++--- .../InProcess/ShutdownTests.cs | 4 +-- .../InProcess/StartupTests.cs | 8 +++--- .../OutOfProcess/GlobalVersionTests.cs | 18 ++++++------- .../OutOfProcess/HttpsTest.cs | 4 +-- .../OutOfProcess/NtlmAuthentationTest.cs | 2 +- .../UpgradeFeatureDetectionTests.cs | 2 +- 13 files changed, 58 insertions(+), 47 deletions(-) diff --git a/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISDeploymentResult.cs b/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISDeploymentResult.cs index 4a9d881900..814a778c16 100644 --- a/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISDeploymentResult.cs +++ b/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISDeploymentResult.cs @@ -27,21 +27,9 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS { HostProcess = hostProcess; Logger = loggerFactory.CreateLogger(deploymentParameters.SiteName); - // SocketsHttpHandler isn't available in netstandard2.0 - RetryingHttpClient = CreateRetryClient(new HttpClientHandler()); HttpClient = CreateClient(new HttpClientHandler()); } - public HttpClient CreateRetryClient(HttpMessageHandler messageHandler) - { - var loggingHandler = new LoggingHandler(messageHandler, Logger); - var retryHandler = new RetryHandler(loggingHandler, Logger); - return new HttpClient(retryHandler) - { - BaseAddress = base.HttpClient.BaseAddress - }; - } - public HttpClient CreateClient(HttpMessageHandler messageHandler) { return new HttpClient(new LoggingHandler(messageHandler, Logger)) @@ -50,8 +38,6 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS }; } - public HttpClient RetryingHttpClient { get; set; } - public new HttpClient HttpClient { get; set; } } } diff --git a/test/Common.FunctionalTests/AppOfflineTests.cs b/test/Common.FunctionalTests/AppOfflineTests.cs index c191eea4c7..3e1580fcb9 100644 --- a/test/Common.FunctionalTests/AppOfflineTests.cs +++ b/test/Common.FunctionalTests/AppOfflineTests.cs @@ -42,6 +42,25 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests DeletePublishOutput(deploymentResult); } + [ConditionalTheory] + [InlineData(HostingModel.InProcess)] + [InlineData(HostingModel.OutOfProcess)] + public async Task LockedAppOfflineDroppedWhileSiteIsDown_SiteReturns503(HostingModel hostingModel) + { + var deploymentResult = await DeployApp(hostingModel); + + // Add app_offline without shared access + using (var stream = File.Open(Path.Combine(deploymentResult.ContentRoot, "app_offline.htm"), FileMode.CreateNew, FileAccess.ReadWrite, FileShare.None)) + using (var writer = new StreamWriter(stream)) + { + await writer.WriteLineAsync("App if offline but you wouldn't see this message"); + await writer.FlushAsync(); + await AssertAppOffline(deploymentResult, ""); + } + + DeletePublishOutput(deploymentResult); + } + [ConditionalTheory] [InlineData(HostingModel.InProcess, 500, "500.0")] [InlineData(HostingModel.OutOfProcess, 502, "502.5")] @@ -259,7 +278,13 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests private static async Task AssertRunning(IISDeploymentResult deploymentResult) { - var response = await deploymentResult.RetryingHttpClient.GetAsync("HelloWorld"); + HttpResponseMessage response = null; + + for (var i = 0; i < 5 && response?.IsSuccessStatusCode != true; i++) + { + response = await deploymentResult.HttpClient.GetAsync("HelloWorld"); + await Task.Delay(RetryDelay); + } var responseText = await response.Content.ReadAsStringAsync(); Assert.Equal("Hello World", responseText); diff --git a/test/Common.FunctionalTests/Inprocess/LoggingTests.cs b/test/Common.FunctionalTests/Inprocess/LoggingTests.cs index 6710fb7f47..0a19a90133 100644 --- a/test/Common.FunctionalTests/Inprocess/LoggingTests.cs +++ b/test/Common.FunctionalTests/Inprocess/LoggingTests.cs @@ -93,7 +93,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests var deploymentResult = await DeployAsync(deploymentParameters); - await deploymentResult.RetryingHttpClient.GetAsync("/"); + await deploymentResult.HttpClient.GetAsync("/"); AssertLogs(Path.Combine(deploymentResult.ContentRoot, "debug.txt")); } @@ -106,7 +106,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests var deploymentResult = await DeployAsync(deploymentParameters); - await deploymentResult.RetryingHttpClient.GetAsync("/"); + await deploymentResult.HttpClient.GetAsync("/"); AssertLogs(Path.Combine(deploymentResult.ContentRoot, "aspnetcore-debug.log")); } @@ -121,7 +121,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests deploymentParameters.HandlerSettings["debugFile"] = ""; var deploymentResult = await DeployAsync(deploymentParameters); - await deploymentResult.RetryingHttpClient.GetAsync("/"); + await deploymentResult.HttpClient.GetAsync("/"); AssertLogs(Path.Combine(deploymentResult.ContentRoot, "aspnetcore-debug.log")); } @@ -186,7 +186,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests var deploymentResult = await DeployAsync(deploymentParameters); - var response = await deploymentResult.RetryingHttpClient.GetAsync("/"); + var response = await deploymentResult.HttpClient.GetAsync("/"); StopServer(); var logContents = File.ReadAllText(firstTempFile); diff --git a/test/Common.FunctionalTests/Inprocess/StartupExceptionTests.cs b/test/Common.FunctionalTests/Inprocess/StartupExceptionTests.cs index 980341dbc4..1234d368fc 100644 --- a/test/Common.FunctionalTests/Inprocess/StartupExceptionTests.cs +++ b/test/Common.FunctionalTests/Inprocess/StartupExceptionTests.cs @@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests var deploymentResult = await DeployAsync(deploymentParameters); - var response = await deploymentResult.RetryingHttpClient.GetAsync(path); + var response = await deploymentResult.HttpClient.GetAsync(path); Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode); @@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests var deploymentResult = await DeployAsync(deploymentParameters); - var response = await deploymentResult.RetryingHttpClient.GetAsync(path); + var response = await deploymentResult.HttpClient.GetAsync(path); Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode); diff --git a/test/Common.FunctionalTests/OutOfProcess/HelloWorldTest.cs b/test/Common.FunctionalTests/OutOfProcess/HelloWorldTest.cs index d2a56caea5..0b05ff54db 100644 --- a/test/Common.FunctionalTests/OutOfProcess/HelloWorldTest.cs +++ b/test/Common.FunctionalTests/OutOfProcess/HelloWorldTest.cs @@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests var deploymentResult = await DeployAsync(deploymentParameters); - var response = await deploymentResult.RetryingHttpClient.GetAsync("/HelloWorld"); + var response = await deploymentResult.HttpClient.GetAsync("/HelloWorld"); var responseText = await response.Content.ReadAsStringAsync(); Assert.Equal("Hello World", responseText); diff --git a/test/Common.FunctionalTests/Utilities/Helpers.cs b/test/Common.FunctionalTests/Utilities/Helpers.cs index 77eb37d524..73d48fd6ca 100644 --- a/test/Common.FunctionalTests/Utilities/Helpers.cs +++ b/test/Common.FunctionalTests/Utilities/Helpers.cs @@ -25,11 +25,11 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests public static string GetInProcessTestSitesPath() => GetTestWebSitePath("InProcessWebSite"); public static string GetOutOfProcessTestSitesPath() => GetTestWebSitePath("OutOfProcessWebSite"); - + public static async Task AssertStarts(IISDeploymentResult deploymentResult, string path = "/HelloWorld") { - var response = await deploymentResult.RetryingHttpClient.GetAsync(path); + var response = await deploymentResult.HttpClient.GetAsync(path); var responseText = await response.Content.ReadAsStringAsync(); diff --git a/test/IISExpress.FunctionalTests/InProcess/AuthenticationTests.cs b/test/IISExpress.FunctionalTests/InProcess/AuthenticationTests.cs index af442c4521..333a7a055b 100644 --- a/test/IISExpress.FunctionalTests/InProcess/AuthenticationTests.cs +++ b/test/IISExpress.FunctionalTests/InProcess/AuthenticationTests.cs @@ -29,26 +29,26 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests var deploymentResult = await DeployAsync(deploymentParameters); - var response = await deploymentResult.RetryingHttpClient.GetAsync("/AuthenticationAnonymous"); + var response = await deploymentResult.HttpClient.GetAsync("/AuthenticationAnonymous"); var responseText = await response.Content.ReadAsStringAsync(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("Anonymous?True", responseText); - response = await deploymentResult.RetryingHttpClient.GetAsync("/AuthenticationRestricted"); + response = await deploymentResult.HttpClient.GetAsync("/AuthenticationRestricted"); responseText = await response.Content.ReadAsStringAsync(); Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); Assert.Contains("NTLM", response.Headers.WwwAuthenticate.ToString()); Assert.Contains("Negotiate", response.Headers.WwwAuthenticate.ToString()); - response = await deploymentResult.RetryingHttpClient.GetAsync("/AuthenticationRestrictedNTLM"); + response = await deploymentResult.HttpClient.GetAsync("/AuthenticationRestrictedNTLM"); responseText = await response.Content.ReadAsStringAsync(); Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); Assert.Contains("NTLM", response.Headers.WwwAuthenticate.ToString()); // Note we can't restrict a challenge to a specific auth type, the native auth modules always add themselves. Assert.Contains("Negotiate", response.Headers.WwwAuthenticate.ToString()); - response = await deploymentResult.RetryingHttpClient.GetAsync("/AuthenticationForbidden"); + response = await deploymentResult.HttpClient.GetAsync("/AuthenticationForbidden"); responseText = await response.Content.ReadAsStringAsync(); Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode); diff --git a/test/IISExpress.FunctionalTests/InProcess/ShutdownTests.cs b/test/IISExpress.FunctionalTests/InProcess/ShutdownTests.cs index 1e397731e7..d9dbcd2b6e 100644 --- a/test/IISExpress.FunctionalTests/InProcess/ShutdownTests.cs +++ b/test/IISExpress.FunctionalTests/InProcess/ShutdownTests.cs @@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests parameters.GracefulShutdown = true; var result = await DeployAsync(parameters); - var response = await result.RetryingHttpClient.GetAsync("/HelloWorld"); + var response = await result.HttpClient.GetAsync("/HelloWorld"); StopServer(); Assert.True(result.HostProcess.ExitCode == 0); } @@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests var parameters = _fixture.GetBaseDeploymentParameters(publish: true); var result = await DeployAsync(parameters); - var response = await result.RetryingHttpClient.GetAsync("/HelloWorld"); + var response = await result.HttpClient.GetAsync("/HelloWorld"); StopServer(); Assert.True(result.HostProcess.ExitCode == 1); } diff --git a/test/IISExpress.FunctionalTests/InProcess/StartupTests.cs b/test/IISExpress.FunctionalTests/InProcess/StartupTests.cs index 218cb4b174..89c17d8492 100644 --- a/test/IISExpress.FunctionalTests/InProcess/StartupTests.cs +++ b/test/IISExpress.FunctionalTests/InProcess/StartupTests.cs @@ -51,7 +51,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests var deploymentResult = await DeployAsync(deploymentParameters); - var response = await deploymentResult.RetryingHttpClient.GetAsync("HelloWorld"); + var response = await deploymentResult.HttpClient.GetAsync("HelloWorld"); Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode); @@ -108,7 +108,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests var deploymentResult = await DeployAsync(deploymentParameters); - var response = await deploymentResult.RetryingHttpClient.GetAsync("HelloWorld"); + var response = await deploymentResult.HttpClient.GetAsync("HelloWorld"); var responseText = await response.Content.ReadAsStringAsync(); Assert.Equal("Hello World", responseText); @@ -128,7 +128,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests var deploymentResult = await DeployAsync(deploymentParameters); - var response = await deploymentResult.RetryingHttpClient.GetAsync("/HelloWorld"); + var response = await deploymentResult.HttpClient.GetAsync("/HelloWorld"); var responseText = await response.Content.ReadAsStringAsync(); Assert.Equal("Hello World", responseText); @@ -154,7 +154,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests var deploymentResult = await DeployAsync(deploymentParameters); - var response = await deploymentResult.RetryingHttpClient.GetAsync("HelloWorld"); + var response = await deploymentResult.HttpClient.GetAsync("HelloWorld"); Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode); diff --git a/test/IISExpress.FunctionalTests/OutOfProcess/GlobalVersionTests.cs b/test/IISExpress.FunctionalTests/OutOfProcess/GlobalVersionTests.cs index 7ad5d9c9f6..fa859d614a 100644 --- a/test/IISExpress.FunctionalTests/OutOfProcess/GlobalVersionTests.cs +++ b/test/IISExpress.FunctionalTests/OutOfProcess/GlobalVersionTests.cs @@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests var deploymentResult = await DeployAsync(deploymentParameters); - var response = await deploymentResult.RetryingHttpClient.GetAsync(_helloWorldRequest); + var response = await deploymentResult.HttpClient.GetAsync(_helloWorldRequest); var responseText = await response.Content.ReadAsStringAsync(); Assert.Equal(_helloWorldResponse, responseText); } @@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests var deploymentResult = await DeployAsync(deploymentParameters); - var response = await deploymentResult.RetryingHttpClient.GetAsync(_helloWorldRequest); + var response = await deploymentResult.HttpClient.GetAsync(_helloWorldRequest); Assert.False(response.IsSuccessStatusCode); } @@ -80,7 +80,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests var newANCMPath = GetANCMRequestHandlerPath(deploymentResult, version); Directory.Move(originalANCMPath, newANCMPath); - var response = await deploymentResult.RetryingHttpClient.GetAsync(_helloWorldRequest); + var response = await deploymentResult.HttpClient.GetAsync(_helloWorldRequest); var responseText = await response.Content.ReadAsStringAsync(); Assert.Equal(_helloWorldResponse, responseText); AssertLoadedVersion(version); @@ -101,8 +101,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests CopyDirectory(originalANCMPath, newANCMPath); - deploymentResult.RetryingHttpClient.DefaultRequestHeaders.Add("ANCMRHPath", newANCMPath); - var response = await deploymentResult.RetryingHttpClient.GetAsync("CheckRequestHandlerVersion"); + deploymentResult.HttpClient.DefaultRequestHeaders.Add("ANCMRHPath", newANCMPath); + var response = await deploymentResult.HttpClient.GetAsync("CheckRequestHandlerVersion"); var responseText = await response.Content.ReadAsStringAsync(); Assert.Equal(_helloWorldResponse, responseText); @@ -120,8 +120,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests var originalANCMPath = GetANCMRequestHandlerPath(deploymentResult, _handlerVersion20); - deploymentResult.RetryingHttpClient.DefaultRequestHeaders.Add("ANCMRHPath", originalANCMPath); - var response = await deploymentResult.RetryingHttpClient.GetAsync("CheckRequestHandlerVersion"); + deploymentResult.HttpClient.DefaultRequestHeaders.Add("ANCMRHPath", originalANCMPath); + var response = await deploymentResult.HttpClient.GetAsync("CheckRequestHandlerVersion"); var responseText = await response.Content.ReadAsStringAsync(); Assert.Equal(_helloWorldResponse, responseText); @@ -136,8 +136,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests CopyDirectory(originalANCMPath, newANCMPath); - deploymentResult.RetryingHttpClient.DefaultRequestHeaders.Add("ANCMRHPath", newANCMPath); - response = await deploymentResult.RetryingHttpClient.GetAsync("CheckRequestHandlerVersion"); + deploymentResult.HttpClient.DefaultRequestHeaders.Add("ANCMRHPath", newANCMPath); + response = await deploymentResult.HttpClient.GetAsync("CheckRequestHandlerVersion"); responseText = await response.Content.ReadAsStringAsync(); Assert.Equal(_helloWorldResponse, responseText); diff --git a/test/IISExpress.FunctionalTests/OutOfProcess/HttpsTest.cs b/test/IISExpress.FunctionalTests/OutOfProcess/HttpsTest.cs index 91c5291b0a..5735393c57 100644 --- a/test/IISExpress.FunctionalTests/OutOfProcess/HttpsTest.cs +++ b/test/IISExpress.FunctionalTests/OutOfProcess/HttpsTest.cs @@ -48,7 +48,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests { ServerCertificateCustomValidationCallback = (a, b, c, d) => true }; - var client = deploymentResult.CreateRetryClient(handler); + var client = deploymentResult.CreateClient(handler); var response = await client.GetAsync("HttpsHelloWorld"); var responseText = await response.Content.ReadAsStringAsync(); Assert.Equal("Scheme:https; Original:http", responseText); @@ -92,7 +92,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests handler.ClientCertificates.Add(clientCert); } - var client = deploymentResult.CreateRetryClient(handler); + var client = deploymentResult.CreateClient(handler); // Request to base address and check if various parts of the body are rendered & measure the cold startup time. var response = await client.GetAsync("checkclientcert"); diff --git a/test/IISExpress.FunctionalTests/OutOfProcess/NtlmAuthentationTest.cs b/test/IISExpress.FunctionalTests/OutOfProcess/NtlmAuthentationTest.cs index b67b3b103a..49365998a0 100644 --- a/test/IISExpress.FunctionalTests/OutOfProcess/NtlmAuthentationTest.cs +++ b/test/IISExpress.FunctionalTests/OutOfProcess/NtlmAuthentationTest.cs @@ -43,7 +43,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests deploymentParameters.AddWindowsAuthToServerConfig(); var result = await DeployAsync(deploymentParameters); - var response = await result.RetryingHttpClient.GetAsync("/HelloWorld"); + var response = await result.HttpClient.GetAsync("/HelloWorld"); var responseText = await response.Content.ReadAsStringAsync(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); diff --git a/test/IISExpress.FunctionalTests/UpgradeFeatureDetectionTests.cs b/test/IISExpress.FunctionalTests/UpgradeFeatureDetectionTests.cs index 492ae8db87..62d07c5fd9 100644 --- a/test/IISExpress.FunctionalTests/UpgradeFeatureDetectionTests.cs +++ b/test/IISExpress.FunctionalTests/UpgradeFeatureDetectionTests.cs @@ -75,7 +75,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests var deploymentResult = await DeployAsync(deploymentParameters); - var response = await deploymentResult.RetryingHttpClient.GetAsync("UpgradeFeatureDetection"); + var response = await deploymentResult.HttpClient.GetAsync("UpgradeFeatureDetection"); var responseText = await response.Content.ReadAsStringAsync(); Assert.Equal(expected, responseText); } From dd429e9597993e3b2cb78b4ccce543884794a32a Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Thu, 9 Aug 2018 09:45:28 -0700 Subject: [PATCH 2/4] Catch exceptions thrown by is_regular_file (#1179) --- .../CommonLib/PollingAppOfflineApplication.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/AspNetCoreModuleV2/CommonLib/PollingAppOfflineApplication.cpp b/src/AspNetCoreModuleV2/CommonLib/PollingAppOfflineApplication.cpp index e9bbb42383..14629ebe10 100644 --- a/src/AspNetCoreModuleV2/CommonLib/PollingAppOfflineApplication.cpp +++ b/src/AspNetCoreModuleV2/CommonLib/PollingAppOfflineApplication.cpp @@ -27,12 +27,20 @@ PollingAppOfflineApplication::CheckAppOffline() SRWExclusiveLock lock(m_statusLock); if (ulCurrentTime - m_ulLastCheckTime > c_appOfflineRefreshIntervalMS) { - m_fAppOfflineFound = is_regular_file(m_appOfflineLocation); - if(m_fAppOfflineFound) + try { - LOG_IF_FAILED(OnAppOfflineFound()); + m_fAppOfflineFound = is_regular_file(m_appOfflineLocation); + if(m_fAppOfflineFound) + { + LOG_IF_FAILED(OnAppOfflineFound()); + } + m_ulLastCheckTime = ulCurrentTime; + } + catch (...) + { + // is_regular_file might throw in very rare cases + OBSERVE_CAUGHT_EXCEPTION(); } - m_ulLastCheckTime = ulCurrentTime; } } From d7ad4c79eecb10e158ce6b4ef1ccb6d49bc52c7d Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Thu, 9 Aug 2018 10:03:03 -0700 Subject: [PATCH 3/4] Fix incremental checks for test projects (#1186) --- build/testsite.props | 1 + test/IIS.FunctionalTests/IIS.FunctionalTests.csproj | 1 + .../IISExpress.FunctionalTests.csproj | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/build/testsite.props b/build/testsite.props index 9a9e2cdf76..03aa0c9cff 100644 --- a/build/testsite.props +++ b/build/testsite.props @@ -6,6 +6,7 @@ $(MSBuildThisFileDirectory)applicationhost.config $(MSBuildThisFileDirectory)applicationhost.iis.config false + True diff --git a/test/IIS.FunctionalTests/IIS.FunctionalTests.csproj b/test/IIS.FunctionalTests/IIS.FunctionalTests.csproj index dfe65f9b56..723433b707 100644 --- a/test/IIS.FunctionalTests/IIS.FunctionalTests.csproj +++ b/test/IIS.FunctionalTests/IIS.FunctionalTests.csproj @@ -3,6 +3,7 @@ netcoreapp2.2 IIS.FunctionalTests + True diff --git a/test/IISExpress.FunctionalTests/IISExpress.FunctionalTests.csproj b/test/IISExpress.FunctionalTests/IISExpress.FunctionalTests.csproj index 455f453431..e62095f98f 100644 --- a/test/IISExpress.FunctionalTests/IISExpress.FunctionalTests.csproj +++ b/test/IISExpress.FunctionalTests/IISExpress.FunctionalTests.csproj @@ -1,7 +1,8 @@ - + netcoreapp2.2 + True From e6330ab19bdf058953b7547ef04aae7034b21658 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Thu, 9 Aug 2018 10:08:44 -0700 Subject: [PATCH 4/4] Fix win7 test again (#1187) --- .../IISDeployer.cs | 18 +++++++++++------- .../Utilities/FunctionalTestsBase.cs | 3 ++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISDeployer.cs b/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISDeployer.cs index 1030823b3a..f677632485 100644 --- a/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISDeployer.cs +++ b/src/Microsoft.AspNetCore.Server.IntegrationTesting.IIS/IISDeployer.cs @@ -345,14 +345,18 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS .RequiredElement("applicationPools") .RequiredElement("add"); - var environmentVariables = pool - .GetOrAdd("environmentVariables"); - - foreach (var tuple in DeploymentParameters.EnvironmentVariables) + if (DeploymentParameters.EnvironmentVariables.Any()) { - environmentVariables - .GetOrAdd("add", "name", tuple.Key) - .SetAttributeValue("value", tuple.Value); + var environmentVariables = pool + .GetOrAdd("environmentVariables"); + + foreach (var tuple in DeploymentParameters.EnvironmentVariables) + { + environmentVariables + .GetOrAdd("add", "name", tuple.Key) + .SetAttributeValue("value", tuple.Value); + } + } RunServerConfigActions(config, contentRoot); diff --git a/test/Common.FunctionalTests/Utilities/FunctionalTestsBase.cs b/test/Common.FunctionalTests/Utilities/FunctionalTestsBase.cs index 14b78a0d6e..79919e5753 100644 --- a/test/Common.FunctionalTests/Utilities/FunctionalTestsBase.cs +++ b/test/Common.FunctionalTests/Utilities/FunctionalTestsBase.cs @@ -22,7 +22,8 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting protected ApplicationDeployer CreateDeployer(IISDeploymentParameters parameters) { - if (!parameters.EnvironmentVariables.ContainsKey(DebugEnvironmentVariable)) + if (parameters.ServerType == ServerType.IISExpress && + !parameters.EnvironmentVariables.ContainsKey(DebugEnvironmentVariable)) { parameters.EnvironmentVariables[DebugEnvironmentVariable] = "console"; }