Port startup tests to IIS (#1513)

This commit is contained in:
Pavel Krymets 2018-10-15 11:44:51 -07:00 committed by GitHub
parent b0deed05be
commit 24e2e5ad52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 11 deletions

View File

@ -119,12 +119,18 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
key: "hostingModel",
value: DeploymentParameters.HostingModel.ToString());
if (DeploymentParameters.ApplicationType == ApplicationType.Portable)
{
yield return WebConfigHelpers.AddOrModifyAspNetCoreSection(
"processPath",
DotNetCommands.GetDotNetExecutable(DeploymentParameters.RuntimeArchitecture));
}
yield return (element, _) => {
var aspNetCore = element
.Descendants("system.webServer")
.Single()
.GetOrAdd("aspNetCore");
// Expand path to dotnet because IIS process would not inherit PATH variable
if (aspNetCore.Attribute("processPath")?.Value.StartsWith("dotnet") == true)
{
aspNetCore.SetAttributeValue("processPath", DotNetCommands.GetDotNetExecutable(DeploymentParameters.RuntimeArchitecture));
}
};
yield return WebConfigHelpers.AddOrModifyHandlerSection(
key: "modules",
@ -399,8 +405,10 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
redirectionSection.Attributes["enabled"].Value = false;
serverManager.CommitChanges();
Directory.Delete(_configPath, true);
if (Directory.Exists(_configPath))
{
Directory.Delete(_configPath, true);
}
});
}
}

View File

@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
if (process.ExitCode != 0)
{
throw new InvalidOperationException($"Exit code {process.ExitCode} when running {fileName} {arguments}. Stdout: {process.StandardOutput.ReadToEnd()}");
throw new InvalidOperationException($"Exit code {process.ExitCode} when running {fileName} {arguments}. Stdout: {process.StandardOutput.ReadToEnd()} Stderr: {process.StandardError.ReadToEnd()}");
}
}

View File

@ -146,7 +146,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public static string InProcessFailedToStop(IISDeploymentResult deploymentResult, string reason)
{
return "Failed to gracefully shutdown application 'MACHINE/WEBROOT/APPHOST/HTTPTESTSITE'.";
return "Failed to gracefully shutdown application 'MACHINE/WEBROOT/APPHOST/.*?'.";
}
public static string InProcessThreadException(IISDeploymentResult deploymentResult, string reason)

View File

@ -13,7 +13,6 @@ using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Xunit;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
@ -203,5 +202,12 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
var output = JsonConvert.SerializeObject(depsFileContent);
File.WriteAllText(path, output);
}
public static void AllowNoLogs(this IISDeploymentResult deploymentResult)
{
File.AppendAllText(
Path.Combine(deploymentResult.DeploymentParameters.PublishedApplicationRootPath, "aspnetcore-debug.log"),
"Running test allowed log file to be empty." + Environment.NewLine);
}
}
}

View File

@ -120,9 +120,13 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
}
[ConditionalFact]
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
public async Task StartsWithPortableAndBootstraperExe()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
// We need the right dotnet on the path in IIS
deploymentParameters.EnvironmentVariables["PATH"] = Path.GetDirectoryName(DotNetCommands.GetDotNetExecutable(deploymentParameters.RuntimeArchitecture));
// rest publisher as it doesn't support additional parameters
deploymentParameters.ApplicationPublisher = null;
// ReferenceTestTasks is workaround for https://github.com/dotnet/sdk/issues/2482
@ -302,6 +306,9 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
var result = await deploymentResult.HttpClient.GetAsync("/HelloWorld");
Assert.Equal(HttpStatusCode.InternalServerError, result.StatusCode);
// Config load errors might not allow us to initialize log file
deploymentResult.AllowNoLogs();
StopServer();
EventLogHelpers.VerifyEventLogEvents(deploymentResult,