Allow test projects to run standalone (#7144)

This commit is contained in:
Pavel Krymets 2019-02-01 15:19:49 -08:00 committed by GitHub
parent d53f0da021
commit 35746adf68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 216 additions and 185 deletions

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@ -45,19 +45,22 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
DeploymentParameters.RuntimeFlavor = GetRuntimeFlavor(DeploymentParameters.TargetFramework);
}
if (string.IsNullOrEmpty(DeploymentParameters.ApplicationPath))
if (DeploymentParameters.ApplicationPublisher == null)
{
throw new ArgumentException("ApplicationPath cannot be null.");
}
if (string.IsNullOrEmpty(DeploymentParameters.ApplicationPath))
{
throw new ArgumentException("ApplicationPath cannot be null.");
}
if (!Directory.Exists(DeploymentParameters.ApplicationPath))
{
throw new DirectoryNotFoundException(string.Format("Application path {0} does not exist.", DeploymentParameters.ApplicationPath));
}
if (!Directory.Exists(DeploymentParameters.ApplicationPath))
{
throw new DirectoryNotFoundException(string.Format("Application path {0} does not exist.", DeploymentParameters.ApplicationPath));
}
if (string.IsNullOrEmpty(DeploymentParameters.ApplicationName))
{
DeploymentParameters.ApplicationName = new DirectoryInfo(DeploymentParameters.ApplicationPath).Name;
if (string.IsNullOrEmpty(DeploymentParameters.ApplicationName))
{
DeploymentParameters.ApplicationName = new DirectoryInfo(DeploymentParameters.ApplicationPath).Name;
}
}
}
@ -97,7 +100,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
}
else
{
_publishedApplication.Dispose();
_publishedApplication?.Dispose();
}
}
}

View File

@ -66,7 +66,7 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
[InlineData(HostingModel.OutOfProcess, 502, "502.5")]
public async Task AppOfflineDroppedWhileSiteFailedToStartInShim_AppOfflineServed(HostingModel hostingModel, int statusCode, string content)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel: hostingModel, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel: hostingModel);
deploymentParameters.WebConfigActionList.Add(WebConfigHelpers.AddOrModifyAspNetCoreSection("processPath", "nonexistent"));
var deploymentResult = await DeployAsync(deploymentParameters);
@ -228,7 +228,7 @@ namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests
private async Task<IISDeploymentResult> DeployApp(HostingModel hostingModel = HostingModel.InProcess)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel: hostingModel, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel: hostingModel);
return await DeployAsync(deploymentParameters);
}

View File

@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
var username = Environment.GetEnvironmentVariable("ASPNETCORE_MODULE_TEST_USER");
var password = Environment.GetEnvironmentVariable("ASPNETCORE_MODULE_TEST_PASSWORD");
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant);
deploymentParameters.SetAnonymousAuth(enabled: false);
deploymentParameters.SetWindowsAuth(enabled: false);
deploymentParameters.SetBasicAuth(enabled: true);

View File

@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[MemberData(nameof(TestVariants))]
public async Task StartupStress(TestVariant variant)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant);
var deploymentResult = await DeployAsync(deploymentParameters);

View File

@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task ConfigurationChangeStopsInProcess()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.InProcess, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.InProcess);
var deploymentResult = await DeployAsync(deploymentParameters);
@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task ConfigurationChangeForcesChildProcessRestart()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess);
var deploymentResult = await DeployAsync(deploymentParameters);
@ -63,7 +63,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task OutOfProcessToInProcessHostingModelSwitchWorks()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess);
var deploymentResult = await DeployAsync(deploymentParameters);
@ -88,7 +88,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[InlineData(HostingModel.OutOfProcess)]
public async Task ConfigurationTouchedStress(HostingModel hostingModel)
{
var deploymentResult = await DeployAsync(_fixture.GetBaseDeploymentParameters(hostingModel, publish: true));
var deploymentResult = await DeployAsync(_fixture.GetBaseDeploymentParameters(hostingModel));
await deploymentResult.AssertStarts();
var load = Helpers.StressLoad(deploymentResult.HttpClient, "/HelloWorld", response => {

View File

@ -80,7 +80,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
var appName = "\u041C\u043E\u0451\u041F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435";
var port = TestPortHelper.GetNextSSLPort();
var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.InProcess, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.InProcess);
deploymentParameters.ApplicationBaseUriHint = $"https://localhost:{port}/";
deploymentParameters.AddHttpsToServerConfig();
deploymentParameters.AddServerConfigAction(
@ -100,7 +100,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[RequiresNewShim]
public async Task HttpsPortCanBeOverriden()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess);
deploymentParameters.AddServerConfigAction(
element => {
@ -126,7 +126,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
var sslPort = GetNextSSLPort();
var anotherSslPort = GetNextSSLPort(sslPort);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess);
deploymentParameters.AddServerConfigAction(
element => {

View File

@ -33,7 +33,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
"AReallyLongValueThatIsGreaterThan300CharactersToForceResizeInNative";
var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel);
deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_INPROCESS_TESTING_LONG_VALUE"] = expectedValue;
Assert.Equal(
@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
private async Task AuthHeaderEnvironmentVariableRemoved(HostingModel hostingModel)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel);
deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_IIS_HTTPAUTH"] = "shouldberemoved";
Assert.DoesNotContain("shouldberemoved", await GetStringAsync(deploymentParameters,"/GetEnvironmentVariable?name=ASPNETCORE_IIS_HTTPAUTH"));
@ -67,7 +67,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
private async Task WebConfigOverridesGlobalEnvironmentVariables(HostingModel hostingModel)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel);
deploymentParameters.EnvironmentVariables["ASPNETCORE_ENVIRONMENT"] = "Development";
deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_ENVIRONMENT"] = "Production";
Assert.Equal("Production", await GetStringAsync(deploymentParameters, "/GetEnvironmentVariable?name=ASPNETCORE_ENVIRONMENT"));
@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
private async Task WebConfigAppendsHostingStartup(HostingModel hostingModel)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel);
deploymentParameters.EnvironmentVariables["ASPNETCORE_HOSTINGSTARTUPASSEMBLIES"] = "Asm1";
if (hostingModel == HostingModel.InProcess)
{
@ -107,7 +107,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
private async Task WebConfigOverridesHostingStartup(HostingModel hostingModel)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel);
deploymentParameters.EnvironmentVariables["ASPNETCORE_HOSTINGSTARTUPASSEMBLIES"] = "Asm1";
deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_HOSTINGSTARTUPASSEMBLIES"] = "Asm2";
Assert.Equal("Asm2", await GetStringAsync(deploymentParameters, "/GetEnvironmentVariable?name=ASPNETCORE_HOSTINGSTARTUPASSEMBLIES"));
@ -124,7 +124,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
private async Task WebConfigExpandsVariables(HostingModel hostingModel)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel);
deploymentParameters.EnvironmentVariables["TestVariable"] = "World";
deploymentParameters.WebConfigBasedEnvironmentVariables["OtherVariable"] = "%TestVariable%;Hello";
Assert.Equal("World;Hello", await GetStringAsync(deploymentParameters, "/GetEnvironmentVariable?name=OtherVariable"));

View File

@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
public async Task IncludesAdditionalErrorPageTextInProcessHandlerLoadFailure_CorrectString()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters();
var response = await DeployAppWithStartupFailure(deploymentParameters);
Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
public async Task IncludesAdditionalErrorPageTextOutOfProcessStartupFailure_CorrectString()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess);
var response = await DeployAppWithStartupFailure(deploymentParameters);
Assert.Equal(HttpStatusCode.BadGateway, response.StatusCode);
@ -62,7 +62,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
public async Task IncludesAdditionalErrorPageTextOutOfProcessHandlerLoadFailure_CorrectString()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess);
deploymentParameters.HandlerSettings["handlerVersion"] = "88.93";
deploymentParameters.EnvironmentVariables["ANCM_ADDITIONAL_ERROR_PAGE_LINK"] = "http://example";
@ -85,7 +85,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[RequiresNewHandler]
public async Task IncludesAdditionalErrorPageTextInProcessStartupFailure_CorrectString()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters();
deploymentParameters.TransformArguments((a, _) => $"{a} EarlyReturn");
deploymentParameters.EnvironmentVariables["ANCM_ADDITIONAL_ERROR_PAGE_LINK"] = "http://example";

