Update server test infrastructure, remove Helios concepts.
This commit is contained in:
parent
c426fa97d5
commit
0131015b43
|
|
@ -89,6 +89,9 @@ namespace Microsoft.AspNet.Server.Testing
|
|||
/// </summary>
|
||||
public Action<DeploymentParameters> UserAdditionalCleanup { get; set; }
|
||||
|
||||
// Which command in the test project to run.
|
||||
public string Command { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format(
|
||||
|
|
|
|||
|
|
@ -27,14 +27,14 @@ namespace Microsoft.AspNet.Server.Testing
|
|||
{
|
||||
for (int retry = 0; retry < retryCount; retry++)
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
logger.LogInformation("Failed to connect, retry canceled.");
|
||||
throw new OperationCanceledException("Failed to connect, retry canceled.", cancellationToken);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
logger.LogInformation("Stopping retry as cancellation token is triggered.");
|
||||
break;
|
||||
}
|
||||
|
||||
logger.LogWarning("Retry count {retryCount}..", retry + 1);
|
||||
var response = await retryBlock();
|
||||
|
||||
|
|
@ -45,12 +45,13 @@ namespace Microsoft.AspNet.Server.Testing
|
|||
continue;
|
||||
}
|
||||
|
||||
return response; //Went through successfully
|
||||
return response; // Went through successfully
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
if (retry == retryCount - 1)
|
||||
{
|
||||
logger.LogError("Failed to connect, retry limit exceeded.", exception);
|
||||
throw;
|
||||
}
|
||||
else
|
||||
|
|
@ -68,7 +69,8 @@ namespace Microsoft.AspNet.Server.Testing
|
|||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
logger.LogInformation("Failed to connect, retry limit exceeded.");
|
||||
throw new OperationCanceledException("Failed to connect, retry limit exceeded.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,6 @@ namespace Microsoft.AspNet.Server.Testing
|
|||
{
|
||||
IISExpress,
|
||||
IIS,
|
||||
IISNativeModule,
|
||||
WebListener,
|
||||
Kestrel
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace Microsoft.AspNet.Server.Testing
|
|||
{
|
||||
var runtimePath = Process.GetCurrentProcess().MainModule.FileName;
|
||||
Logger.LogInformation(string.Empty);
|
||||
Logger.LogInformation("Current runtime path is : {0}", runtimePath);
|
||||
Logger.LogInformation($"Current runtime path is : {runtimePath}");
|
||||
|
||||
var replaceStr = new StringBuilder().
|
||||
Append("dnx").
|
||||
|
|
@ -62,7 +62,7 @@ namespace Microsoft.AspNet.Server.Testing
|
|||
|
||||
ChosenRuntimeName = runtimeDirectoryInfo.Parent.Name;
|
||||
Logger.LogInformation(string.Empty);
|
||||
Logger.LogInformation("Changing to use runtime : {runtimeName}", ChosenRuntimeName);
|
||||
Logger.LogInformation($"Changing to use runtime : {ChosenRuntimeName}");
|
||||
return ChosenRuntimeName;
|
||||
}
|
||||
|
||||
|
|
@ -70,16 +70,13 @@ namespace Microsoft.AspNet.Server.Testing
|
|||
{
|
||||
DeploymentParameters.PublishedApplicationRootPath = Path.Combine(publishRoot ?? Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
|
||||
var parameters =
|
||||
string.Format(
|
||||
"publish {0} -o {1} --runtime {2} {3}",
|
||||
DeploymentParameters.ApplicationPath,
|
||||
DeploymentParameters.PublishedApplicationRootPath,
|
||||
DeploymentParameters.DnxRuntime,
|
||||
DeploymentParameters.PublishWithNoSource ? "--no-source" : string.Empty);
|
||||
var noSource = DeploymentParameters.PublishWithNoSource ? "--no-source" : string.Empty;
|
||||
var command = DeploymentParameters.Command ?? "web";
|
||||
var parameters = $"publish {DeploymentParameters.ApplicationPath} -o {DeploymentParameters.PublishedApplicationRootPath}"
|
||||
+ $" --runtime {DeploymentParameters.DnxRuntime} {noSource} --iis-command {command}";
|
||||
|
||||
var dnuPath = Path.Combine(ChosenRuntimePath, "dnu.cmd");
|
||||
Logger.LogInformation("Executing command {dnu} {args}", dnuPath, parameters);
|
||||
Logger.LogInformation($"Executing command {dnuPath} {parameters}");
|
||||
|
||||
var startInfo = new ProcessStartInfo
|
||||
{
|
||||
|
|
@ -106,13 +103,12 @@ namespace Microsoft.AspNet.Server.Testing
|
|||
|
||||
DeploymentParameters.ApplicationPath =
|
||||
(DeploymentParameters.ServerType == ServerType.IISExpress ||
|
||||
DeploymentParameters.ServerType == ServerType.IISNativeModule ||
|
||||
DeploymentParameters.ServerType == ServerType.IIS) ?
|
||||
Path.Combine(DeploymentParameters.PublishedApplicationRootPath, "wwwroot") :
|
||||
Path.Combine(DeploymentParameters.PublishedApplicationRootPath, "approot", "src",
|
||||
new DirectoryInfo(DeploymentParameters.ApplicationPath).Name);
|
||||
|
||||
Logger.LogInformation("dnu publish finished with exit code : {exitCode}", hostProcess.ExitCode);
|
||||
Logger.LogInformation($"dnu publish finished with exit code : {hostProcess.ExitCode}");
|
||||
}
|
||||
|
||||
protected void CleanPublishedOutput()
|
||||
|
|
@ -124,7 +120,7 @@ namespace Microsoft.AspNet.Server.Testing
|
|||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Logger.LogWarning("Failed to delete directory : {error}", exception.Message);
|
||||
Logger.LogWarning($"Failed to delete directory : {exception.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -225,7 +221,7 @@ namespace Microsoft.AspNet.Server.Testing
|
|||
|
||||
protected void StartTimer()
|
||||
{
|
||||
Logger.LogInformation("Deploying {VariationDetails}", DeploymentParameters.ToString());
|
||||
Logger.LogInformation($"Deploying {DeploymentParameters.ToString()}");
|
||||
StopWatch.Start();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ namespace Microsoft.AspNet.Server.Testing
|
|||
return new IISExpressDeployer(deploymentParameters, logger);
|
||||
#if DNX451
|
||||
case ServerType.IIS:
|
||||
case ServerType.IISNativeModule:
|
||||
return new IISDeployer(deploymentParameters, logger);
|
||||
#endif
|
||||
case ServerType.WebListener:
|
||||
|
|
|
|||
|
|
@ -41,14 +41,8 @@ namespace Microsoft.AspNet.Server.Testing
|
|||
// Publish to IIS root\application folder.
|
||||
DnuPublish(publishRoot: _application.WebSiteRootFolder);
|
||||
|
||||
// Drop an ini file instead of setting environment variable.
|
||||
SetAspEnvironmentWithIni();
|
||||
|
||||
// Setup the IIS Application.
|
||||
if (DeploymentParameters.ServerType == ServerType.IISNativeModule)
|
||||
{
|
||||
TurnRammFarOnNativeModule();
|
||||
}
|
||||
// Drop a json file instead of setting environment variable.
|
||||
SetAspEnvironmentWithJson();
|
||||
|
||||
lock (_syncObject)
|
||||
{
|
||||
|
|
@ -70,30 +64,12 @@ namespace Microsoft.AspNet.Server.Testing
|
|||
};
|
||||
}
|
||||
|
||||
private void SetAspEnvironmentWithIni()
|
||||
private void SetAspEnvironmentWithJson()
|
||||
{
|
||||
// Drop a Microsoft.AspNet.Hosting.ini with ASPNET_ENV information.
|
||||
Logger.LogInformation("Creating Microsoft.AspNet.Hosting.ini file with ASPNET_ENV.");
|
||||
var iniFile = Path.Combine(DeploymentParameters.ApplicationPath, "Microsoft.AspNet.Hosting.ini");
|
||||
File.WriteAllText(iniFile, string.Format("ASPNET_ENV={0}", DeploymentParameters.EnvironmentName));
|
||||
}
|
||||
|
||||
private void TurnRammFarOnNativeModule()
|
||||
{
|
||||
Logger.LogInformation("Turning runAllManagedModulesForAllRequests=true in web.config for native module.");
|
||||
var webConfig = Path.Combine(DeploymentParameters.ApplicationPath, "web.config");
|
||||
var configuration = new XmlDocument();
|
||||
configuration.LoadXml(File.ReadAllText(webConfig));
|
||||
|
||||
// https://github.com/aspnet/Helios/issues/77
|
||||
var rammfarAttribute = configuration.CreateAttribute("runAllManagedModulesForAllRequests");
|
||||
rammfarAttribute.Value = "true";
|
||||
var modulesNode = configuration.CreateElement("modules");
|
||||
modulesNode.Attributes.Append(rammfarAttribute);
|
||||
var systemWebServerNode = configuration.CreateElement("system.webServer");
|
||||
systemWebServerNode.AppendChild(modulesNode);
|
||||
configuration.SelectSingleNode("//configuration").AppendChild(systemWebServerNode);
|
||||
configuration.Save(webConfig);
|
||||
// Drop a Microsoft.AspNet.Hosting.json with Hosting:Environment information.
|
||||
Logger.LogInformation("Creating Microsoft.AspNet.Hosting.json file with Hosting:Environment.");
|
||||
var jsonFile = Path.Combine(DeploymentParameters.ApplicationPath, "Microsoft.AspNet.Hosting.json");
|
||||
File.WriteAllText(jsonFile, string.Format("{ \"Hosting:Environment\":\"{0}\" }", DeploymentParameters.EnvironmentName));
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
|
|
@ -118,8 +94,6 @@ namespace Microsoft.AspNet.Server.Testing
|
|||
private class IISApplication
|
||||
{
|
||||
private const string WebSiteName = "ASPNETTESTRUNS";
|
||||
private const string NativeModuleManagedRuntimeVersion = "vCoreFX";
|
||||
private const string Dotnet45RuntimeVersion = "v4.0.30319";
|
||||
|
||||
private readonly ServerManager _serverManager = new ServerManager();
|
||||
private readonly DeploymentParameters _deploymentParameters;
|
||||
|
|
@ -176,10 +150,7 @@ namespace Microsoft.AspNet.Server.Testing
|
|||
private ApplicationPool CreateAppPool(string appPoolName)
|
||||
{
|
||||
var applicationPool = _serverManager.ApplicationPools.Add(appPoolName);
|
||||
applicationPool.ManagedRuntimeVersion =
|
||||
_deploymentParameters.ServerType == ServerType.IISNativeModule ?
|
||||
NativeModuleManagedRuntimeVersion :
|
||||
Dotnet45RuntimeVersion;
|
||||
applicationPool.ManagedRuntimeVersion = string.Empty;
|
||||
|
||||
applicationPool.Enable32BitAppOnWin64 = (_deploymentParameters.RuntimeArchitecture == RuntimeArchitecture.x86);
|
||||
_logger.LogInformation("Created {bit} application pool '{name}' with runtime version {runtime}.",
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ using System;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using Microsoft.Dnx.Runtime;
|
||||
using Microsoft.Dnx.Runtime.Infrastructure;
|
||||
using Microsoft.Framework.Logging;
|
||||
|
||||
namespace Microsoft.AspNet.Server.Testing
|
||||
|
|
@ -30,6 +28,8 @@ namespace Microsoft.AspNet.Server.Testing
|
|||
|
||||
DeploymentParameters.DnxRuntime = PopulateChosenRuntimeInformation();
|
||||
|
||||
// For now we always auto-publish. Otherwise we'll have to write our own local web.config for the HttpPlatformHandler
|
||||
DeploymentParameters.PublishApplicationBeforeDeployment = true;
|
||||
if (DeploymentParameters.PublishApplicationBeforeDeployment)
|
||||
{
|
||||
DnuPublish();
|
||||
|
|
@ -57,18 +57,12 @@ namespace Microsoft.AspNet.Server.Testing
|
|||
|
||||
DeploymentParameters.ApplicationHostConfigTemplateContent =
|
||||
DeploymentParameters.ApplicationHostConfigTemplateContent
|
||||
.Replace("[ApplicationPhysicalPath]", Path.Combine(DeploymentParameters.ApplicationPath, "wwwroot"))
|
||||
.Replace("[PORT]", new Uri(DeploymentParameters.ApplicationBaseUriHint).Port.ToString());
|
||||
.Replace("[ApplicationPhysicalPath]", DeploymentParameters.ApplicationPath)
|
||||
.Replace("[PORT]", new Uri(DeploymentParameters.ApplicationBaseUriHint).Port.ToString());
|
||||
|
||||
DeploymentParameters.ApplicationHostConfigLocation = Path.GetTempFileName();
|
||||
|
||||
File.WriteAllText(DeploymentParameters.ApplicationHostConfigLocation,
|
||||
DeploymentParameters.ApplicationHostConfigTemplateContent.Replace("[ApplicationPhysicalPath]", DeploymentParameters.ApplicationPath));
|
||||
}
|
||||
|
||||
if (!DeploymentParameters.PublishApplicationBeforeDeployment)
|
||||
{
|
||||
CopyAspNetLoader();
|
||||
File.WriteAllText(DeploymentParameters.ApplicationHostConfigLocation, DeploymentParameters.ApplicationHostConfigTemplateContent);
|
||||
}
|
||||
|
||||
var webroot = DeploymentParameters.ApplicationPath;
|
||||
|
|
@ -129,38 +123,6 @@ namespace Microsoft.AspNet.Server.Testing
|
|||
return hostExitTokenSource.Token;
|
||||
}
|
||||
|
||||
private void CopyAspNetLoader()
|
||||
{
|
||||
var libraryManager = (ILibraryManager)CallContextServiceLocator.Locator.ServiceProvider.GetService(typeof(ILibraryManager));
|
||||
var interopLibrary = libraryManager.GetLibrary("Microsoft.AspNet.Loader.IIS.Interop");
|
||||
|
||||
if (interopLibrary == null)
|
||||
{
|
||||
throw new Exception(
|
||||
string.Format("Include Microsoft.AspNet.Server.IIS package in your project.json to deploy in {0}.",
|
||||
ServerType.IISExpress));
|
||||
}
|
||||
|
||||
var aspNetLoaderSrcPath = Path.Combine(interopLibrary.Path, "tools", "AspNet.Loader.dll");
|
||||
var aspNetLoaderDestPath = Path.Combine(DeploymentParameters.ApplicationPath, "wwwroot", "bin", "AspNet.Loader.dll");
|
||||
|
||||
// Create bin directory if it does not exist.
|
||||
Directory.CreateDirectory(new DirectoryInfo(aspNetLoaderDestPath).Parent.FullName);
|
||||
|
||||
if (!File.Exists(aspNetLoaderDestPath))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Copy(aspNetLoaderSrcPath, aspNetLoaderDestPath);
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
// Ignore file already exists exception. Sometimes multiple tests might try
|
||||
// doing the same and one of them wins.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string GetIISExpressPath()
|
||||
{
|
||||
// Get path to program files
|
||||
|
|
|
|||
|
|
@ -47,9 +47,13 @@ namespace Microsoft.AspNet.Server.Testing
|
|||
|
||||
private CancellationToken StartSelfHost()
|
||||
{
|
||||
var commandName = DeploymentParameters.ServerType == ServerType.WebListener ? "web" : "kestrel";
|
||||
var commandName = DeploymentParameters.Command;
|
||||
if (string.IsNullOrEmpty(commandName))
|
||||
{
|
||||
commandName = DeploymentParameters.ServerType == ServerType.WebListener ? "web" : "kestrel";
|
||||
}
|
||||
var dnxPath = Path.Combine(ChosenRuntimePath, "dnx.exe");
|
||||
var dnxArgs = $"--appbase \"{DeploymentParameters.ApplicationPath}\" Microsoft.Dnx.ApplicationHost {commandName} --server.urls {DeploymentParameters.ApplicationBaseUriHint}";
|
||||
var dnxArgs = $"-p \"{DeploymentParameters.ApplicationPath}\" Microsoft.Dnx.ApplicationHost {commandName} --server.urls {DeploymentParameters.ApplicationBaseUriHint}";
|
||||
Logger.LogInformation("Executing {dnxexe} {dnxArgs}", dnxPath, dnxArgs);
|
||||
|
||||
var startInfo = new ProcessStartInfo
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
// 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 Microsoft.AspNet.Testing.xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Server.Testing
|
||||
{
|
||||
/// <summary>
|
||||
/// Skip test if IIS native module is not enabled. To enable setup native module
|
||||
/// and set environment variable IIS_NATIVE_VARIATIONS_ENABLED=true for the test process.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
||||
public class SkipIfIISNativeVariationsNotEnabledAttribute : Attribute, ITestCondition
|
||||
{
|
||||
public bool IsMet
|
||||
{
|
||||
get
|
||||
{
|
||||
return Environment.GetEnvironmentVariable("IIS_NATIVE_VARIATIONS_ENABLED") == "true";
|
||||
}
|
||||
}
|
||||
|
||||
public string SkipReason
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Skipping Native module test since native module variations are not enabled. " +
|
||||
"To run the test, setup the native module and set the environment variable IIS_NATIVE_VARIATIONS_ENABLED=true.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue