react to aspnet/Hosting#996 (#769)

This commit is contained in:
Andrew Stanton-Nurse 2017-03-31 13:30:20 -07:00 committed by GitHub
parent 6922cbb903
commit 049ee03d22
10 changed files with 400 additions and 365 deletions

View File

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26206.0
VisualStudioVersion = 15.0.26228.10
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7D749BDA-4638-4517-B66A-D40DEDEEB141}"
ProjectSection(SolutionItems) = preProject

View File

@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<AspNetCoreVersion>1.2.0-*</AspNetCoreVersion>
<AspNetCoreLabsVersion>0.3.0-*</AspNetCoreLabsVersion>
<AspNetIntegrationTestingVersion>0.4.0-*</AspNetIntegrationTestingVersion>
<AspNetCoreModuleVersion>1.0.0-*</AspNetCoreModuleVersion>
<DotNetPlatformAbstractionsVersion>1.1.0</DotNetPlatformAbstractionsVersion>
<CoreFxVersion>4.3.0</CoreFxVersion>

View File

@ -19,7 +19,7 @@
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Server.IntegrationTesting" Version="$(AspNetCoreLabsVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Server.IntegrationTesting" Version="$(AspNetIntegrationTestingVersion)" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="$(DotNetPlatformAbstractionsVersion)" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="$(AspNetCoreVersion)" />
@ -28,6 +28,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Testing" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
<PackageReference Include="System.Data.SqlClient" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Xml.XmlDocument" Version="$(CoreFxVersion)" />

View File

@ -5,7 +5,7 @@
For schema documentation, see
%IIS_BIN%\config\schema\IIS_schema.xml.
Please make a backup of this file before making any changes to it.
NOTE: The following environment variables are available to be used
@ -25,20 +25,20 @@
The <configSections> section controls the registration of sections.
Section is the basic unit of deployment, locking, searching and
containment for configuration settings.
Every section belongs to one section group.
A section group is a container of logically-related sections.
Sections cannot be nested.
Section groups may be nested.
<section
name="" [Required, Collection Key] [XML name of the section]
allowDefinition="Everywhere" [MachineOnly|MachineToApplication|AppHostOnly|Everywhere] [Level where it can be set]
overrideModeDefault="Allow" [Allow|Deny] [Default delegation mode]
allowLocation="true" [true|false] [Allowed in location tags]
/>
The recommended way to unlock sections is by using a location tag:
<location path="Default Web Site" overrideMode="Allow">
<system.webServer>

View File

@ -5,7 +5,7 @@
For schema documentation, see
%IIS_BIN%\config\schema\IIS_schema.xml.
Please make a backup of this file before making any changes to it.
NOTE: The following environment variables are available to be used
@ -25,20 +25,20 @@
The <configSections> section controls the registration of sections.
Section is the basic unit of deployment, locking, searching and
containment for configuration settings.
Every section belongs to one section group.
A section group is a container of logically-related sections.
Sections cannot be nested.
Section groups may be nested.
<section
name="" [Required, Collection Key] [XML name of the section]
allowDefinition="Everywhere" [MachineOnly|MachineToApplication|AppHostOnly|Everywhere] [Level where it can be set]
overrideModeDefault="Allow" [Allow|Deny] [Default delegation mode]
allowLocation="true" [true|false] [Allowed in location tags]
/>
The recommended way to unlock sections is by using a location tag:
<location path="Default Web Site" overrideMode="Allow">
<system.webServer>

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
@ -13,88 +13,96 @@ using Xunit.Abstractions;
namespace E2ETests
{
// Uses ports ranging 5050 - 5060.
public class NtlmAuthenticationTests : IDisposable
{
private readonly XunitLogger _logger;
private readonly ILoggerFactory _loggerFactory;
public NtlmAuthenticationTests(ITestOutputHelper output)
{
_logger = new XunitLogger(output, LogLevel.Information);
_loggerFactory = new LoggerFactory()
.AddXunit(output);
}
[ConditionalTheory, Trait("E2Etests", "E2Etests")]
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable, "http://localhost:5050/")]
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone, "http://localhost:5051/")]
[InlineData(ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable, "http://localhost:5052/")]
[InlineData(ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone, "http://localhost:5053/")]
public async Task NtlmAuthenticationTest(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType, string applicationBaseUrl)
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable)]
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone)]
[InlineData(ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable)]
[InlineData(ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone)]
public async Task NtlmAuthenticationTest(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType)
{
using (_logger.BeginScope("NtlmAuthenticationTest"))
try
{
var musicStoreDbName = DbUtils.GetUniqueName();
var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
Console.WriteLine("NtlmAuthenticationTest");
var logger = _loggerFactory.CreateLogger($"NtlmAuthentication:{serverType}:{runtimeFlavor}:{architecture}:{applicationType}");
using (logger.BeginScope("NtlmAuthenticationTest"))
{
PublishApplicationBeforeDeployment = true,
PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging,
TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net451" : "netcoreapp1.1",
Configuration = Helpers.GetCurrentBuildConfiguration(),
ApplicationType = applicationType,
ApplicationBaseUriHint = applicationBaseUrl,
EnvironmentName = "NtlmAuthentication", //Will pick the Start class named 'StartupNtlmAuthentication'
ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "NtlmAuthentation.config")) : null,
SiteName = "MusicStoreNtlmAuthentication", //This is configured in the NtlmAuthentication.config
UserAdditionalCleanup = parameters =>
var musicStoreDbName = DbUtils.GetUniqueName();
var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
{
DbUtils.DropDatabase(musicStoreDbName, _logger);
PublishApplicationBeforeDeployment = true,
PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging,
TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net451" : "netcoreapp1.1",
Configuration = Helpers.GetCurrentBuildConfiguration(),
ApplicationType = applicationType,
EnvironmentName = "NtlmAuthentication", //Will pick the Start class named 'StartupNtlmAuthentication'
ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "NtlmAuthentation.config")) : null,
SiteName = "MusicStoreNtlmAuthentication", //This is configured in the NtlmAuthentication.config
UserAdditionalCleanup = parameters =>
{
DbUtils.DropDatabase(musicStoreDbName, logger);
}
};
if (applicationType == ApplicationType.Standalone)
{
deploymentParameters.AdditionalPublishParameters = " -r " + RuntimeEnvironment.GetRuntimeIdentifier();
}
};
if (applicationType == ApplicationType.Standalone)
{
deploymentParameters.AdditionalPublishParameters = " -r " + RuntimeEnvironment.GetRuntimeIdentifier();
}
// Override the connection strings using environment based configuration
deploymentParameters.EnvironmentVariables
.Add(new KeyValuePair<string, string>(
MusicStoreConfig.ConnectionStringKey,
DbUtils.CreateConnectionString(musicStoreDbName)));
// Override the connection strings using environment based configuration
deploymentParameters.EnvironmentVariables
.Add(new KeyValuePair<string, string>(
MusicStoreConfig.ConnectionStringKey,
DbUtils.CreateConnectionString(musicStoreDbName)));
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, _logger))
{
var deploymentResult = deployer.Deploy();
var httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true };
var httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) };
// Request to base address and check if various parts of the body are rendered & measure the cold startup time.
var response = await RetryHelper.RetryRequest(async () =>
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, _loggerFactory))
{
return await httpClient.GetAsync(string.Empty);
}, logger: _logger, cancellationToken: deploymentResult.HostShutdownToken);
var deploymentResult = await deployer.DeployAsync();
var httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true };
var httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) };
Assert.False(response == null, "Response object is null because the client could not " +
"connect to the server after multiple retries");
// Request to base address and check if various parts of the body are rendered & measure the cold startup time.
var response = await RetryHelper.RetryRequest(async () =>
{
return await httpClient.GetAsync(string.Empty);
}, logger: logger, cancellationToken: deploymentResult.HostShutdownToken);
var validator = new Validator(httpClient, httpClientHandler, _logger, deploymentResult);
Assert.False(response == null, "Response object is null because the client could not " +
"connect to the server after multiple retries");
Console.WriteLine("Verifying home page");
await validator.VerifyNtlmHomePage(response);
var validator = new Validator(httpClient, httpClientHandler, logger, deploymentResult);
Console.WriteLine("Verifying access to store with permissions");
await validator.AccessStoreWithPermissions();
Console.WriteLine("Verifying home page");
await validator.VerifyNtlmHomePage(response);
_logger.LogInformation("Variation completed successfully.");
Console.WriteLine("Verifying access to store with permissions");
await validator.AccessStoreWithPermissions();
logger.LogInformation("Variation completed successfully.");
}
}
}
finally
{
Console.WriteLine("Finished NtlmAuthenticationTest");
}
}
public void Dispose()
{
_logger.Dispose();
_loggerFactory.Dispose();
}
}
}

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
@ -12,114 +12,121 @@ using Xunit.Abstractions;
namespace E2ETests
{
// Uses ports ranging 5040 - 5049.
public class OpenIdConnectTests : IDisposable
{
private readonly XunitLogger _logger;
private readonly ILoggerFactory _loggerFactory;
public OpenIdConnectTests(ITestOutputHelper output)
{
_logger = new XunitLogger(output, LogLevel.Information);
_loggerFactory = new LoggerFactory()
.AddXunit(output);
}
[ConditionalTheory, Trait("E2Etests", "E2Etests")]
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
//[InlineData(ServerType.Kestrel, RuntimeFlavor.Clr, RuntimeArchitecture.x64, ApplicationType.Portable, "http://localhost:5040/")]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable, "http://localhost:5041/")]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone, "http://localhost:5042/")]
//[InlineData(ServerType.Kestrel, RuntimeFlavor.Clr, RuntimeArchitecture.x64, ApplicationType.Portable)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone)]
public async Task OpenIdConnect_OnWindowsOS(
ServerType serverType,
RuntimeFlavor runtimeFlavor,
RuntimeArchitecture architecture,
ApplicationType applicationType,
string applicationBaseUrl)
ApplicationType applicationType)
{
await OpenIdConnectTestSuite(serverType, runtimeFlavor, architecture, applicationType, applicationBaseUrl);
await OpenIdConnectTestSuite(serverType, runtimeFlavor, architecture, applicationType);
}
[ConditionalTheory, Trait("E2Etests", "E2Etests")]
[OSSkipCondition(OperatingSystems.Windows)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable, "http://localhost:5043/")]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone, "http://localhost:5044/", Skip = "https://github.com/aspnet/MusicStore/issues/761")]
public async Task OpenIdConnect_OnNonWindows(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType, string applicationBaseUrl)
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone, Skip = "https://github.com/aspnet/MusicStore/issues/761")]
public async Task OpenIdConnect_OnNonWindows(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType)
{
await OpenIdConnectTestSuite(serverType, runtimeFlavor, architecture, applicationType, applicationBaseUrl);
await OpenIdConnectTestSuite(serverType, runtimeFlavor, architecture, applicationType);
}
// TODO: temporarily disabling x86 tests as dotnet xunit test runner currently does not support 32-bit
//[ConditionalTheory(Skip = "https://github.com/aspnet/MusicStore/issues/565"), Trait("E2Etests", "E2Etests")]
//[OSSkipCondition(OperatingSystems.Windows)]
//[InlineData(ServerType.Kestrel, RuntimeFlavor.Clr, RuntimeArchitecture.x86, ApplicationType.Portable, "http://localhost:5045/")]
//public async Task OpenIdConnect_OnMono(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType, string applicationBaseUrl)
//[InlineData(ServerType.Kestrel, RuntimeFlavor.Clr, RuntimeArchitecture.x86, ApplicationType.Portable)]
//public async Task OpenIdConnect_OnMono(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType)
//{
// await OpenIdConnectTestSuite(serverType, runtimeFlavor, architecture, applicationBaseUrl);
// await OpenIdConnectTestSuite(serverType, runtimeFlavor, architecture);
//}
private async Task OpenIdConnectTestSuite(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType, string applicationBaseUrl)
private async Task OpenIdConnectTestSuite(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType)
{
using (_logger.BeginScope("OpenIdConnectTestSuite"))
try
{
var musicStoreDbName = DbUtils.GetUniqueName();
var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
Console.WriteLine($"Starting OpenIdConnectTestSuite:{serverType}:{runtimeFlavor}:{architecture}:{applicationType}");
var logger = _loggerFactory.CreateLogger($"OpenIdConnectTestSuite:{serverType}:{runtimeFlavor}:{architecture}:{applicationType}");
using (logger.BeginScope("OpenIdConnectTestSuite"))
{
PublishApplicationBeforeDeployment = true,
PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging,
TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net451" : "netcoreapp1.1",
Configuration = Helpers.GetCurrentBuildConfiguration(),
ApplicationType = applicationType,
ApplicationBaseUriHint = applicationBaseUrl,
EnvironmentName = "OpenIdConnectTesting",
UserAdditionalCleanup = parameters =>
var musicStoreDbName = DbUtils.GetUniqueName();
var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
{
DbUtils.DropDatabase(musicStoreDbName, _logger);
PublishApplicationBeforeDeployment = true,
PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging,
TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net451" : "netcoreapp1.1",
Configuration = Helpers.GetCurrentBuildConfiguration(),
ApplicationType = applicationType,
EnvironmentName = "OpenIdConnectTesting",
UserAdditionalCleanup = parameters =>
{
DbUtils.DropDatabase(musicStoreDbName, logger);
}
};
if (applicationType == ApplicationType.Standalone)
{
deploymentParameters.AdditionalPublishParameters = " -r " + RuntimeEnvironment.GetRuntimeIdentifier();
}
};
if (applicationType == ApplicationType.Standalone)
{
deploymentParameters.AdditionalPublishParameters = " -r " + RuntimeEnvironment.GetRuntimeIdentifier();
}
// Override the connection strings using environment based configuration
deploymentParameters.EnvironmentVariables
.Add(new KeyValuePair<string, string>(
MusicStoreConfig.ConnectionStringKey,
DbUtils.CreateConnectionString(musicStoreDbName)));
// Override the connection strings using environment based configuration
deploymentParameters.EnvironmentVariables
.Add(new KeyValuePair<string, string>(
MusicStoreConfig.ConnectionStringKey,
DbUtils.CreateConnectionString(musicStoreDbName)));
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, _logger))
{
var deploymentResult = deployer.Deploy();
var httpClientHandler = new HttpClientHandler();
var httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) };
// Request to base address and check if various parts of the body are rendered & measure the cold startup time.
var response = await RetryHelper.RetryRequest(async () =>
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, _loggerFactory))
{
return await httpClient.GetAsync(string.Empty);
}, logger: _logger, cancellationToken: deploymentResult.HostShutdownToken);
var deploymentResult = await deployer.DeployAsync();
var httpClientHandler = new HttpClientHandler();
var httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) };
Assert.False(response == null, "Response object is null because the client could not " +
"connect to the server after multiple retries");
// Request to base address and check if various parts of the body are rendered & measure the cold startup time.
var response = await RetryHelper.RetryRequest(async () =>
{
return await httpClient.GetAsync(string.Empty);
}, logger: logger, cancellationToken: deploymentResult.HostShutdownToken);
var validator = new Validator(httpClient, httpClientHandler, _logger, deploymentResult);
Assert.False(response == null, "Response object is null because the client could not " +
"connect to the server after multiple retries");
Console.WriteLine("Verifying home page");
await validator.VerifyHomePage(response);
var validator = new Validator(httpClient, httpClientHandler, logger, deploymentResult);
Console.WriteLine("Verifying login by OpenIdConnect");
await validator.LoginWithOpenIdConnect();
Console.WriteLine("Verifying home page");
await validator.VerifyHomePage(response);
_logger.LogInformation("Variation completed successfully.");
Console.WriteLine("Verifying login by OpenIdConnect");
await validator.LoginWithOpenIdConnect();
logger.LogInformation("Variation completed successfully.");
}
}
}
finally
{
Console.WriteLine("Finished OpenIdConnectTestSuite");
}
}
public void Dispose()
{
_logger.Dispose();
_loggerFactory.Dispose();
}
}
}