View File

@ -21,7 +21,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task CheckStartupEventLogMessage()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters();
var deploymentResult = await DeployAsync(deploymentParameters);
await deploymentResult.AssertStarts();
@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task CheckShutdownEventLogMessage()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters();
var deploymentResult = await DeployAsync(deploymentParameters);
await deploymentResult.AssertStarts();

View File

@ -54,7 +54,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[RequiresIIS(IISCapability.FailedRequestTracingModule)]
public async Task FrebIncludesHResultFailures()
{
var parameters = _fixture.GetBaseDeploymentParameters(publish: true);
var parameters = _fixture.GetBaseDeploymentParameters();
parameters.TransformArguments((args, _) => string.Empty);
var result = await SetupFrebApp(parameters);
@ -104,7 +104,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
private async Task<IISDeploymentResult> SetupFrebApp(IISDeploymentParameters parameters = null)
{
parameters = parameters ?? _fixture.GetBaseDeploymentParameters(publish: true);
parameters = parameters ?? _fixture.GetBaseDeploymentParameters();
parameters.EnableFreb("Verbose", _logFolderPath);
Directory.CreateDirectory(_logFolderPath);

View File

@ -8,11 +8,11 @@ using Xunit;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
[Collection(IISTestSiteCollection.Name)]
public class HelloWorldInProcessTests
public class HelloWorldInProcessTests: FixtureLoggedTest
{
private readonly IISTestSiteFixture _fixture;
public HelloWorldInProcessTests(IISTestSiteFixture fixture)
public HelloWorldInProcessTests(IISTestSiteFixture fixture) : base(fixture)
{
_fixture = fixture;
}

View File

@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[InlineData("ConsoleWrite")]
public async Task CheckStdoutLoggingToPipe_DoesNotCrashProcess(string path)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters();
var deploymentResult = await DeployAsync(deploymentParameters);
await Helpers.AssertStarts(deploymentResult, path);
@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[InlineData("ConsoleWriteStartServer")]
public async Task CheckStdoutLoggingToPipeWithFirstWrite(string path)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters();
var firstWriteString = "TEST MESSAGE";
@ -67,7 +67,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public async Task CheckUnicodePipe()
{
var path = "CheckConsoleFunctions";
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);
deploymentParameters.TransformArguments((a, _) => $"{a} {path}");
var deploymentResult = await DeployAsync(deploymentParameters);

View File

@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task ShutdownTimeoutIsApplied()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);
deploymentParameters.TransformArguments((a, _) => $"{a} HangOnStop");
deploymentParameters.WebConfigActionList.Add(
WebConfigHelpers.AddOrModifyAspNetCoreSection("shutdownTimeLimit", "1"));
@ -47,7 +47,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
// Canceled token doesn't affect shutdown, in-proc doesn't handle ungraceful shutdown
// IIS's ShutdownTimeLimit will handle that.
var parameters = _fixture.GetBaseDeploymentParameters(publish: true);
var parameters = _fixture.GetBaseDeploymentParameters();
var deploymentResult = await DeployAsync(parameters);
try
{

View File

@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[InlineData("CheckOversizedStdOutWrites")]
public async Task CheckStdoutWithLargeWrites_TestSink(string mode)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);
deploymentParameters.TransformArguments((a, _) => $"{a} {mode}");
var deploymentResult = await DeployAsync(deploymentParameters);
@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[InlineData("CheckOversizedStdOutWrites")]
public async Task CheckStdoutWithLargeWrites_LogFile(string mode)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);
deploymentParameters.TransformArguments((a, _) => $"{a} {mode}");
deploymentParameters.EnableLogging(_logFolderPath);
@ -62,7 +62,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task CheckValidConsoleFunctions()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);
deploymentParameters.TransformArguments((a, _) => $"{a} CheckConsoleFunctions");
var deploymentResult = await DeployAsync(deploymentParameters);
@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task Gets500_30_ErrorPage()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);
deploymentParameters.TransformArguments((a, _) => $"{a} EarlyReturn");
var deploymentResult = await DeployAsync(deploymentParameters);

View File

@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public async Task ExpandEnvironmentVariableInWebConfig()
{
// Point to dotnet installed in user profile.
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters();
deploymentParameters.EnvironmentVariables["DotnetPath"] = _dotnetLocation;
deploymentParameters.WebConfigActionList.Add(WebConfigHelpers.AddOrModifyAspNetCoreSection("processPath", "%DotnetPath%"));
await StartAsync(deploymentParameters);
@ -49,7 +49,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[InlineData("dotnet.zip", "", @"Process path 'dotnet.zip' doesn't have '.exe' extension.")]
public async Task InvalidProcessPath_ExpectServerError(string path, string arguments, string subError)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters();
deploymentParameters.WebConfigActionList.Add(WebConfigHelpers.AddOrModifyAspNetCoreSection("processPath", path));
deploymentParameters.WebConfigActionList.Add(WebConfigHelpers.AddOrModifyAspNetCoreSection("arguments", arguments));
@ -69,7 +69,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task StartsWithDotnetLocationWithoutExe()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters();
var dotnetLocationWithoutExtension = _dotnetLocation.Substring(0, _dotnetLocation.LastIndexOf("."));
deploymentParameters.WebConfigActionList.Add(WebConfigHelpers.AddOrModifyAspNetCoreSection("processPath", dotnetLocationWithoutExtension));
@ -80,7 +80,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task StartsWithDotnetLocationUppercase()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters();
var dotnetLocationWithoutExtension = _dotnetLocation.Substring(0, _dotnetLocation.LastIndexOf(".")).ToUpperInvariant();
deploymentParameters.WebConfigActionList.Add(WebConfigHelpers.AddOrModifyAspNetCoreSection("processPath", dotnetLocationWithoutExtension));
@ -94,7 +94,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
public async Task StartsWithDotnetOnThePath(string path)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters();
deploymentParameters.EnvironmentVariables["PATH"] = Path.GetDirectoryName(_dotnetLocation);
deploymentParameters.WebConfigActionList.Add(WebConfigHelpers.AddOrModifyAspNetCoreSection("processPath", path));
@ -115,7 +115,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
public async Task StartsWithDotnetInstallLocation(RuntimeArchitecture runtimeArchitecture)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters();
deploymentParameters.RuntimeArchitecture = runtimeArchitecture;
// IIS doesn't allow empty PATH
@ -147,7 +147,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
public async Task DoesNotStartIfDisabled()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters();
using (new TestRegistryKey(
Registry.LocalMachine,
@ -179,7 +179,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[MemberData(nameof(TestVariants))]
public async Task HelloWorld(TestVariant variant)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant);
await StartAsync(deploymentParameters);
}
@ -187,7 +187,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[RequiresIIS(IISCapability.PoolEnvironmentVariables)]
public async Task StartsWithPortableAndBootstraperExe()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);
// We need the right dotnet on the path in IIS
deploymentParameters.EnvironmentVariables["PATH"] = Path.GetDirectoryName(DotNetCommands.GetDotNetExecutable(deploymentParameters.RuntimeArchitecture));
// ReferenceTestTasks is workaround for https://github.com/dotnet/sdk/issues/2482
@ -204,7 +204,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task DetectsOverriddenServer()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);
deploymentParameters.TransformArguments((a, _) => $"{a} OverriddenServer");
var deploymentResult = await DeployAsync(deploymentParameters);
@ -221,7 +221,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task LogsStartupExceptionExitError()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);
deploymentParameters.TransformArguments((a, _) => $"{a} Throw");
var deploymentResult = await DeployAsync(deploymentParameters);
@ -239,7 +239,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task LogsUnexpectedThreadExitError()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);
deploymentParameters.TransformArguments((a, _) => $"{a} EarlyReturn");
var deploymentResult = await DeployAsync(deploymentParameters);
@ -256,7 +256,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task RemoveHostfxrFromApp_InProcessHostfxrAPIAbsent()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);
deploymentParameters.ApplicationType = ApplicationType.Standalone;
var deploymentResult = await DeployAsync(deploymentParameters);
@ -273,7 +273,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[RequiresNewShim]
public async Task RemoveHostfxrFromApp_InProcessHostfxrLoadFailure()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);
deploymentParameters.ApplicationType = ApplicationType.Standalone;
var deploymentResult = await DeployAsync(deploymentParameters);
@ -287,7 +287,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task TargedDifferenceSharedFramework_FailedToFindNativeDependencies()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);
var deploymentResult = await DeployAsync(deploymentParameters);
Helpers.ModifyFrameworkVersionInRuntimeConfig(deploymentResult);
@ -299,7 +299,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task RemoveInProcessReference_FailedToFindRequestHandler()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);
deploymentParameters.ApplicationType = ApplicationType.Standalone;
var deploymentResult = await DeployAsync(deploymentParameters);
@ -320,7 +320,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task StartupTimeoutIsApplied()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);
deploymentParameters.TransformArguments((a, _) => $"{a} Hang");
deploymentParameters.WebConfigActionList.Add(
WebConfigHelpers.AddOrModifyAspNetCoreSection("startupTimeLimit", "1"));
@ -340,7 +340,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task CheckInvalidHostingModelParameter()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters();
deploymentParameters.WebConfigActionList.Add(WebConfigHelpers.AddOrModifyAspNetCoreSection("hostingModel", "bogus"));
var deploymentResult = await DeployAsync(deploymentParameters);
@ -364,7 +364,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public async Task ReportsWebConfigAuthoringErrors(string scenario)
{
var (expectedError, action) = InvalidConfigTransformations[scenario];
var iisDeploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
var iisDeploymentParameters = _fixture.GetBaseDeploymentParameters();
iisDeploymentParameters.WebConfigActionList.Add((element, _) => action(element));
var deploymentResult = await DeployAsync(iisDeploymentParameters);
var result = await deploymentResult.HttpClient.GetAsync("/HelloWorld");
@ -409,7 +409,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public async Task StartsWithWebConfigVariationsPortable(string scenario)
{
var action = PortableConfigTransformations[scenario];
var iisDeploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
var iisDeploymentParameters = _fixture.GetBaseDeploymentParameters();
var expectedArguments = action(iisDeploymentParameters);
var result = await DeployAsync(iisDeploymentParameters);
Assert.Equal(expectedArguments, await result.HttpClient.GetStringAsync("/CommandLineArgs"));
@ -473,7 +473,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public async Task StartsWithWebConfigVariationsStandalone(string scenario)
{
var action = StandaloneConfigTransformations[scenario];
var iisDeploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
var iisDeploymentParameters = _fixture.GetBaseDeploymentParameters();
iisDeploymentParameters.ApplicationType = ApplicationType.Standalone;
var expectedArguments = action(iisDeploymentParameters);
var result = await DeployAsync(iisDeploymentParameters);
@ -508,7 +508,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[RequiresNewHandler]
public async Task SetCurrentDirectoryHandlerSettingWorks()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters();
deploymentParameters.HandlerSettings["SetCurrentDirectory"] = "false";
var deploymentResult = await DeployAsync(deploymentParameters);

View File

@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
private async Task CheckStdoutToFile(TestVariant variant, string path)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant);
deploymentParameters.EnableLogging(_logFolderPath);
var deploymentResult = await DeployAsync(deploymentParameters);
@ -64,7 +64,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[MemberData(nameof(TestVariants))]
public async Task InvalidFilePathForLogs_ServerStillRuns(TestVariant variant)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant);
deploymentParameters.WebConfigActionList.Add(
WebConfigHelpers.AddOrModifyAspNetCoreSection("stdoutLogEnabled", "true"));
@ -88,7 +88,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[RequiresNewShim]
public async Task StartupMessagesAreLoggedIntoDebugLogFile(TestVariant variant)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant);
deploymentParameters.HandlerSettings["debugLevel"] = "file";
deploymentParameters.HandlerSettings["debugFile"] = "subdirectory\\debug.txt";
@ -103,7 +103,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[MemberData(nameof(TestVariants))]
public async Task StartupMessagesAreLoggedIntoDefaultDebugLogFile(TestVariant variant)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant);
deploymentParameters.HandlerSettings["debugLevel"] = "file";
var deploymentResult = await DeployAsync(deploymentParameters);
@ -118,7 +118,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[MemberData(nameof(TestVariants))]
public async Task StartupMessagesAreLoggedIntoDefaultDebugLogFileWhenEnabledWithEnvVar(TestVariant variant)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant);
deploymentParameters.EnvironmentVariables["ASPNETCORE_MODULE_DEBUG"] = "file";
// Add empty debugFile handler setting to prevent IIS deployer from overriding debug settings
deploymentParameters.HandlerSettings["debugFile"] = "";
@ -139,7 +139,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
try
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant);
deploymentParameters.EnvironmentVariables["ASPNETCORE_MODULE_DEBUG_FILE"] = firstTempFile;
deploymentParameters.AddDebugLogToWebConfig(secondTempFile);
@ -166,7 +166,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public async Task DebugLogsAreWrittenToEventLog(TestVariant variant)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant);
deploymentParameters.HandlerSettings["debugLevel"] = "file,eventlog";
var deploymentResult = await StartAsync(deploymentParameters);
StopServer();
@ -179,7 +179,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
var path = "CheckConsoleFunctions";
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, variant.HostingModel, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, variant.HostingModel);
deploymentParameters.TransformArguments((a, _) => $"{a} {path}"); // For standalone this will need to remove space
var logFolderPath = _logFolderPath + "\\彡⾔";
@ -210,7 +210,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[MemberData(nameof(TestVariants))]
public async Task OnlyOneFileCreatedWithProcessStartTime(TestVariant variant)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant);
deploymentParameters.EnableLogging(_logFolderPath);

