Port startup tests to IIS (#1513)
This commit is contained in:
parent
b0deed05be
commit
24e2e5ad52
|
|
@ -119,12 +119,18 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
||||||
key: "hostingModel",
|
key: "hostingModel",
|
||||||
value: DeploymentParameters.HostingModel.ToString());
|
value: DeploymentParameters.HostingModel.ToString());
|
||||||
|
|
||||||
if (DeploymentParameters.ApplicationType == ApplicationType.Portable)
|
yield return (element, _) => {
|
||||||
{
|
var aspNetCore = element
|
||||||
yield return WebConfigHelpers.AddOrModifyAspNetCoreSection(
|
.Descendants("system.webServer")
|
||||||
"processPath",
|
.Single()
|
||||||
DotNetCommands.GetDotNetExecutable(DeploymentParameters.RuntimeArchitecture));
|
.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(
|
yield return WebConfigHelpers.AddOrModifyHandlerSection(
|
||||||
key: "modules",
|
key: "modules",
|
||||||
|
|
@ -399,8 +405,10 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
|
||||||
redirectionSection.Attributes["enabled"].Value = false;
|
redirectionSection.Attributes["enabled"].Value = false;
|
||||||
|
|
||||||
serverManager.CommitChanges();
|
serverManager.CommitChanges();
|
||||||
|
if (Directory.Exists(_configPath))
|
||||||
Directory.Delete(_configPath, true);
|
{
|
||||||
|
Directory.Delete(_configPath, true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
||||||
|
|
||||||
if (process.ExitCode != 0)
|
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()}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
|
|
||||||
public static string InProcessFailedToStop(IISDeploymentResult deploymentResult, string reason)
|
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)
|
public static string InProcessThreadException(IISDeploymentResult deploymentResult, string reason)
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ using Microsoft.AspNetCore.Server.IntegrationTesting.IIS;
|
||||||
using Microsoft.AspNetCore.Testing;
|
using Microsoft.AspNetCore.Testing;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
|
|
@ -203,5 +202,12 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
var output = JsonConvert.SerializeObject(depsFileContent);
|
var output = JsonConvert.SerializeObject(depsFileContent);
|
||||||
File.WriteAllText(path, output);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -120,9 +120,13 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[ConditionalFact]
|
[ConditionalFact]
|
||||||
|
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
|
||||||
public async Task StartsWithPortableAndBootstraperExe()
|
public async Task StartsWithPortableAndBootstraperExe()
|
||||||
{
|
{
|
||||||
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
|
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
|
// rest publisher as it doesn't support additional parameters
|
||||||
deploymentParameters.ApplicationPublisher = null;
|
deploymentParameters.ApplicationPublisher = null;
|
||||||
// ReferenceTestTasks is workaround for https://github.com/dotnet/sdk/issues/2482
|
// 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");
|
var result = await deploymentResult.HttpClient.GetAsync("/HelloWorld");
|
||||||
Assert.Equal(HttpStatusCode.InternalServerError, result.StatusCode);
|
Assert.Equal(HttpStatusCode.InternalServerError, result.StatusCode);
|
||||||
|
|
||||||
|
// Config load errors might not allow us to initialize log file
|
||||||
|
deploymentResult.AllowNoLogs();
|
||||||
|
|
||||||
StopServer();
|
StopServer();
|
||||||
|
|
||||||
EventLogHelpers.VerifyEventLogEvents(deploymentResult,
|
EventLogHelpers.VerifyEventLogEvents(deploymentResult,
|
||||||
Loading…
Reference in New Issue