Re-enable desktop tests

* Cleanup tests to use a test case per scenario
* Run tests on CLR
* Enable view precompilaton for the sample.
This commit is contained in:
Pranav K 2017-06-14 18:06:05 -07:00
parent 71ce7df465
commit 5bcba9677e
11 changed files with 288 additions and 345 deletions

View File

@ -5,6 +5,7 @@
<AspNetCoreModuleVersion>1.0.0-*</AspNetCoreModuleVersion> <AspNetCoreModuleVersion>1.0.0-*</AspNetCoreModuleVersion>
<CoreFxVersion>4.4.0-*</CoreFxVersion> <CoreFxVersion>4.4.0-*</CoreFxVersion>
<NETStandardImplicitPackageVersion>2.0.0-*</NETStandardImplicitPackageVersion> <NETStandardImplicitPackageVersion>2.0.0-*</NETStandardImplicitPackageVersion>
<NETStandardLibraryNETFrameworkVersion>2.0.0-*</NETStandardLibraryNETFrameworkVersion>
<NuGetPackagesVersion>4.0.0</NuGetPackagesVersion> <NuGetPackagesVersion>4.0.0</NuGetPackagesVersion>
<RuntimeFrameworkVersion Condition="'$(TargetFramework)'=='netcoreapp2.0'">2.0.0-*</RuntimeFrameworkVersion> <RuntimeFrameworkVersion Condition="'$(TargetFramework)'=='netcoreapp2.0'">2.0.0-*</RuntimeFrameworkVersion>
<TestSdkVersion>15.3.0-*</TestSdkVersion> <TestSdkVersion>15.3.0-*</TestSdkVersion>

View File