View File

@ -31,7 +31,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task RunsTwoOutOfProcessApps()
{
var parameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess, publish: true);
var parameters = _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess);
parameters.ServerConfigActionList.Add(DuplicateApplication);
var result = await DeployAsync(parameters);
var id1 = await result.HttpClient.GetStringAsync("/app1/ProcessId");
@ -42,7 +42,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task FailsAndLogsWhenRunningTwoInProcessApps()
{
var parameters = _fixture.GetBaseDeploymentParameters(HostingModel.InProcess, publish: true);
var parameters = _fixture.GetBaseDeploymentParameters(HostingModel.InProcess);
parameters.ServerConfigActionList.Add(DuplicateApplication);
var result = await DeployAsync(parameters);
@ -59,7 +59,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[InlineData(HostingModel.InProcess)]
public async Task FailsAndLogsEventLogForMixedHostingModel(HostingModel firstApp)
{
var parameters = _fixture.GetBaseDeploymentParameters(firstApp, publish: true);
var parameters = _fixture.GetBaseDeploymentParameters(firstApp);
parameters.ServerConfigActionList.Add(DuplicateApplication);
var result = await DeployAsync(parameters);

View File

@ -46,7 +46,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public async Task EnvVarInWebConfig_Valid(TestVariant variant)
{
// Must publish to set env vars in web.config
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant);
var port = GetUnusedRandomPort();
deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_PORT"] = port.ToString();
@ -62,7 +62,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public async Task EnvVarInWebConfig_Empty(TestVariant variant)
{
// Must publish to set env vars in web.config
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant);
deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_PORT"] = string.Empty;
var deploymentResult = await DeployAsync(deploymentParameters);
@ -78,7 +78,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public async Task EnvVarInWebConfig_Invalid(TestVariant variant, string port)
{
// Must publish to set env vars in web.config
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(variant);
deploymentParameters.WebConfigBasedEnvironmentVariables["ASPNETCORE_PORT"] = port;
var deploymentResult = await DeployAsync(deploymentParameters);

View File

@ -184,7 +184,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
private IISDeploymentParameters GetGlobalVersionBaseDeploymentParameters()
{
return _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess, publish: true);
return _fixture.GetBaseDeploymentParameters(HostingModel.OutOfProcess);
}
private void CopyDirectory(string from, string to)

View File

@ -1,24 +1,54 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
public class PublishedApplicationPublisher: ApplicationPublisher
{
private readonly string _applicationPath;
private readonly string _applicationName;
public PublishedApplicationPublisher(string applicationPath) : base(applicationPath)
public PublishedApplicationPublisher(string applicationName) : base(applicationName)
{
_applicationPath = applicationPath;
_applicationName = applicationName;
}
public override Task<PublishedApplication> Publish(DeploymentParameters deploymentParameters, ILogger logger)
{
var path = Path.Combine(AppContext.BaseDirectory, GetProfileName(deploymentParameters));
if (!Directory.Exists(path))
{
var solutionPath = GetProjectReferencePublishLocation(deploymentParameters);
logger.LogInformation("{PublishDir} doesn't exist falling back to solution based path {SolutionBasedDir}", solutionPath, solutionPath);
path = solutionPath;
}
logger.LogInformation("Using prepublished application from {PublishDir}", path);
var target = CreateTempDirectory();
var source = new DirectoryInfo(path);
CachingApplicationPublisher.CopyFiles(source, target, logger);
return Task.FromResult(new PublishedApplication(target.FullName, logger));
}
private string GetProjectReferencePublishLocation(DeploymentParameters deploymentParameters)
{
var testAssetsBasePath = Path.Combine(TestPathUtilities.GetSolutionRootDirectory("IISIntegration"), "IIS", "test", "testassets", _applicationName);
var configuration = this.GetType().GetTypeInfo().Assembly.GetCustomAttribute<AssemblyConfigurationAttribute>().Configuration;
var path = Path.Combine(testAssetsBasePath, "bin", configuration, deploymentParameters.TargetFramework, "publish", GetProfileName(deploymentParameters));
return path;
}
private string GetProfileName(DeploymentParameters deploymentParameters)
{
// Treat AdditionalPublishParameters as profile name if defined
string profileName;
@ -35,16 +65,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
profileName = "Standalone-" + deploymentParameters.RuntimeArchitecture;
}
var configuration = this.GetType().GetTypeInfo().Assembly.GetCustomAttribute<AssemblyConfigurationAttribute>().Configuration;
var path = Path.Combine(_applicationPath, "bin", configuration, deploymentParameters.TargetFramework, "publish", profileName);
logger.LogInformation("Using prepublished application from {PublishDir}", path);
var target = CreateTempDirectory();
var source = new DirectoryInfo(path);
CachingApplicationPublisher.CopyFiles(source, target, logger);
return Task.FromResult(new PublishedApplication(target.FullName, logger));
return Path.GetFileNameWithoutExtension(_applicationName) + "-" + profileName;
}
}
}

