Merge pull request #1185 from dotnet-maestro-bot/merge/release/2.2-to-master

[automated] Merge branch 'release/2.2' => 'master'
This commit is contained in:
Pavel Krymets 2018-08-09 11:00:09 -07:00 committed by GitHub
commit 54a7cc9fc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 87 additions and 60 deletions

View File

@ -6,6 +6,7 @@
<IISExpressAppHostConfig>$(MSBuildThisFileDirectory)applicationhost.config</IISExpressAppHostConfig>
<IISAppHostConfig>$(MSBuildThisFileDirectory)applicationhost.iis.config</IISAppHostConfig>
<PreserveCompilationContext>false</PreserveCompilationContext>
<DisableFastUpToDateCheck>True</DisableFastUpToDateCheck>
</PropertyGroup>
<Import Project="assets.props" />

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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; }
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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";
}

View File

@ -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();

View File

@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
<TestGroupName>IIS.FunctionalTests</TestGroupName>
<DisableFastUpToDateCheck>True</DisableFastUpToDateCheck>
</PropertyGroup>
<ItemGroup>

View File

@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.2</TargetFrameworks>
<DisableFastUpToDateCheck>True</DisableFastUpToDateCheck>
</PropertyGroup>
<ItemGroup>

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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");

View File

@ -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);

View File

@ -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);
}