View File

@ -1,9 +1,8 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;
using E2ETests.Common;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.DotNet.PlatformAbstractions;
@ -13,58 +12,56 @@ using Xunit.Abstractions;
namespace E2ETests
{
// Uses ports ranging 5025 - 5039.
public class PublishAndRunTests_OnX64 : IDisposable
{
private readonly XunitLogger _logger;
private readonly ILoggerFactory _loggerFactory;
public PublishAndRunTests_OnX64(ITestOutputHelper output)
{
_logger = new XunitLogger(output, LogLevel.Information);
_loggerFactory = new LoggerFactory()
.AddXunit(output);
}
[ConditionalTheory, Trait("E2Etests", "PublishAndRun")]
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
//[InlineData(ServerType.WebListener, RuntimeFlavor.Clr, RuntimeArchitecture.x64, ApplicationType.Portable, "http://localhost:5025/", false)]
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable, "http://localhost:5026/", false)]
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone, "http://localhost:5027/", false)]
// [InlineData(ServerType.Kestrel, RuntimeFlavor.Clr, RuntimeArchitecture.x64, ApplicationType.Portable, "http://localhost:5028/", false)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable, "http://localhost:5029/", false)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone, "http://localhost:5030/", false)]
//[InlineData(ServerType.WebListener, RuntimeFlavor.Clr, RuntimeArchitecture.x64, ApplicationType.Portable, false)]
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable, false)]
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone, false)]
// [InlineData(ServerType.Kestrel, RuntimeFlavor.Clr, RuntimeArchitecture.x64, ApplicationType.Portable, false)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable, false)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone, false)]
public async Task WindowsOS(
ServerType serverType,
RuntimeFlavor runtimeFlavor,
RuntimeArchitecture architecture,
ApplicationType applicationType,
string applicationBaseUrl,
bool noSource)
{
var testRunner = new PublishAndRunTests(_logger);
var testRunner = new PublishAndRunTests(_loggerFactory);
await testRunner.Publish_And_Run_Tests(
serverType, runtimeFlavor, architecture, applicationType, applicationBaseUrl, noSource);
serverType, runtimeFlavor, architecture, applicationType, noSource);
}
[ConditionalTheory, Trait("E2Etests", "PublishAndRun")]
[OSSkipCondition(OperatingSystems.Windows)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable, "http://localhost:5031/", false)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone, "http://localhost:5032/", false, Skip = "https://github.com/aspnet/MusicStore/issues/761")]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable, false)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone, false, Skip = "https://github.com/aspnet/MusicStore/issues/761")]
public async Task NonWindowsOS(
ServerType serverType,
RuntimeFlavor runtimeFlavor,
RuntimeArchitecture architecture,
ApplicationType applicationType,
string applicationBaseUrl,
bool noSource)
{
var testRunner = new PublishAndRunTests(_logger);
var testRunner = new PublishAndRunTests(_loggerFactory);
await testRunner.Publish_And_Run_Tests(
serverType, runtimeFlavor, architecture, applicationType, applicationBaseUrl, noSource);
serverType, runtimeFlavor, architecture, applicationType, noSource);
}
public void Dispose()
{
_logger.Dispose();
_loggerFactory.Dispose();
}
}
@ -72,64 +69,63 @@ namespace E2ETests
// public
class PublishAndRunTests_OnX86 : IDisposable
{
private readonly XunitLogger _logger;
private readonly ILoggerFactory _loggerFactory;
public PublishAndRunTests_OnX86(ITestOutputHelper output)
{
_logger = new XunitLogger(output, LogLevel.Information);
_loggerFactory = new LoggerFactory()
.AddXunit(output);
}
[ConditionalTheory, Trait("E2Etests", "PublishAndRun")]
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
[InlineData(ServerType.WebListener, RuntimeFlavor.Clr, RuntimeArchitecture.x86, ApplicationType.Portable, "http://localhost:5034/", false)]
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, ApplicationType.Portable, "http://localhost:5035/", false)]
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, ApplicationType.Standalone, "http://localhost:5036/", false)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.Clr, RuntimeArchitecture.x86, ApplicationType.Portable, "http://localhost:5037/", false)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, ApplicationType.Portable, "http://localhost:5038/", false)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, ApplicationType.Standalone, "http://localhost:5039/", false)]
[InlineData(ServerType.WebListener, RuntimeFlavor.Clr, RuntimeArchitecture.x86, ApplicationType.Portable, false)]
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, ApplicationType.Portable, false)]
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, ApplicationType.Standalone, false)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.Clr, RuntimeArchitecture.x86, ApplicationType.Portable, false)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, ApplicationType.Portable, false)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, ApplicationType.Standalone, false)]
public async Task WindowsOS(
ServerType serverType,
RuntimeFlavor runtimeFlavor,
RuntimeArchitecture architecture,
ApplicationType applicationType,
string applicationBaseUrl,
bool noSource)
{
var testRunner = new PublishAndRunTests(_logger);
var testRunner = new PublishAndRunTests(_loggerFactory);
await testRunner.Publish_And_Run_Tests(
serverType, runtimeFlavor, architecture, applicationType, applicationBaseUrl, noSource);
serverType, runtimeFlavor, architecture, applicationType, noSource);
}
[ConditionalTheory, Trait("E2Etests", "PublishAndRun")]
[OSSkipCondition(OperatingSystems.Windows)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.Clr, RuntimeArchitecture.x86, ApplicationType.Portable, "http://localhost:5040/", false)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.Clr, RuntimeArchitecture.x86, ApplicationType.Portable, false)]
public async Task NonWindowsOS(
ServerType serverType,
RuntimeFlavor runtimeFlavor,
RuntimeArchitecture architecture,
ApplicationType applicationType,
string applicationBaseUrl,
bool noSource)
{
var testRunner = new PublishAndRunTests(_logger);
var testRunner = new PublishAndRunTests(_loggerFactory);
await testRunner.Publish_And_Run_Tests(
serverType, runtimeFlavor, architecture, applicationType, applicationBaseUrl, noSource);
serverType, runtimeFlavor, architecture, applicationType, noSource);
}
public void Dispose()
{
_logger.Dispose();
_loggerFactory.Dispose();
}
}
public class PublishAndRunTests
{
private ILogger _logger;
private ILoggerFactory _loggerFactory;
public PublishAndRunTests(ILogger logger)
public PublishAndRunTests(ILoggerFactory loggerFactory)
{
_logger = logger;
_loggerFactory = loggerFactory;
}
public async Task Publish_And_Run_Tests(
@ -137,74 +133,82 @@ namespace E2ETests
RuntimeFlavor runtimeFlavor,
RuntimeArchitecture architecture,
ApplicationType applicationType,
string applicationBaseUrl,
bool noSource)
{
using (_logger.BeginScope("Publish_And_Run_Tests"))
var testName = $"PublishAndRunTests:{serverType}:{runtimeFlavor}:{architecture}:{applicationType}:NoSource={noSource}";
try
{
var musicStoreDbName = DbUtils.GetUniqueName();
var deploymentParameters = new DeploymentParameters(
Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
Console.WriteLine($"Starting {testName}");
var logger = _loggerFactory.CreateLogger(testName);
using (logger.BeginScope("Publish_And_Run_Tests"))
{
ApplicationBaseUriHint = applicationBaseUrl,
PublishApplicationBeforeDeployment = true,
PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging,
TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net451" : "netcoreapp1.1",
Configuration = Helpers.GetCurrentBuildConfiguration(),
ApplicationType = applicationType,
UserAdditionalCleanup = parameters =>
var musicStoreDbName = DbUtils.GetUniqueName();
var deploymentParameters = new DeploymentParameters(
Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
{
DbUtils.DropDatabase(musicStoreDbName, _logger);
}
};
if (applicationType == ApplicationType.Standalone)
{
deploymentParameters.AdditionalPublishParameters = "-r " + RuntimeEnvironment.GetRuntimeIdentifier();
}
// Override the connection strings using environment based configuration
deploymentParameters.EnvironmentVariables
.Add(new KeyValuePair<string, string>(
MusicStoreConfig.ConnectionStringKey,
DbUtils.CreateConnectionString(musicStoreDbName)));
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, _logger))
{
var deploymentResult = deployer.Deploy();
var httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true };
var httpClient = new HttpClient(httpClientHandler);
httpClient.BaseAddress = new Uri(deploymentResult.ApplicationBaseUri);
// Request to base address and check if various parts of the body are rendered &
// measure the cold startup time.
// Add retry logic since tests are flaky on mono due to connection issues
var response = await RetryHelper.RetryRequest(async () => await httpClient.GetAsync(string.Empty), logger: _logger, cancellationToken: deploymentResult.HostShutdownToken);
Assert.False(response == null, "Response object is null because the client could not " +
"connect to the server after multiple retries");
var validator = new Validator(httpClient, httpClientHandler, _logger, deploymentResult);
Console.WriteLine("Verifying home page");
await validator.VerifyHomePage(response);
Console.WriteLine("Verifying static files are served from static file middleware");
await validator.VerifyStaticContentServed();
if (serverType != ServerType.IISExpress)
{
if (Directory.GetFiles(
deploymentParameters.ApplicationPath, "*.cmd", SearchOption.TopDirectoryOnly).Length > 0)
PublishApplicationBeforeDeployment = true,
PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging,
TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net451" : "netcoreapp1.1",
Configuration = Helpers.GetCurrentBuildConfiguration(),
ApplicationType = applicationType,
UserAdditionalCleanup = parameters =>
{
throw new Exception("publishExclude parameter values are not honored.");
DbUtils.DropDatabase(musicStoreDbName, logger);
}
};
if (applicationType == ApplicationType.Standalone)
{
deploymentParameters.AdditionalPublishParameters = "-r " + RuntimeEnvironment.GetRuntimeIdentifier();
}
_logger.LogInformation("Variation completed successfully.");
// Override the connection strings using environment based configuration
deploymentParameters.EnvironmentVariables
.Add(new KeyValuePair<string, string>(
MusicStoreConfig.ConnectionStringKey,
DbUtils.CreateConnectionString(musicStoreDbName)));
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, _loggerFactory))
{
var deploymentResult = await deployer.DeployAsync();
var httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true };
var httpClient = new HttpClient(httpClientHandler);
httpClient.BaseAddress = new Uri(deploymentResult.ApplicationBaseUri);
// Request to base address and check if various parts of the body are rendered &
// measure the cold startup time.
// Add retry logic since tests are flaky on mono due to connection issues
var response = await RetryHelper.RetryRequest(async () => await httpClient.GetAsync(string.Empty), logger: logger, cancellationToken: deploymentResult.HostShutdownToken);
Assert.False(response == null, "Response object is null because the client could not " +
"connect to the server after multiple retries");
var validator = new Validator(httpClient, httpClientHandler, logger, deploymentResult);
Console.WriteLine("Verifying home page");
await validator.VerifyHomePage(response);
Console.WriteLine("Verifying static files are served from static file middleware");
await validator.VerifyStaticContentServed();
if (serverType != ServerType.IISExpress)
{
if (Directory.GetFiles(
deploymentParameters.ApplicationPath, "*.cmd", SearchOption.TopDirectoryOnly).Length > 0)
{
throw new Exception("publishExclude parameter values are not honored.");
}
}
logger.LogInformation("Variation completed successfully.");
}
}
}
finally
{
Console.WriteLine($"Finished {testName}");
}
}
}
}