View File

@ -19,44 +19,46 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
public class PublishedSitesFixture : IDisposable
{
public PublishedApplicationPublisher InProcessTestSite { get; } = new PublishedApplicationPublisher(Helpers.GetInProcessTestSitesPath());
public PublishedApplicationPublisher OutOfProcessTestSite { get; } = new PublishedApplicationPublisher(Helpers.GetOutOfProcessTestSitesPath());
public PublishedApplicationPublisher InProcessTestSite { get; } = new PublishedApplicationPublisher(Helpers.GetInProcessTestSitesName());
public PublishedApplicationPublisher OutOfProcessTestSite { get; } = new PublishedApplicationPublisher(Helpers.GetOutOfProcessTestSitesName());
public void Dispose()
{
}
public IISDeploymentParameters GetBaseDeploymentParameters(HostingModel hostingModel = HostingModel.InProcess, bool publish = false)
public IISDeploymentParameters GetBaseDeploymentParameters(HostingModel hostingModel = HostingModel.InProcess)
{
var publisher = hostingModel == HostingModel.InProcess ? InProcessTestSite : OutOfProcessTestSite;
return GetBaseDeploymentParameters(publisher, hostingModel, publish);
}
public IISDeploymentParameters GetBaseDeploymentParameters(TestVariant variant, bool publish = false)
{
var publisher = variant.HostingModel == HostingModel.InProcess ? InProcessTestSite : OutOfProcessTestSite;
return GetBaseDeploymentParameters(publisher, new DeploymentParameters(variant), publish);
return GetBaseDeploymentParameters(publisher, hostingModel);
}
public IISDeploymentParameters GetBaseDeploymentParameters(ApplicationPublisher publisher, HostingModel hostingModel = HostingModel.InProcess, bool publish = false)
public IISDeploymentParameters GetBaseDeploymentParameters(TestVariant variant)
{
var publisher = variant.HostingModel == HostingModel.InProcess ? InProcessTestSite : OutOfProcessTestSite;
return GetBaseDeploymentParameters(publisher, new DeploymentParameters(variant));
}
public IISDeploymentParameters GetBaseDeploymentParameters(ApplicationPublisher publisher, HostingModel hostingModel = HostingModel.InProcess)
{
return GetBaseDeploymentParameters(
publisher,
new DeploymentParameters(publisher.ApplicationPath, DeployerSelector.ServerType, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64)
new DeploymentParameters()
{
ServerType = DeployerSelector.ServerType,
RuntimeFlavor = RuntimeFlavor.CoreClr,
RuntimeArchitecture = RuntimeArchitecture.x64,
HostingModel = hostingModel,
TargetFramework = Tfm.NetCoreApp30,
AncmVersion = AncmVersion.AspNetCoreModuleV2
},
publish);
});
}
public IISDeploymentParameters GetBaseDeploymentParameters(ApplicationPublisher publisher, DeploymentParameters baseParameters, bool publish = false)
public IISDeploymentParameters GetBaseDeploymentParameters(ApplicationPublisher publisher, DeploymentParameters baseParameters)
{
return new IISDeploymentParameters(baseParameters)
{
ApplicationPublisher = publisher,
ApplicationPath = publisher.ApplicationPath,
PublishApplicationBeforeDeployment = publish
PublishApplicationBeforeDeployment = true
};
}
}