@ -4,8 +4,9 @@
<PropertyGroup> <PropertyGroup>
<Description>Music store application on ASP.NET Core</Description> <Description>Music store application on ASP.NET Core</Description>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
<DefineConstants>$(DefineConstants);DEMO</DefineConstants> <DefineConstants>$(DefineConstants);DEMO</DefineConstants>
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<RuntimeIdentifiers Condition="'$(MUSICSTORE_ASPNETCORE_STORE_FEED)' == ''">win7-x86;win7-x64;linux-x64;osx-x64</RuntimeIdentifiers> <RuntimeIdentifiers Condition="'$(MUSICSTORE_ASPNETCORE_STORE_FEED)' == ''">win7-x86;win7-x64;linux-x64;osx-x64</RuntimeIdentifiers>
</PropertyGroup> </PropertyGroup>
@ -15,7 +16,32 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.AspNetCoreModule" Version="$(AspNetCoreModuleVersion)" /> <PackageReference Include="Microsoft.AspNetCore.AspNetCoreModule" Version="$(AspNetCoreModuleVersion)" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)'=='.NETCoreApp'">
<PackageReference Include="Microsoft.AspNetCore.All" Version="$(AspNetCoreVersion)" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)'=='.NETFramework'">
<PackageReference Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.AspNetCoreModule" Version="$(AspNetCoreModuleVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Twitter" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.AspNetCore.Server.HttpSys" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Session" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="$(AspNetCoreVersion)" />
<PackageReference Include="NETStandard.Library.NETFramework" Version="$(NETStandardLibraryNETFrameworkVersion)" />
</ItemGroup>
</Project> </Project>

View File

@ -1,8 +1,7 @@
using System; using System;
using System.IO; using System.IO;
using System.Linq;
using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.Extensions.Logging; using Microsoft.AspNetCore.Testing;
namespace E2ETests namespace E2ETests
{ {
@ -10,53 +9,17 @@ namespace E2ETests
{ {
public static string GetApplicationPath(ApplicationType applicationType) public static string GetApplicationPath(ApplicationType applicationType)
{ {
var current = new DirectoryInfo(AppContext.BaseDirectory); var solutionDirectory = TestPathUtilities.GetSolutionRootDirectory("MusicStore");
while (current != null) return Path.GetFullPath(Path.Combine(solutionDirectory, "samples", "MusicStore"));
{
if (File.Exists(Path.Combine(current.FullName, "MusicStore.sln")))
{
break;
}
current = current.Parent;
}
if (current == null)
{
throw new InvalidOperationException("Could not find the solution directory");
}
return Path.GetFullPath(Path.Combine(current.FullName, "samples", "MusicStore"));
}
public static void SetInMemoryStoreForIIS(DeploymentParameters deploymentParameters, ILogger logger)
{
if (deploymentParameters.ServerType == ServerType.IIS)
{
// Can't use localdb with IIS. Setting an override to use InMemoryStore.
logger.LogInformation("Creating configoverride.json file to override default config.");
var compileRoot = Path.GetFullPath(
Path.Combine(
deploymentParameters.ApplicationPath,
"..", "approot", "packages", "MusicStore"));
// We don't know the exact version number with which sources are built.
string overrideConfig = Path.Combine(Directory.GetDirectories(compileRoot).First(), "root", "configoverride.json");
File.WriteAllText(overrideConfig, "{\"UseInMemoryDatabase\": \"true\"}");
}
} }
public static string GetCurrentBuildConfiguration() public static string GetCurrentBuildConfiguration()
{ {
var configuration = "Debug"; #if DEBUG
if (string.Equals(Environment.GetEnvironmentVariable("Configuration"), "Release", StringComparison.OrdinalIgnoreCase)) return "Debug";
{ #else
configuration = "Release"; return "Release";
} #endif
return configuration;
} }
public static bool PreservePublishedApplicationForDebugging public static bool PreservePublishedApplicationForDebugging

View File

@ -12,32 +12,65 @@ using Xunit.Abstractions;
namespace E2ETests namespace E2ETests
{ {
[Trait("E2Etests", "E2Etests")]
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
public class NtlmAuthenticationTests : LoggedTest public class NtlmAuthenticationTests : LoggedTest
{ {
public NtlmAuthenticationTests(ITestOutputHelper output) : base(output) public NtlmAuthenticationTests(ITestOutputHelper output) : base(output)
{ {
} }
[ConditionalTheory, Trait("E2Etests", "E2Etests")] [ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux)] public Task NtlmAuthenticationTest_WebListener_CoreCLR_Portable()
[OSSkipCondition(OperatingSystems.MacOSX)]
[InlineData(ServerType.WebListener, RuntimeArchitecture.x64, ApplicationType.Portable)]
[InlineData(ServerType.WebListener, RuntimeArchitecture.x64, ApplicationType.Standalone)]
[InlineData(ServerType.IISExpress, RuntimeArchitecture.x64, ApplicationType.Portable)]
[InlineData(ServerType.IISExpress, RuntimeArchitecture.x64, ApplicationType.Standalone)]
public async Task NtlmAuthenticationTest(ServerType serverType, RuntimeArchitecture architecture, ApplicationType applicationType)
{ {
var testName = $"NtlmAuthentication_{serverType}_{architecture}_{applicationType}"; return NtlmAuthenticationTest(ServerType.WebListener, RuntimeFlavor.CoreClr, ApplicationType.Portable);
}
[ConditionalFact]
public Task NtlmAuthenticationTest_WebListener_CoreCLR_Standalone()
{
return NtlmAuthenticationTest(ServerType.WebListener, RuntimeFlavor.CoreClr, ApplicationType.Standalone);
}
[ConditionalFact]
public Task NtlmAuthenticationTest_IISExpress_CoreCLR_Portable()
{
return NtlmAuthenticationTest(ServerType.IISExpress, RuntimeFlavor.CoreClr, ApplicationType.Portable);
}
[ConditionalFact]
public Task NtlmAuthenticationTest_IISExpress_CoreCLR_Standalone()
{
return NtlmAuthenticationTest(ServerType.IISExpress, RuntimeFlavor.CoreClr, ApplicationType.Standalone);
}
[ConditionalFact]
public Task NtlmAuthenticationTest_WebListener_CLR()
{
return NtlmAuthenticationTest(ServerType.WebListener, RuntimeFlavor.Clr, ApplicationType.Portable);
}
[ConditionalFact]
public Task NtlmAuthenticationTest_IISExpress_CLR()
{
return NtlmAuthenticationTest(ServerType.IISExpress, RuntimeFlavor.Clr, ApplicationType.Standalone);
}
private async Task NtlmAuthenticationTest(ServerType serverType, RuntimeFlavor runtimeFlavor, ApplicationType applicationType)
{
var architecture = RuntimeArchitecture.x64;
var testName = $"NtlmAuthentication_{serverType}_{runtimeFlavor}_{applicationType}";
using (StartLog(out var loggerFactory, testName)) using (StartLog(out var loggerFactory, testName))
{ {
var logger = loggerFactory.CreateLogger("NtlmAuthenticationTest"); var logger = loggerFactory.CreateLogger("NtlmAuthenticationTest");
var musicStoreDbName = DbUtils.GetUniqueName(); var musicStoreDbName = DbUtils.GetUniqueName();
var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, RuntimeFlavor.CoreClr, architecture) var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
{ {
PublishApplicationBeforeDeployment = true, PublishApplicationBeforeDeployment = true,
PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging, PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging,
TargetFramework = "netcoreapp2.0", TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net461" : "netcoreapp2.0",
Configuration = Helpers.GetCurrentBuildConfiguration(), Configuration = Helpers.GetCurrentBuildConfiguration(),
ApplicationType = applicationType, ApplicationType = applicationType,
EnvironmentName = "NtlmAuthentication", //Will pick the Start class named 'StartupNtlmAuthentication' EnvironmentName = "NtlmAuthentication", //Will pick the Start class named 'StartupNtlmAuthentication'

View File

@ -10,47 +10,47 @@ using Xunit.Abstractions;
namespace E2ETests namespace E2ETests
{ {
[Trait("E2Etests", "E2Etests")]
public class OpenIdConnectTests : LoggedTest public class OpenIdConnectTests : LoggedTest
{ {
public OpenIdConnectTests(ITestOutputHelper output) : base(output) public OpenIdConnectTests(ITestOutputHelper output) : base(output)
{ {
} }
[ConditionalTheory, Trait("E2Etests", "E2Etests")] [Fact]
public Task OpenIdConnect_Kestrel_CoreCLR_Portable()
{
return OpenIdConnectTestSuite(ServerType.Kestrel, RuntimeFlavor.CoreClr, ApplicationType.Portable);
}
[Fact]
public Task OpenIdConnect_Kestrel_CoreCLR_Standalone()
{
return OpenIdConnectTestSuite(ServerType.Kestrel, RuntimeFlavor.CoreClr, ApplicationType.Standalone);
}
[ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux)] [OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)] [OSSkipCondition(OperatingSystems.MacOSX)]
[InlineData(ServerType.Kestrel, RuntimeArchitecture.x64, ApplicationType.Portable)] public Task OpenIdConnect_Kestrel_CLR()
[InlineData(ServerType.Kestrel, RuntimeArchitecture.x64, ApplicationType.Standalone)]
public async Task OpenIdConnect_OnWindowsOS(
ServerType serverType,
RuntimeArchitecture architecture,
ApplicationType applicationType)
{ {
await OpenIdConnectTestSuite(serverType, architecture, applicationType); return OpenIdConnectTestSuite(ServerType.Kestrel, RuntimeFlavor.Clr, ApplicationType.Portable);
} }
[ConditionalTheory, Trait("E2Etests", "E2Etests")] private async Task OpenIdConnectTestSuite(ServerType serverType, RuntimeFlavor runtimeFlavor, ApplicationType applicationType)
[OSSkipCondition(OperatingSystems.Windows)]
[InlineData(ServerType.Kestrel, RuntimeArchitecture.x64, ApplicationType.Portable)]
[InlineData(ServerType.Kestrel, RuntimeArchitecture.x64, ApplicationType.Standalone)]
public async Task OpenIdConnect_OnNonWindows(ServerType serverType, RuntimeArchitecture architecture, ApplicationType applicationType)
{ {
await OpenIdConnectTestSuite(serverType, architecture, applicationType); var architecture = RuntimeArchitecture.x64;
} var testName = $"OpenIdConnectTestSuite_{serverType}_{runtimeFlavor}_{architecture}_{applicationType}";
private async Task OpenIdConnectTestSuite(ServerType serverType, RuntimeArchitecture architecture, ApplicationType applicationType)
{
var testName = $"OpenIdConnectTestSuite_{serverType}_{architecture}_{applicationType}";
using (StartLog(out var loggerFactory, testName)) using (StartLog(out var loggerFactory, testName))
{ {
var logger = loggerFactory.CreateLogger("OpenIdConnectTestSuite"); var logger = loggerFactory.CreateLogger("OpenIdConnectTestSuite");
var musicStoreDbName = DbUtils.GetUniqueName(); var musicStoreDbName = DbUtils.GetUniqueName();
var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, RuntimeFlavor.CoreClr, architecture) var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
{ {
PublishApplicationBeforeDeployment = true, PublishApplicationBeforeDeployment = true,
PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging, PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging,
TargetFramework = "netcoreapp2.0", TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net461" : "netcoreapp2.0",
Configuration = Helpers.GetCurrentBuildConfiguration(), Configuration = Helpers.GetCurrentBuildConfiguration(),
ApplicationType = applicationType, ApplicationType = applicationType,
EnvironmentName = "OpenIdConnectTesting", EnvironmentName = "OpenIdConnectTesting",

View File

@ -12,119 +12,74 @@ using Xunit.Abstractions;
namespace E2ETests namespace E2ETests
{ {
public class PublishAndRunTests_OnX64 [Trait("E2Etests", "PublishAndRun")]
public class PublishAndRunTests_X64 : LoggedTest
{ {
private readonly ITestOutputHelper _output; public PublishAndRunTests_X64(ITestOutputHelper output) : base(output)
public PublishAndRunTests_OnX64(ITestOutputHelper output)
{ {
_output = output;
} }
[ConditionalTheory, Trait("E2Etests", "PublishAndRun")] [ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux)] [OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)] [OSSkipCondition(OperatingSystems.MacOSX)]
[InlineData(ServerType.WebListener, RuntimeArchitecture.x64, ApplicationType.Portable, false)] public Task PublishAndRunTests_X64_WebListener_CoreCLR_Portable()
[InlineData(ServerType.WebListener, RuntimeArchitecture.x64, ApplicationType.Standalone, false)]
[InlineData(ServerType.Kestrel, RuntimeArchitecture.x64, ApplicationType.Portable, false)]
[InlineData(ServerType.Kestrel, RuntimeArchitecture.x64, ApplicationType.Standalone, false)]
public async Task WindowsOS(
ServerType serverType,
RuntimeArchitecture architecture,
ApplicationType applicationType,
bool noSource)
{ {
var testRunner = new PublishAndRunTests(_output); return RunTests(ServerType.WebListener, RuntimeFlavor.CoreClr, ApplicationType.Portable);
await testRunner.Publish_And_Run_Tests(
serverType, architecture, applicationType, noSource);
} }
[ConditionalTheory, Trait("E2Etests", "PublishAndRun")] [ConditionalFact]
[OSSkipCondition(OperatingSystems.Windows)]
[InlineData(ServerType.Kestrel, RuntimeArchitecture.x64, ApplicationType.Portable, false)]
[InlineData(ServerType.Kestrel, RuntimeArchitecture.x64, ApplicationType.Standalone, false)]
public async Task NonWindowsOS(
ServerType serverType,
RuntimeArchitecture architecture,
ApplicationType applicationType,
bool noSource)
{
var testRunner = new PublishAndRunTests(_output);
await testRunner.Publish_And_Run_Tests(
serverType, architecture, applicationType, noSource);
}
}
public class PublishAndRunTests_OnX86
{
private const string SkipReason = "temporarily disabling x86 tests as dotnet xunit test runner currently does not support 32-bit";
private readonly ITestOutputHelper _output;
public PublishAndRunTests_OnX86(ITestOutputHelper output)
{
_output = output;
}
[ConditionalTheory(Skip = SkipReason)]
[Trait("E2Etests", "PublishAndRun")]
[OSSkipCondition(OperatingSystems.Linux)] [OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)] [OSSkipCondition(OperatingSystems.MacOSX)]
[InlineData(ServerType.WebListener, RuntimeArchitecture.x86, ApplicationType.Portable, false)] public Task PublishAndRunTests_X64_WebListener_CoreCLR_Standalone()
[InlineData(ServerType.WebListener, RuntimeArchitecture.x86, ApplicationType.Standalone, false)]
[InlineData(ServerType.Kestrel, RuntimeArchitecture.x86, ApplicationType.Portable, false)]
[InlineData(ServerType.Kestrel, RuntimeArchitecture.x86, ApplicationType.Standalone, false)]
public async Task WindowsOS(
ServerType serverType,
RuntimeArchitecture architecture,
ApplicationType applicationType,
bool noSource)
{ {
var testRunner = new PublishAndRunTests(_output); return RunTests(ServerType.WebListener, RuntimeFlavor.CoreClr, ApplicationType.Standalone);
await testRunner.Publish_And_Run_Tests(
serverType, architecture, applicationType, noSource);
} }
[ConditionalTheory(Skip = SkipReason)] [ConditionalFact]
[Trait("E2Etests", "PublishAndRun")] [OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.Windows)] [OSSkipCondition(OperatingSystems.MacOSX)]
[InlineData(ServerType.Kestrel, RuntimeArchitecture.x86, ApplicationType.Portable, false)] public Task PublishAndRunTests_X64_WebListener_Clr()
public async Task NonWindowsOS(
ServerType serverType,
RuntimeArchitecture architecture,
ApplicationType applicationType,
bool noSource)
{
var testRunner = new PublishAndRunTests(_output);
await testRunner.Publish_And_Run_Tests(
serverType, architecture, applicationType, noSource);
}
}
public class PublishAndRunTests : LoggedTest
{
public PublishAndRunTests(ITestOutputHelper output) : base(output)
{ {
return RunTests(ServerType.WebListener, RuntimeFlavor.Clr, ApplicationType.Portable);
} }
public async Task Publish_And_Run_Tests( [Fact]
ServerType serverType, public Task PublishAndRunTests_X64_Kestrel_CoreClr_Portable()
RuntimeArchitecture architecture,
ApplicationType applicationType,
bool noSource)
{ {
var noSourceStr = noSource ? "NoSource" : "WithSource"; return RunTests(ServerType.Kestrel, RuntimeFlavor.CoreClr, ApplicationType.Portable);
var testName = $"PublishAndRunTests_{serverType}_{architecture}_{applicationType}_{noSourceStr}"; }
[Fact]
public Task PublishAndRunTests_X64_Kestrel_CoreClr_Standalone()
{
return RunTests(ServerType.Kestrel, RuntimeFlavor.CoreClr, ApplicationType.Standalone);
}
[ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
public Task PublishAndRunTests_X64_Kestrel_Clr()
{
return RunTests(ServerType.Kestrel, RuntimeFlavor.Clr, ApplicationType.Standalone);
}
private async Task RunTests(
ServerType serverType,
RuntimeFlavor runtimeFlavor,
ApplicationType applicationType)
{
var testName = $"PublishAndRunTests_{serverType}_{runtimeFlavor}_{applicationType}";
using (StartLog(out var loggerFactory, testName)) using (StartLog(out var loggerFactory, testName))
{ {
var logger = loggerFactory.CreateLogger("Publish_And_Run_Tests"); var logger = loggerFactory.CreateLogger("Publish_And_Run_Tests");
var musicStoreDbName = DbUtils.GetUniqueName(); var musicStoreDbName = DbUtils.GetUniqueName();
var deploymentParameters = new DeploymentParameters( var deploymentParameters = new DeploymentParameters(
Helpers.GetApplicationPath(applicationType), serverType, RuntimeFlavor.CoreClr, architecture) Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, RuntimeArchitecture.x64)
{ {
PublishApplicationBeforeDeployment = true, PublishApplicationBeforeDeployment = true,
PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging, PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging,
TargetFramework = "netcoreapp2.0", TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net461" : "netcoreapp2.0",
Configuration = Helpers.GetCurrentBuildConfiguration(), Configuration = Helpers.GetCurrentBuildConfiguration(),
ApplicationType = applicationType, ApplicationType = applicationType,
UserAdditionalCleanup = parameters => UserAdditionalCleanup = parameters =>
@ -142,13 +97,13 @@ namespace E2ETests
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory))
{ {
var deploymentResult = await deployer.DeployAsync(); var deploymentResult = await deployer.DeployAsync();
var httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true }; var httpClientHandler = new HttpClientHandler { UseDefaultCredentials = true };
var httpClient = deploymentResult.CreateHttpClient(httpClientHandler); var httpClient = deploymentResult.CreateHttpClient(httpClientHandler);
// Request to base address and check if various parts of the body are rendered & // Request to base address and check if various parts of the body are rendered &
// measure the cold startup time. // measure the cold startup time.
// Add retry logic since tests are flaky on mono due to connection issues // 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); var response = await RetryHelper.RetryRequest(() => httpClient.GetAsync(string.Empty), logger, cancellationToken: deploymentResult.HostShutdownToken);
Assert.False(response == null, "Response object is null because the client could not " + Assert.False(response == null, "Response object is null because the client could not " +
"connect to the server after multiple retries"); "connect to the server after multiple retries");

View File

@ -1,14 +1,66 @@
using System; using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Testing;
using Xunit; using Xunit;
using Xunit.Abstractions;
namespace E2ETests namespace E2ETests
{ {
public static class SmokeTestHelper public class SmokeTestRunner : LoggedTest
{ {
public SmokeTestRunner(ITestOutputHelper output) : base(output)
{
}
public async Task SmokeTestSuite(
ServerType serverType,
RuntimeFlavor runtimeFlavor,
RuntimeArchitecture architecture,
ApplicationType applicationType)
{
var testName = $"SmokeTestSuite_{serverType}_{applicationType}";
using (StartLog(out var loggerFactory, testName))
{
var logger = loggerFactory.CreateLogger("SmokeTestSuite");
var musicStoreDbName = DbUtils.GetUniqueName();
var deploymentParameters = new DeploymentParameters(
Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
{
EnvironmentName = "SocialTesting",
ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("Http.config") : null,
SiteName = "MusicStoreTestSite",
PublishApplicationBeforeDeployment = true,
PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging,
TargetFramework = runtimeFlavor == RuntimeFlavor.CoreClr ? "netcoreapp2.0" : "net461",
Configuration = Helpers.GetCurrentBuildConfiguration(),
ApplicationType = applicationType,
UserAdditionalCleanup = parameters =>
{
DbUtils.DropDatabase(musicStoreDbName, 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();
await RunTestsAsync(deploymentResult, logger);
}
}
}
public static async Task RunTestsAsync(DeploymentResult deploymentResult, ILogger logger) public static async Task RunTestsAsync(DeploymentResult deploymentResult, ILogger logger)
{ {
var httpClientHandler = new HttpClientHandler(); var httpClientHandler = new HttpClientHandler();
@ -110,5 +162,6 @@ namespace E2ETests
logger.LogInformation("Variation completed successfully."); logger.LogInformation("Variation completed successfully.");
} }
} }
} }

View File

@ -1,175 +0,0 @@
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Testing.xunit;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
using Xunit.Abstractions;
namespace E2ETests
{
public class SmokeTests_X86
{
private readonly ITestOutputHelper _output;
public SmokeTests_X86(ITestOutputHelper output)
{
_output = output;
}
[ConditionalTheory(Skip = "temporarily disabling these tests as dotnet xunit runner does not support 32-bit yet.")]
[Trait("E2Etests", "Smoke")]
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
[InlineData(ServerType.WebListener, RuntimeArchitecture.x86, ApplicationType.Portable)]
[InlineData(ServerType.WebListener, RuntimeArchitecture.x86, ApplicationType.Standalone)]
[InlineData(ServerType.Kestrel, RuntimeArchitecture.x86, ApplicationType.Portable)]
[InlineData(ServerType.Kestrel, RuntimeArchitecture.x86, ApplicationType.Standalone)]
[InlineData(ServerType.IISExpress, RuntimeArchitecture.x86, ApplicationType.Portable)]
[InlineData(ServerType.IISExpress, RuntimeArchitecture.x86, ApplicationType.Standalone)]
public async Task WindowsOS(
ServerType serverType,
RuntimeArchitecture architecture,
ApplicationType applicationType)
{
var smokeTestRunner = new SmokeTests(_output);
await smokeTestRunner.SmokeTestSuite(serverType, architecture, applicationType);
}
[ConditionalTheory(Skip = "Temporarily disabling test")]
[Trait("E2Etests", "Smoke")]
[OSSkipCondition(OperatingSystems.Windows)]
[InlineData(ServerType.Kestrel, RuntimeArchitecture.x86, ApplicationType.Portable)]
public async Task NonWindowsOS(
ServerType serverType,
RuntimeArchitecture architecture,
ApplicationType applicationType)
{
var smokeTestRunner = new SmokeTests(_output);
await smokeTestRunner.SmokeTestSuite(serverType, architecture, applicationType);
}
}
public class SmokeTests_X64
{
private readonly ITestOutputHelper _output;
public SmokeTests_X64(ITestOutputHelper output)
{
_output = output;
}
[ConditionalTheory, Trait("E2Etests", "Smoke")]
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
[InlineData(ServerType.WebListener, RuntimeArchitecture.x64, ApplicationType.Portable)]
[InlineData(ServerType.WebListener, RuntimeArchitecture.x64, ApplicationType.Standalone)]
[InlineData(ServerType.Kestrel, RuntimeArchitecture.x64, ApplicationType.Portable)]
[InlineData(ServerType.Kestrel, RuntimeArchitecture.x64, ApplicationType.Standalone)]
[InlineData(ServerType.IISExpress, RuntimeArchitecture.x64, ApplicationType.Portable)]
[InlineData(ServerType.IISExpress, RuntimeArchitecture.x64, ApplicationType.Standalone)]
public async Task WindowsOS(
ServerType serverType,
RuntimeArchitecture architecture,
ApplicationType applicationType)
{
var smokeTestRunner = new SmokeTests(_output);
await smokeTestRunner.SmokeTestSuite(serverType, architecture, applicationType);
}
[ConditionalTheory, Trait("E2Etests", "Smoke")]
[OSSkipCondition(OperatingSystems.Windows)]
[InlineData(ServerType.Kestrel, RuntimeArchitecture.x64, ApplicationType.Portable)]
[InlineData(ServerType.Kestrel, RuntimeArchitecture.x64, ApplicationType.Standalone)]
public async Task NonWindowsOS(
ServerType serverType,
RuntimeArchitecture architecture,
ApplicationType applicationType)
{
var smokeTestRunner = new SmokeTests(_output);
await smokeTestRunner.SmokeTestSuite(serverType, architecture, applicationType);
}
}
public class SmokeTests_OnIIS
{
private readonly ITestOutputHelper _output;
public SmokeTests_OnIIS(ITestOutputHelper output)
{
_output = output;
}
[ConditionalTheory]
[Trait("E2Etests", "Smoke")]
[OSSkipCondition(OperatingSystems.MacOSX)]
[OSSkipCondition(OperatingSystems.Linux)]
[FrameworkSkipCondition(RuntimeFrameworks.CoreCLR)]
[SkipIfEnvironmentVariableNotEnabled("IIS_VARIATIONS_ENABLED")]
[InlineData(ServerType.IIS, RuntimeArchitecture.x64, ApplicationType.Portable)]
[InlineData(ServerType.IIS, RuntimeArchitecture.x64, ApplicationType.Standalone)]
public async Task SmokeTestSuite_On_IIS_X86(
ServerType serverType,
RuntimeArchitecture architecture,
ApplicationType applicationType)
{
var smokeTestRunner = new SmokeTests(_output);
await smokeTestRunner.SmokeTestSuite(
serverType, architecture, applicationType, noSource: true);
}
}
public class SmokeTests : LoggedTest
{
public SmokeTests(ITestOutputHelper output) : base(output)
{
}
public async Task SmokeTestSuite(
ServerType serverType,
RuntimeArchitecture architecture,
ApplicationType applicationType,
bool noSource = false)
{
var testName = $"SmokeTestSuite_{serverType}_{architecture}_{applicationType}";
using (StartLog(out var loggerFactory, testName))
{
var logger = loggerFactory.CreateLogger("SmokeTestSuite");
var musicStoreDbName = DbUtils.GetUniqueName();
var deploymentParameters = new DeploymentParameters(
Helpers.GetApplicationPath(applicationType), serverType, RuntimeFlavor.CoreClr, architecture)
{
EnvironmentName = "SocialTesting",
ServerConfigTemplateContent = (serverType == ServerType.IISExpress) ? File.ReadAllText("Http.config") : null,
SiteName = "MusicStoreTestSite",
PublishApplicationBeforeDeployment = true,
PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging,
TargetFramework = "netcoreapp2.0",
Configuration = Helpers.GetCurrentBuildConfiguration(),
ApplicationType = applicationType,
UserAdditionalCleanup = parameters =>
{
DbUtils.DropDatabase(musicStoreDbName, 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);
}
}
}
}
}

View File

@ -258,7 +258,7 @@ namespace E2ETests
{ {
var deploymentResult = await deployer.DeployAsync(); var deploymentResult = await deployer.DeployAsync();
await SmokeTestHelper.RunTestsAsync(deploymentResult, logger); await SmokeTestRunner.RunTestsAsync(deploymentResult, logger);
} }
} }
} }

View File

@ -61,7 +61,7 @@ namespace E2ETests
File.Exists(mvcCoreDllPath), File.Exists(mvcCoreDllPath),
$"The file '{fileInfo.Name}.{fileInfo.Extension}' was not expected to be present in the publish directory"); $"The file '{fileInfo.Name}.{fileInfo.Extension}' was not expected to be present in the publish directory");
await SmokeTestHelper.RunTestsAsync(deploymentResult, logger); await SmokeTestRunner.RunTestsAsync(deploymentResult, logger);
} }
} }
} }

View File

@ -0,0 +1,87 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Testing.xunit;
using Xunit;
using Xunit.Abstractions;
namespace E2ETests
{
[Trait("E2Etests", "Smoke")]
public class SmokeTests_X64
{
private readonly SmokeTestRunner _smokeTestRunner;
public SmokeTests_X64(ITestOutputHelper output)
{
_smokeTestRunner = new SmokeTestRunner(output);
}
[ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
public Task SmokeTests_X64_WebListener_Clr()
{
return _smokeTestRunner.SmokeTestSuite(ServerType.WebListener, RuntimeFlavor.Clr, RuntimeArchitecture.x64, ApplicationType.Portable);
}
[ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
public Task SmokeTests_X64_WebListener_CoreClr_Portable()
{
return _smokeTestRunner.SmokeTestSuite(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable);
}
[ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
public Task SmokeTests_X64_WebListener_CoreClr_Standalone()
{
return _smokeTestRunner.SmokeTestSuite(ServerType.WebListener, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone);
}
[ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
public Task SmokeTests_X64_IISExpress_Clr()
{
return _smokeTestRunner.SmokeTestSuite(ServerType.IISExpress, RuntimeFlavor.Clr, RuntimeArchitecture.x64, ApplicationType.Portable);
}
[ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
public Task SmokeTests_X64_IISExpress_CoreClr_Portable()
{
return _smokeTestRunner.SmokeTestSuite(ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable);
}
[ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
public Task SmokeTests_X64_IISExpress_CoreClr_Standalone()
{
return _smokeTestRunner.SmokeTestSuite(ServerType.IISExpress, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone);
}
[ConditionalFact]
[OSSkipCondition(OperatingSystems.Linux)]
[OSSkipCondition(OperatingSystems.MacOSX)]
public Task SmokeTests_X64_Kestrel_Clr()
{
return _smokeTestRunner.SmokeTestSuite(ServerType.Kestrel, RuntimeFlavor.Clr, RuntimeArchitecture.x64, ApplicationType.Portable);
}
[Fact]
public Task SmokeTests_X64_Kestrel_CoreClr_Portable()
{
return _smokeTestRunner.SmokeTestSuite(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Portable);
}
[Fact]
public Task SmokeTests_X64_Kestrel_CoreClr_Standalone()
{
return _smokeTestRunner.SmokeTestSuite(ServerType.Kestrel, RuntimeFlavor.CoreClr, RuntimeArchitecture.x64, ApplicationType.Standalone);
}
}
}