View File

@ -1,8 +1,7 @@
using System;
using System.IO;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using E2ETests.Common;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.DotNet.PlatformAbstractions;
@ -14,118 +13,116 @@ namespace E2ETests
{
// Uses ports ranging 5001 - 5025.
// TODO: temporarily disabling these tests as dotnet xunit runner does not support 32-bit yet.
// public
class SmokeTests_X86 : IDisposable
internal class SmokeTests_X86 : IDisposable
{
private readonly XunitLogger _logger;
private readonly ILoggerFactory _loggerFactory;
public SmokeTests_X86(ITestOutputHelper output)
{
_logger = new XunitLogger(output, LogLevel.Information);
_loggerFactory = new LoggerFactory()
.AddXunit(output);
}
[ConditionalTheory, Trait("E2Etests", "Smoke")]
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
[InlineData(ServerType.WebListener, RuntimeFlavor.Clr, RuntimeArchitecture.x86, ApplicationType.Portable, "http://localhost:5001/")]
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, ApplicationType.Portable, "http://localhost:5002/")]
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, ApplicationType.Standalone, "http://localhost:5003/")]
[InlineData(ServerType.Kestrel, RuntimeFlavor.Clr, RuntimeArchitecture.x86, ApplicationType.Portable, "http://localhost:5004/")]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, ApplicationType.Portable, "http://localhost:5005/")]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, ApplicationType.Standalone, "http://localhost:5006/")]
[InlineData(ServerType.IISExpress, RuntimeFlavor.Clr, RuntimeArchitecture.x86, ApplicationType.Portable, "http://localhost:5007/")]
[InlineData(ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, ApplicationType.Portable, "http://localhost:5008/")]
[InlineData(ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, ApplicationType.Standalone, "http://localhost:5009/")]
[InlineData(ServerType.WebListener, RuntimeFlavor.Clr, RuntimeArchitecture.x86, ApplicationType.Portable)]
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, ApplicationType.Portable)]
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, ApplicationType.Standalone)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.Clr, RuntimeArchitecture.x86, ApplicationType.Portable)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, ApplicationType.Portable)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, ApplicationType.Standalone)]
[InlineData(ServerType.IISExpress, RuntimeFlavor.Clr, RuntimeArchitecture.x86, ApplicationType.Portable)]
[InlineData(ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, ApplicationType.Portable)]
[InlineData(ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x86, ApplicationType.Standalone)]
public async Task WindowsOS(
ServerType serverType,
RuntimeFlavor runtimeFlavor,
RuntimeArchitecture architecture,
ApplicationType applicationType,
string applicationBaseUrl)
ApplicationType applicationType)
{
var smokeTestRunner = new SmokeTests(_logger);
await smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationType, applicationBaseUrl);
var smokeTestRunner = new SmokeTests(_loggerFactory);
await smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationType);
}
[ConditionalTheory(Skip = "Temporarily disabling test"), Trait("E2Etests", "Smoke")]
[OSSkipCondition(OperatingSystems.Windows)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.Clr, RuntimeArchitecture.x86, ApplicationType.Portable, "http://localhost:5010/")]
[InlineData(ServerType.Kestrel, RuntimeFlavor.Clr, RuntimeArchitecture.x86, ApplicationType.Portable)]
public async Task NonWindowsOS(
ServerType serverType,
RuntimeFlavor runtimeFlavor,
RuntimeArchitecture architecture,
ApplicationType applicationType,
string applicationBaseUrl)
ApplicationType applicationType)
{
var smokeTestRunner = new SmokeTests(_logger);
await smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationType, applicationBaseUrl);
var smokeTestRunner = new SmokeTests(_loggerFactory);
await smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationType);
}
public void Dispose()
{
_logger.Dispose();
_loggerFactory.Dispose();
}
}
public class SmokeTests_X64 : IDisposable
{
private readonly XunitLogger _logger;
private readonly ILoggerFactory _loggerFactory;
public SmokeTests_X64(ITestOutputHelper output)
{
_logger = new XunitLogger(output, LogLevel.Information);
_loggerFactory = new LoggerFactory()
.AddXunit(output);
}
[ConditionalTheory, Trait("E2Etests", "Smoke")]
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
[InlineData(ServerType.WebListener, RuntimeFlavor.Clr, RuntimeArchitecture.x64, ApplicationType.Portable, "http://localhost:5011/")]
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable, "http://localhost:5012/")]
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone, "http://localhost:5013/")]
[InlineData(ServerType.Kestrel, RuntimeFlavor.Clr, RuntimeArchitecture.x64, ApplicationType.Portable, "http://localhost:5014/")]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable, "http://localhost:5015/")]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone, "http://localhost:5016/")]
[InlineData(ServerType.IISExpress, RuntimeFlavor.Clr, RuntimeArchitecture.x64, ApplicationType.Portable, "http://localhost:5017/")]
[InlineData(ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable, "http://localhost:5018/")]
[InlineData(ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone, "http://localhost:5019/")]
[InlineData(ServerType.WebListener, RuntimeFlavor.Clr, RuntimeArchitecture.x64, ApplicationType.Portable)]
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable)]
[InlineData(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.Clr, RuntimeArchitecture.x64, ApplicationType.Portable)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone)]
[InlineData(ServerType.IISExpress, RuntimeFlavor.Clr, RuntimeArchitecture.x64, ApplicationType.Portable)]
[InlineData(ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable)]
[InlineData(ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone)]
public async Task WindowsOS(
ServerType serverType,
RuntimeFlavor runtimeFlavor,
RuntimeArchitecture architecture,
ApplicationType applicationType,
string applicationBaseUrl)
ApplicationType applicationType)
{
var smokeTestRunner = new SmokeTests(_logger);
await smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationType, applicationBaseUrl);
var smokeTestRunner = new SmokeTests(_loggerFactory);
await smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationType);
}
[ConditionalTheory, Trait("E2Etests", "Smoke")]
[OSSkipCondition(OperatingSystems.Windows)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable, "http://localhost:5020/")]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone, "http://localhost:5021/", Skip = "https://github.com/aspnet/MusicStore/issues/761")]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable)]
[InlineData(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone, Skip = "https://github.com/aspnet/MusicStore/issues/761")]
public async Task NonWindowsOS(
ServerType serverType,
RuntimeFlavor runtimeFlavor,
RuntimeArchitecture architecture,
ApplicationType applicationType,
string applicationBaseUrl)
ApplicationType applicationType)
{
var smokeTestRunner = new SmokeTests(_logger);
await smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationType, applicationBaseUrl);
var smokeTestRunner = new SmokeTests(_loggerFactory);
await smokeTestRunner.SmokeTestSuite(serverType, runtimeFlavor, architecture, applicationType);
}
public void Dispose()
{
_logger.Dispose();
_loggerFactory.Dispose();
}
}
class SmokeTests_OnIIS : IDisposable
{
private readonly XunitLogger _logger;
private readonly ILoggerFactory _loggerFactory;
public SmokeTests_OnIIS(ITestOutputHelper output)
{
_logger = new XunitLogger(output, LogLevel.Information);
_loggerFactory = new LoggerFactory()
.AddXunit(output);
}
[ConditionalTheory, Trait("E2Etests", "Smoke")]
@ -133,34 +130,33 @@ namespace E2ETests
[OSSkipCondition(OperatingSystems.Linux)]
[FrameworkSkipCondition(RuntimeFrameworks.CoreCLR)]
[SkipIfEnvironmentVariableNotEnabled("IIS_VARIATIONS_ENABLED")]
//[InlineData(ServerType.IIS, RuntimeFlavor.Clr, RuntimeArchitecture.x86, ApplicationType.Portable, "http://localhost:5022/")]
[InlineData(ServerType.IIS, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable, "http://localhost:5023/")]
[InlineData(ServerType.IIS, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone, "http://localhost:5024/")]
//[InlineData(ServerType.IIS, RuntimeFlavor.Clr, RuntimeArchitecture.x86, ApplicationType.Portable)]
[InlineData(ServerType.IIS, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable)]
[InlineData(ServerType.IIS, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone)]
public async Task SmokeTestSuite_On_IIS_X86(
ServerType serverType,
RuntimeFlavor runtimeFlavor,
RuntimeArchitecture architecture,
ApplicationType applicationType,
string applicationBaseUrl)
ApplicationType applicationType)
{
var smokeTestRunner = new SmokeTests(_logger);
var smokeTestRunner = new SmokeTests(_loggerFactory);
await smokeTestRunner.SmokeTestSuite(
serverType, runtimeFlavor, architecture, applicationType, applicationBaseUrl, noSource: true);
serverType, runtimeFlavor, architecture, applicationType, noSource: true);
}
public void Dispose()
{
_logger.Dispose();
_loggerFactory.Dispose();
}
}
public class SmokeTests
{
private ILogger _logger;
private ILoggerFactory _loggerFactory;
public SmokeTests(ILogger logger)
public SmokeTests(ILoggerFactory loggerFactory)
{
_logger = logger;
_loggerFactory = loggerFactory;
}
public async Task SmokeTestSuite(
@ -168,51 +164,59 @@ namespace E2ETests
RuntimeFlavor runtimeFlavor,
RuntimeArchitecture architecture,
ApplicationType applicationType,
string applicationBaseUrl,
bool noSource = false)
{
using (_logger.BeginScope("SmokeTestSuite"))
var testName = $"SmokeTestSuite:{serverType}:{runtimeFlavor}:{architecture}:{applicationType}";
try
{
var musicStoreDbName = DbUtils.GetUniqueName();
var deploymentParameters = new DeploymentParameters(
Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
Console.WriteLine($"Starting {testName}");
var logger = _loggerFactory.CreateLogger(testName);
using (logger.BeginScope("SmokeTestSuite"))
{
ApplicationBaseUriHint = applicationBaseUrl,
EnvironmentName = "SocialTesting",
ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("Http.config") : null,
SiteName = "MusicStoreTestSite",
PublishApplicationBeforeDeployment = true,
PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging,
TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net46" : "netcoreapp1.1",
Configuration = Helpers.GetCurrentBuildConfiguration(),
ApplicationType = applicationType,
UserAdditionalCleanup = parameters =>
var musicStoreDbName = DbUtils.GetUniqueName();
var deploymentParameters = new DeploymentParameters(
Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
{
DbUtils.DropDatabase(musicStoreDbName, _logger);
EnvironmentName = "SocialTesting",
ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("Http.config") : null,
SiteName = "MusicStoreTestSite",
PublishApplicationBeforeDeployment = true,
PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging,
TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net46" : "netcoreapp1.1",
Configuration = Helpers.GetCurrentBuildConfiguration(),
ApplicationType = applicationType,
UserAdditionalCleanup = parameters =>
{
DbUtils.DropDatabase(musicStoreDbName, logger);
}
};
if (applicationType == ApplicationType.Standalone)
{
deploymentParameters.AdditionalPublishParameters = " -r " + RuntimeEnvironment.GetRuntimeIdentifier();
}
};
if (applicationType == ApplicationType.Standalone)
{
deploymentParameters.AdditionalPublishParameters = " -r " + RuntimeEnvironment.GetRuntimeIdentifier();
}
// Override the connection strings using environment based configuration
deploymentParameters.EnvironmentVariables
.Add(new KeyValuePair<string, string>(
MusicStoreConfig.ConnectionStringKey,
DbUtils.CreateConnectionString(musicStoreDbName)));
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, _logger))
{
var deploymentResult = deployer.Deploy();
Helpers.SetInMemoryStoreForIIS(deploymentParameters, _logger);
await SmokeTestHelper.RunTestsAsync(deploymentResult, _logger);
// Override the connection strings using environment based configuration
deploymentParameters.EnvironmentVariables
.Add(new KeyValuePair<string, string>(
MusicStoreConfig.ConnectionStringKey,
DbUtils.CreateConnectionString(musicStoreDbName)));
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, _loggerFactory))
{
var deploymentResult = await deployer.DeployAsync();
Helpers.SetInMemoryStoreForIIS(deploymentParameters, logger);
await SmokeTestHelper.RunTestsAsync(deploymentResult, logger);
}
}
}
finally
{
Console.WriteLine($"Finished {testName}");
}
}
}
}