View File

@ -23,17 +23,12 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
private static readonly TimeSpan RetryRequestDelay = TimeSpan.FromMilliseconds(100);
private static readonly int RetryRequestCount = 10;
public static string GetTestWebSitePath(string name)
public static string GetInProcessTestSitesName()
{
return Path.Combine(TestPathUtilities.GetSolutionRootDirectory("IISIntegration"),"IIS", "test", "testassets", name);
return DeployerSelector.IsForwardsCompatibilityTest ? "InProcessForwardsCompatWebSite" : "InProcessWebSite";
}
public static string GetInProcessTestSitesPath()
{
return DeployerSelector.IsForwardsCompatibilityTest ? GetTestWebSitePath("InProcessForwardsCompatWebSite") : GetTestWebSitePath("InProcessWebSite");
}
public static string GetOutOfProcessTestSitesPath() => GetTestWebSitePath("OutOfProcessWebSite");
public static string GetOutOfProcessTestSitesName() => "OutOfProcessWebSite";
public static async Task AssertStarts(this IISDeploymentResult deploymentResult, string path = "/HelloWorld")
{

View File

@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
private static void Configure(IISDeploymentParameters deploymentParameters)
{
deploymentParameters.ApplicationPath = Helpers.GetOutOfProcessTestSitesPath();
deploymentParameters.ApplicationPublisher = new PublishedApplicationPublisher(Helpers.GetOutOfProcessTestSitesName());;
deploymentParameters.HostingModel = HostingModel.OutOfProcess;
}
}
@ -32,7 +32,8 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
private static void Configure(IISDeploymentParameters deploymentParameters)
{
deploymentParameters.ApplicationPath = Helpers.GetOutOfProcessTestSitesPath();
deploymentParameters.ApplicationPublisher = new PublishedApplicationPublisher(Helpers.GetOutOfProcessTestSitesName());;
deploymentParameters.ApplicationPath = Helpers.GetOutOfProcessTestSitesName();
deploymentParameters.HostingModel = HostingModel.OutOfProcess;
deploymentParameters.AncmVersion = AncmVersion.AspNetCoreModule;
}
@ -108,21 +109,20 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
return;
}
var deploymentParameters = new IISDeploymentParameters(Helpers.GetInProcessTestSitesPath(),
DeployerSelector.ServerType,
RuntimeFlavor.CoreClr,
RuntimeArchitecture.x64)
var deploymentParameters = new IISDeploymentParameters()
{
RuntimeArchitecture = RuntimeArchitecture.x64,
RuntimeFlavor = RuntimeFlavor.CoreClr,
TargetFramework = Tfm.NetCoreApp30,
AncmVersion = AncmVersion.AspNetCoreModuleV2,
HostingModel = HostingModel.InProcess,
PublishApplicationBeforeDeployment = true
PublishApplicationBeforeDeployment = true,
ApplicationPublisher = new PublishedApplicationPublisher(Helpers.GetInProcessTestSitesName()),
ServerType = DeployerSelector.ServerType
};
_configure(deploymentParameters);
deploymentParameters.ApplicationPublisher = new PublishedApplicationPublisher(deploymentParameters.ApplicationPath);
_deployer = IISApplicationDeployerFactory.Create(deploymentParameters, _loggerFactory);
_deploymentResult = (IISDeploymentResult)_deployer.DeployAsync().Result;
}

View File

@ -27,7 +27,7 @@ namespace IIS.FunctionalTests.Inprocess
[ConditionalFact]
public async Task FrameworkNotFoundExceptionLogged_Pipe()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);
var deploymentResult = await DeployAsync(deploymentParameters);
@ -46,7 +46,7 @@ namespace IIS.FunctionalTests.Inprocess
public async Task FrameworkNotFoundExceptionLogged_File()
{
var deploymentParameters =
_fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
_fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);
deploymentParameters.EnableLogging(_logFolderPath);
@ -71,7 +71,7 @@ namespace IIS.FunctionalTests.Inprocess
public async Task EnableCoreHostTraceLogging_TwoLogFilesCreated()
{
var deploymentParameters =
_fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
_fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);
deploymentParameters.TransformArguments((a, _) => $"{a} CheckLargeStdOutWrites");
deploymentParameters.EnvironmentVariables["COREHOST_TRACE"] = "1";
@ -100,7 +100,7 @@ namespace IIS.FunctionalTests.Inprocess
[InlineData("CheckOversizedStdOutWrites")]
public async Task EnableCoreHostTraceLogging_PipeCaptureNativeLogs(string path)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);
deploymentParameters.EnvironmentVariables["COREHOST_TRACE"] = "1";
deploymentParameters.TransformArguments((a, _) => $"{a} {path}");
@ -125,7 +125,7 @@ namespace IIS.FunctionalTests.Inprocess
public async Task EnableCoreHostTraceLogging_FileCaptureNativeLogs(string path)
{
var deploymentParameters =
_fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);
_fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite);
deploymentParameters.EnvironmentVariables["COREHOST_TRACE"] = "1";
deploymentParameters.TransformArguments((a, _) => $"{a} {path}");

View File

@ -35,7 +35,7 @@ namespace IIS.FunctionalTests
// This test often hits a memory leak in warmup.dll module, it has been reported to IIS team
using (AppVerifier.Disable(DeployerSelector.ServerType, 0x900))
{
var baseDeploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel, publish: true);
var baseDeploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel);
baseDeploymentParameters.TransformArguments(
(args, contentRoot) => $"{args} CreateFile \"{Path.Combine(contentRoot, "Started.txt")}\"");
EnablePreload(baseDeploymentParameters);
@ -58,7 +58,7 @@ namespace IIS.FunctionalTests
// This test often hits a memory leak in warmup.dll module, it has been reported to IIS team
using (AppVerifier.Disable(DeployerSelector.ServerType, 0x900))
{
var baseDeploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel, publish: true);
var baseDeploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel);
EnablePreload(baseDeploymentParameters);
baseDeploymentParameters.ServerConfigActionList.Add(

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>

View File

@ -25,7 +25,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[RequiresIIS(IISCapability.WindowsAuthentication)]
public async Task Authentication_InProcess()
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters();
deploymentParameters.SetWindowsAuth();
var deploymentResult = await DeployAsync(deploymentParameters);

View File

@ -27,7 +27,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task ServerShutsDownWhenMainExits()
{
var parameters = _fixture.GetBaseDeploymentParameters(publish: true);
var parameters = _fixture.GetBaseDeploymentParameters();
var deploymentResult = await DeployAsync(parameters);
try
{
@ -45,7 +45,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task ServerShutsDownWhenMainExitsStress()
{
var parameters = _fixture.GetBaseDeploymentParameters(publish: true);
var parameters = _fixture.GetBaseDeploymentParameters();
var deploymentResult = await StartAsync(parameters);
var load = Helpers.StressLoad(deploymentResult.HttpClient, "/HelloWorld", response => {
@ -69,7 +69,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task GracefulShutdown_DoesNotCrashProcess()
{
var parameters = _fixture.GetBaseDeploymentParameters(publish: true);
var parameters = _fixture.GetBaseDeploymentParameters();
var result = await DeployAsync(parameters);
var response = await result.HttpClient.GetAsync("/HelloWorld");
@ -80,7 +80,7 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
[ConditionalFact]
public async Task ForcefulShutdown_DoesCrashProcess()
{
var parameters = _fixture.GetBaseDeploymentParameters(publish: true);
var parameters = _fixture.GetBaseDeploymentParameters();
var result = await DeployAsync(parameters);
var response = await result.HttpClient.GetAsync("/HelloWorld");

View File

@ -29,7 +29,6 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
// fails due to not modifying the apphost.config file.
return UpgradeFeatureDetectionDeployer(
disableWebSocket: true,
Helpers.GetInProcessTestSitesPath(),
"Disabled", HostingModel.InProcess);
}
@ -38,7 +37,6 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
return UpgradeFeatureDetectionDeployer(
disableWebSocket: false,
Helpers.GetInProcessTestSitesPath(),
_isWebsocketsSupported, HostingModel.InProcess);
}
@ -47,7 +45,6 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
return UpgradeFeatureDetectionDeployer(
disableWebSocket: true,
Helpers.GetOutOfProcessTestSitesPath(),
"Disabled", HostingModel.OutOfProcess);
}
@ -56,13 +53,12 @@ namespace Microsoft.AspNetCore.Server.IISIntegration.FunctionalTests
{
return UpgradeFeatureDetectionDeployer(
disableWebSocket: false,
Helpers.GetOutOfProcessTestSitesPath(),
_isWebsocketsSupported, HostingModel.OutOfProcess);
}
private async Task UpgradeFeatureDetectionDeployer(bool disableWebSocket, string sitePath, string expected, HostingModel hostingModel)
private async Task UpgradeFeatureDetectionDeployer(bool disableWebSocket, string expected, HostingModel hostingModel)
{
var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel, publish: true);
var deploymentParameters = _fixture.GetBaseDeploymentParameters(hostingModel);
if (disableWebSocket)
{

View File

@ -4,6 +4,7 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TestAssetOutputName>InProcessForwardsCompatWebSite</TestAssetOutputName>
</PropertyGroup>
<ItemGroup Condition="'$(OS)' == 'Windows_NT'">

View File

@ -19,10 +19,10 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
}
public IISDeploymentParameters(
string applicationPath,
ServerType serverType,
RuntimeFlavor runtimeFlavor,
RuntimeArchitecture runtimeArchitecture)
string applicationPath,
ServerType serverType,
RuntimeFlavor runtimeFlavor,
RuntimeArchitecture runtimeArchitecture)
: base(applicationPath, serverType, runtimeFlavor, runtimeArchitecture)
{
}

View File

@ -115,27 +115,30 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting.IIS
private string CheckIfPublishIsRequired()
{
string dllRoot = null;
var targetFramework = DeploymentParameters.TargetFramework;
// IISIntegration uses this layout
var dllRoot = Path.Combine(DeploymentParameters.ApplicationPath, "bin", DeploymentParameters.RuntimeArchitecture.ToString(),
DeploymentParameters.Configuration, targetFramework);
if (!Directory.Exists(dllRoot))
if (!string.IsNullOrEmpty(DeploymentParameters.ApplicationPath))
{
// Most repos use this layout
dllRoot = Path.Combine(DeploymentParameters.ApplicationPath, "bin", DeploymentParameters.Configuration, targetFramework);
// IISIntegration uses this layout
dllRoot = Path.Combine(DeploymentParameters.ApplicationPath, "bin", DeploymentParameters.RuntimeArchitecture.ToString(),
DeploymentParameters.Configuration, targetFramework);
if (!Directory.Exists(dllRoot))
{
// The bits we need weren't pre-compiled, compile on publish
DeploymentParameters.PublishApplicationBeforeDeployment = true;
}
else if (DeploymentParameters.RuntimeFlavor == RuntimeFlavor.Clr
&& DeploymentParameters.RuntimeArchitecture == RuntimeArchitecture.x86)
{
// x64 is the default. Publish to rebuild for the right bitness
DeploymentParameters.PublishApplicationBeforeDeployment = true;
// Most repos use this layout
dllRoot = Path.Combine(DeploymentParameters.ApplicationPath, "bin", DeploymentParameters.Configuration, targetFramework);
if (!Directory.Exists(dllRoot))
{
// The bits we need weren't pre-compiled, compile on publish
DeploymentParameters.PublishApplicationBeforeDeployment = true;
}
else if (DeploymentParameters.RuntimeFlavor == RuntimeFlavor.Clr
&& DeploymentParameters.RuntimeArchitecture == RuntimeArchitecture.x86)
{
// x64 is the default. Publish to rebuild for the right bitness
DeploymentParameters.PublishApplicationBeforeDeployment = true;
}
}
}

View File

@ -6,10 +6,12 @@
<IISExpressAppHostConfig>$(MSBuildThisFileDirectory)applicationhost.config</IISExpressAppHostConfig>
<IISAppHostConfig>$(MSBuildThisFileDirectory)applicationhost.iis.config</IISAppHostConfig>
<PreserveCompilationContext>false</PreserveCompilationContext>
<DisableFastUpToDateCheck>True</DisableFastUpToDateCheck>
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
<!-- Work around until we get a new WebSdk -->
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
<BuildProjectReferences Condition="'$(_InsidePublishTestsAssets)' == 'True'">False</BuildProjectReferences>
<HasTestAssetProfile Condition="'$(TestAssetProfile)' != ''">true</HasTestAssetProfile>
<AppendRuntimeIdentifierToOutputPath Condition="'$(HasTestAssetProfile)' == 'true'">false</AppendRuntimeIdentifierToOutputPath>
<TestAssetOutputName Condition="'$(TestAssetOutputName)' == ''">$(MSBuildProjectName)</TestAssetOutputName>
</PropertyGroup>
<Import Project="assets.props" />
@ -26,14 +28,6 @@
<NativeFolder>x64</NativeFolder>
</PropertyGroup>
<PropertyGroup>
<!-- For standalone publish, all dlls are flattened to the same folder.
Set the base path to the request handler
-->
<BasePathForRequestHandler Condition="'$(RuntimeIdentifier)' == ''">$(NativePlatform)\</BasePathForRequestHandler>
</PropertyGroup>
<PropertyGroup>
<IISExpressArguments>/config:"$(IISExpressAppHostConfig)" /systray:false</IISExpressArguments>
<IISArguments>-h "$(IISAppHostConfig)"</IISArguments>
@ -50,7 +44,7 @@
<!-- Deps file injection-->
<ItemGroup Condition="('$(InProcessTestSite)' == 'true') AND ('$(ReferenceTestTasks)' != 'false')">
<ProjectReference Include="$(MSBuildThisFileDirectory)..\IIS\test\testassets\TestTasks\TestTasks.csproj">
<ReferenceOutputAssembly>False</ReferenceOutputAssembly>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
@ -64,7 +58,6 @@
</PropertyGroup>
</Target>
<Target Name="InjectRequestHandler"
Condition=" '$(InProcessTestSite)' == 'true' AND '$(BuildIisNativeProjects)' == 'true' AND '$(TargetFrameworkIdentifier)' != '.NETFramework'"
AfterTargets="GenerateBuildDependencyFile"
@ -79,7 +72,24 @@
<Exec Command="$(InjectDepsApp) &quot;$(PublishDepsFilePath)&quot; $(RuntimeIdentifier) " />
</Target>
<Target Name="PublishTestsAssets" AfterTargets="Build" Condition="'$(_InsidePublishTestsAssets)' != 'true' AND '@(TestAssetPublishProfile->Count())' != '0'">
<Target Name="PreventProjectReferencesFromBuilding" BeforeTargets="BeforeResolveReferences" Condition="'@(TestAssetPublishProfile->Count())' != '0'">
<PropertyGroup>
<BuildProjectReferences Condition="'$(HasTestAssetProfile)' == 'true'">false</BuildProjectReferences>
</PropertyGroup>
</Target>
<Target Name="PrepareForTestAssetPublish" BeforeTargets="PrepareForPublish" Condition="'@(TestAssetPublishProfile->Count())' != '0'">
<PropertyGroup Condition="'$(HasTestAssetProfile)' == 'true'">
<PublishDir>$(OutputPath)$(PublishDirName)\$(TestAssetOutputName)-$(TestAssetProfile)\</PublishDir>
</PropertyGroup>
<PropertyGroup Condition="'$(HasTestAssetProfile)' != 'true'">
<IsPublishable>false</IsPublishable>
<IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
</PropertyGroup>
</Target>
<Target Name="PublishTestsAssets" AfterTargets="Build;Publish" Condition="'$(TestAssetProfile)' == '' AND '@(TestAssetPublishProfile->Count())' != '0'">
<!--
_InsidePublishTestsAssets is to avoid invoking this target recursively
@ -87,6 +97,6 @@
<MSBuild Projects="$(MSBuildProjectFullPath)"
Targets="Publish"
RemoveProperties="Platform;PlatformTarget"
Properties="ReferenceTestTasks=false;_InsidePublishTestsAssets=True;PublishDir=$(PublishDir)%(TestAssetPublishProfile.Identity)/;%(TestAssetPublishProfile.Properties)" />
Properties="TestAssetProfile=%(TestAssetPublishProfile.Identity);ReferenceTestTasks=false;%(TestAssetPublishProfile.Properties)" />
</Target>
</Project>