View File

@ -1,9 +1,8 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Threading.Tasks;
using E2ETests.Common;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.Configuration;
@ -18,14 +17,15 @@ namespace E2ETests
public class SmokeTestsOnNanoServerUsingStandaloneRuntime : IDisposable
{
private readonly SmokeTestsOnNanoServer _smokeTestsOnNanoServer;
private readonly XunitLogger _logger;
private readonly ILoggerFactory _loggerFactory;
private readonly RemoteDeploymentConfig _remoteDeploymentConfig;
public SmokeTestsOnNanoServerUsingStandaloneRuntime(ITestOutputHelper output)
{
_logger = new XunitLogger(output, LogLevel.Information);
_loggerFactory = new LoggerFactory()
.AddXunit(output);
_remoteDeploymentConfig = RemoteDeploymentConfigHelper.GetConfiguration();
_smokeTestsOnNanoServer = new SmokeTestsOnNanoServer(output, _remoteDeploymentConfig, _logger);
_smokeTestsOnNanoServer = new SmokeTestsOnNanoServer(output, _remoteDeploymentConfig, _loggerFactory);
}
[ConditionalTheory, Trait("E2ETests", "NanoServer")]
@ -43,7 +43,7 @@ namespace E2ETests
public void Dispose()
{
_logger.Dispose();
_loggerFactory.Dispose();
}
}
@ -56,15 +56,16 @@ namespace E2ETests
{
private readonly SmokeTestsOnNanoServer _smokeTestsOnNanoServer;
private readonly RemoteDeploymentConfig _remoteDeploymentConfig;
private readonly XunitLogger _logger;
private readonly ILoggerFactory _loggerFactory;
public SmokeTestsOnNanoServerUsingSharedRuntime(
DotnetRuntimeSetupTestFixture dotnetRuntimeSetupTestFixture, ITestOutputHelper output)
{
_logger = new XunitLogger(output, LogLevel.Information);
_loggerFactory = new LoggerFactory()
.AddXunit(output);
_remoteDeploymentConfig = RemoteDeploymentConfigHelper.GetConfiguration();
_remoteDeploymentConfig.DotnetRuntimePathOnShare = dotnetRuntimeSetupTestFixture.DotnetRuntimePathOnShare;
_smokeTestsOnNanoServer = new SmokeTestsOnNanoServer(output, _remoteDeploymentConfig, _logger);
_smokeTestsOnNanoServer = new SmokeTestsOnNanoServer(output, _remoteDeploymentConfig, _loggerFactory);
}
[ConditionalTheory, Trait("E2Etests", "NanoServer")]
@ -82,7 +83,7 @@ namespace E2ETests
public void Dispose()
{
_logger.Dispose();
_loggerFactory.Dispose();
}
// Copies dotnet runtime to the target server's file share.
@ -234,12 +235,12 @@ namespace E2ETests
class SmokeTestsOnNanoServer
{
private readonly XunitLogger _logger;
private readonly ILoggerFactory _loggerFactory;
private readonly RemoteDeploymentConfig _remoteDeploymentConfig;
public SmokeTestsOnNanoServer(ITestOutputHelper output, RemoteDeploymentConfig config, XunitLogger logger)
public SmokeTestsOnNanoServer(ITestOutputHelper output, RemoteDeploymentConfig config, ILoggerFactory loggerFactory)
{
_logger = logger;
_loggerFactory = loggerFactory;
_remoteDeploymentConfig = config;
}
@ -248,42 +249,52 @@ namespace E2ETests
string applicationBaseUrl,
ApplicationType applicationType)
{
using (_logger.BeginScope(nameof(SmokeTestsOnNanoServerUsingStandaloneRuntime)))
var testName = $"SmokeTestsOnNanoServer:{serverType}:{applicationType}";
try
{
var deploymentParameters = new RemoteWindowsDeploymentParameters(
Helpers.GetApplicationPath(applicationType),
_remoteDeploymentConfig.DotnetRuntimePathOnShare,
serverType,
RuntimeFlavor.CoreClr,
RuntimeArchitecture.x64,
_remoteDeploymentConfig.FileSharePath,
_remoteDeploymentConfig.ServerName,
_remoteDeploymentConfig.AccountName,
_remoteDeploymentConfig.AccountPassword)
Console.WriteLine($"Started {testName}");
var logger = _loggerFactory.CreateLogger(testName);
using (logger.BeginScope(nameof(SmokeTestsOnNanoServerUsingStandaloneRuntime)))
{
TargetFramework = "netcoreapp1.1",
ApplicationBaseUriHint = applicationBaseUrl,
ApplicationType = applicationType
};
var deploymentParameters = new RemoteWindowsDeploymentParameters(
Helpers.GetApplicationPath(applicationType),
_remoteDeploymentConfig.DotnetRuntimePathOnShare,
serverType,
RuntimeFlavor.CoreClr,
RuntimeArchitecture.x64,
_remoteDeploymentConfig.FileSharePath,
_remoteDeploymentConfig.ServerName,
_remoteDeploymentConfig.AccountName,
_remoteDeploymentConfig.AccountPassword)
{
TargetFramework = "netcoreapp1.1",
ApplicationBaseUriHint = applicationBaseUrl,
ApplicationType = applicationType
};
if (applicationType == ApplicationType.Standalone)
{
// Unable to use the RuntimeEnvironment.GetRuntimeIdentifier API here as NanoServer which is
// part of Windows Server 2016 has a RID of 'win10-x64' where as the CI servers currently
// run on Windows Server 2012 or less, which have different RIDs.
deploymentParameters.AdditionalPublishParameters = "-r win10-x64";
}
deploymentParameters.EnvironmentVariables.Add(
new KeyValuePair<string, string>("ASPNETCORE_ENVIRONMENT", "SocialTesting"));
using (var deployer = new RemoteWindowsDeployer(deploymentParameters, _logger))
{
var deploymentResult = deployer.Deploy();
await SmokeTestHelper.RunTestsAsync(deploymentResult, _logger);
if (applicationType == ApplicationType.Standalone)
{
// Unable to use the RuntimeEnvironment.GetRuntimeIdentifier API here as NanoServer which is
// part of Windows Server 2016 has a RID of 'win10-x64' where as the CI servers currently
// run on Windows Server 2012 or less, which have different RIDs.
deploymentParameters.AdditionalPublishParameters = "-r win10-x64";
}
deploymentParameters.EnvironmentVariables.Add(
new KeyValuePair<string, string>("ASPNETCORE_ENVIRONMENT", "SocialTesting"));
using (var deployer = new RemoteWindowsDeployer(deploymentParameters, logger))
{
var deploymentResult = await deployer.DeployAsync();
await SmokeTestHelper.RunTestsAsync(deploymentResult, logger);
}
}
}
finally
{
Console.WriteLine($"Finished {testName}");
}
}
}