From 5bcba9677ec94b6b14e0d4413c2ec97e2558744c Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 14 Jun 2017 18:06:05 -0700 Subject: [PATCH] Re-enable desktop tests * Cleanup tests to use a test case per scenario * Run tests on CLR * Enable view precompilaton for the sample. --- build/dependencies.props | 1 + samples/MusicStore/MusicStore.csproj | 30 ++- test/MusicStore.E2ETests/Common/Helpers.cs | 53 +----- .../NtlmAuthentationTest.cs | 55 ++++-- .../MusicStore.E2ETests/OpenIdConnectTests.cs | 42 ++--- .../MusicStore.E2ETests/PublishAndRunTests.cs | 131 +++++-------- ...{SmokeTestHelper.cs => SmokeTestRunner.cs} | 55 +++++- test/MusicStore.E2ETests/SmokeTests.cs | 175 ------------------ .../SmokeTestsOnNanoServer.cs | 2 +- .../SmokeTestsUsingStoreHelper.cs | 2 +- test/MusicStore.E2ETests/SmokeTests_X64.cs | 87 +++++++++ 11 files changed, 288 insertions(+), 345 deletions(-) rename test/MusicStore.E2ETests/{SmokeTestHelper.cs => SmokeTestRunner.cs} (67%) delete mode 100644 test/MusicStore.E2ETests/SmokeTests.cs create mode 100644 test/MusicStore.E2ETests/SmokeTests_X64.cs diff --git a/build/dependencies.props b/build/dependencies.props index 10ea3855cf..256894594f 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -5,6 +5,7 @@ 1.0.0-* 4.4.0-* 2.0.0-* + 2.0.0-* 4.0.0 2.0.0-* 15.3.0-* diff --git a/samples/MusicStore/MusicStore.csproj b/samples/MusicStore/MusicStore.csproj index 51ff611dfd..bacbb8917f 100644 --- a/samples/MusicStore/MusicStore.csproj +++ b/samples/MusicStore/MusicStore.csproj @@ -4,8 +4,9 @@ Music store application on ASP.NET Core - netcoreapp2.0 + netcoreapp2.0;net461 $(DefineConstants);DEMO + true true win7-x86;win7-x64;linux-x64;osx-x64 @@ -15,7 +16,32 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/MusicStore.E2ETests/Common/Helpers.cs b/test/MusicStore.E2ETests/Common/Helpers.cs index edbf367450..d507df3bea 100644 --- a/test/MusicStore.E2ETests/Common/Helpers.cs +++ b/test/MusicStore.E2ETests/Common/Helpers.cs @@ -1,8 +1,7 @@ using System; using System.IO; -using System.Linq; using Microsoft.AspNetCore.Server.IntegrationTesting; -using Microsoft.Extensions.Logging; +using Microsoft.AspNetCore.Testing; namespace E2ETests { @@ -10,53 +9,17 @@ namespace E2ETests { public static string GetApplicationPath(ApplicationType applicationType) { - var current = new DirectoryInfo(AppContext.BaseDirectory); - while (current != null) - { - 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\"}"); - } + var solutionDirectory = TestPathUtilities.GetSolutionRootDirectory("MusicStore"); + return Path.GetFullPath(Path.Combine(solutionDirectory, "samples", "MusicStore")); } public static string GetCurrentBuildConfiguration() { - var configuration = "Debug"; - if (string.Equals(Environment.GetEnvironmentVariable("Configuration"), "Release", StringComparison.OrdinalIgnoreCase)) - { - configuration = "Release"; - } - - return configuration; +#if DEBUG + return "Debug"; +#else + return "Release"; +#endif } public static bool PreservePublishedApplicationForDebugging diff --git a/test/MusicStore.E2ETests/NtlmAuthentationTest.cs b/test/MusicStore.E2ETests/NtlmAuthentationTest.cs index b83ef362d5..d8701e633d 100644 --- a/test/MusicStore.E2ETests/NtlmAuthentationTest.cs +++ b/test/MusicStore.E2ETests/NtlmAuthentationTest.cs @@ -12,32 +12,65 @@ using Xunit.Abstractions; namespace E2ETests { + [Trait("E2Etests", "E2Etests")] + [OSSkipCondition(OperatingSystems.Linux)] + [OSSkipCondition(OperatingSystems.MacOSX)] public class NtlmAuthenticationTests : LoggedTest { public NtlmAuthenticationTests(ITestOutputHelper output) : base(output) { } - [ConditionalTheory, Trait("E2Etests", "E2Etests")] - [OSSkipCondition(OperatingSystems.Linux)] - [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) + [ConditionalFact] + public Task NtlmAuthenticationTest_WebListener_CoreCLR_Portable() { - 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)) { var logger = loggerFactory.CreateLogger("NtlmAuthenticationTest"); 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, PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging, - TargetFramework = "netcoreapp2.0", + TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net461" : "netcoreapp2.0", Configuration = Helpers.GetCurrentBuildConfiguration(), ApplicationType = applicationType, EnvironmentName = "NtlmAuthentication", //Will pick the Start class named 'StartupNtlmAuthentication' diff --git a/test/MusicStore.E2ETests/OpenIdConnectTests.cs b/test/MusicStore.E2ETests/OpenIdConnectTests.cs index 0da69d3a61..c5f1b8ffc2 100644 --- a/test/MusicStore.E2ETests/OpenIdConnectTests.cs +++ b/test/MusicStore.E2ETests/OpenIdConnectTests.cs @@ -10,47 +10,47 @@ using Xunit.Abstractions; namespace E2ETests { + [Trait("E2Etests", "E2Etests")] public class OpenIdConnectTests : LoggedTest { 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.MacOSX)] - [InlineData(ServerType.Kestrel, RuntimeArchitecture.x64, ApplicationType.Portable)] - [InlineData(ServerType.Kestrel, RuntimeArchitecture.x64, ApplicationType.Standalone)] - public async Task OpenIdConnect_OnWindowsOS( - ServerType serverType, - RuntimeArchitecture architecture, - ApplicationType applicationType) + public Task OpenIdConnect_Kestrel_CLR() { - await OpenIdConnectTestSuite(serverType, architecture, applicationType); + return OpenIdConnectTestSuite(ServerType.Kestrel, RuntimeFlavor.Clr, ApplicationType.Portable); } - [ConditionalTheory, Trait("E2Etests", "E2Etests")] - [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) + private async Task OpenIdConnectTestSuite(ServerType serverType, RuntimeFlavor runtimeFlavor, ApplicationType applicationType) { - await OpenIdConnectTestSuite(serverType, architecture, applicationType); - } - - private async Task OpenIdConnectTestSuite(ServerType serverType, RuntimeArchitecture architecture, ApplicationType applicationType) - { - var testName = $"OpenIdConnectTestSuite_{serverType}_{architecture}_{applicationType}"; + var architecture = RuntimeArchitecture.x64; + var testName = $"OpenIdConnectTestSuite_{serverType}_{runtimeFlavor}_{architecture}_{applicationType}"; using (StartLog(out var loggerFactory, testName)) { var logger = loggerFactory.CreateLogger("OpenIdConnectTestSuite"); 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, PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging, - TargetFramework = "netcoreapp2.0", + TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net461" : "netcoreapp2.0", Configuration = Helpers.GetCurrentBuildConfiguration(), ApplicationType = applicationType, EnvironmentName = "OpenIdConnectTesting", diff --git a/test/MusicStore.E2ETests/PublishAndRunTests.cs b/test/MusicStore.E2ETests/PublishAndRunTests.cs index ab8940202c..c0add101b8 100644 --- a/test/MusicStore.E2ETests/PublishAndRunTests.cs +++ b/test/MusicStore.E2ETests/PublishAndRunTests.cs @@ -12,119 +12,74 @@ using Xunit.Abstractions; namespace E2ETests { - public class PublishAndRunTests_OnX64 + [Trait("E2Etests", "PublishAndRun")] + public class PublishAndRunTests_X64 : LoggedTest { - private readonly ITestOutputHelper _output; - - public PublishAndRunTests_OnX64(ITestOutputHelper output) + public PublishAndRunTests_X64(ITestOutputHelper output) : base(output) { - _output = output; } - [ConditionalTheory, Trait("E2Etests", "PublishAndRun")] + [ConditionalFact] [OSSkipCondition(OperatingSystems.Linux)] [OSSkipCondition(OperatingSystems.MacOSX)] - [InlineData(ServerType.WebListener, RuntimeArchitecture.x64, ApplicationType.Portable, false)] - [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) + public Task PublishAndRunTests_X64_WebListener_CoreCLR_Portable() { - var testRunner = new PublishAndRunTests(_output); - await testRunner.Publish_And_Run_Tests( - serverType, architecture, applicationType, noSource); + return RunTests(ServerType.WebListener, RuntimeFlavor.CoreClr, ApplicationType.Portable); } - [ConditionalTheory, Trait("E2Etests", "PublishAndRun")] - [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")] + [ConditionalFact] [OSSkipCondition(OperatingSystems.Linux)] [OSSkipCondition(OperatingSystems.MacOSX)] - [InlineData(ServerType.WebListener, RuntimeArchitecture.x86, ApplicationType.Portable, false)] - [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) + public Task PublishAndRunTests_X64_WebListener_CoreCLR_Standalone() { - var testRunner = new PublishAndRunTests(_output); - await testRunner.Publish_And_Run_Tests( - serverType, architecture, applicationType, noSource); + return RunTests(ServerType.WebListener, RuntimeFlavor.CoreClr, ApplicationType.Standalone); } - [ConditionalTheory(Skip = SkipReason)] - [Trait("E2Etests", "PublishAndRun")] - [OSSkipCondition(OperatingSystems.Windows)] - [InlineData(ServerType.Kestrel, RuntimeArchitecture.x86, ApplicationType.Portable, 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 : LoggedTest - { - public PublishAndRunTests(ITestOutputHelper output) : base(output) + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Linux)] + [OSSkipCondition(OperatingSystems.MacOSX)] + public Task PublishAndRunTests_X64_WebListener_Clr() { + return RunTests(ServerType.WebListener, RuntimeFlavor.Clr, ApplicationType.Portable); } - public async Task Publish_And_Run_Tests( - ServerType serverType, - RuntimeArchitecture architecture, - ApplicationType applicationType, - bool noSource) + [Fact] + public Task PublishAndRunTests_X64_Kestrel_CoreClr_Portable() { - var noSourceStr = noSource ? "NoSource" : "WithSource"; - var testName = $"PublishAndRunTests_{serverType}_{architecture}_{applicationType}_{noSourceStr}"; + return RunTests(ServerType.Kestrel, RuntimeFlavor.CoreClr, ApplicationType.Portable); + } + + [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)) { var logger = loggerFactory.CreateLogger("Publish_And_Run_Tests"); var musicStoreDbName = DbUtils.GetUniqueName(); var deploymentParameters = new DeploymentParameters( - Helpers.GetApplicationPath(applicationType), serverType, RuntimeFlavor.CoreClr, architecture) + Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, RuntimeArchitecture.x64) { PublishApplicationBeforeDeployment = true, PreservePublishedApplicationForDebugging = Helpers.PreservePublishedApplicationForDebugging, - TargetFramework = "netcoreapp2.0", + TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net461" : "netcoreapp2.0", Configuration = Helpers.GetCurrentBuildConfiguration(), ApplicationType = applicationType, UserAdditionalCleanup = parameters => @@ -142,13 +97,13 @@ namespace E2ETests using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory)) { var deploymentResult = await deployer.DeployAsync(); - var httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true }; + var httpClientHandler = new HttpClientHandler { UseDefaultCredentials = true }; var httpClient = deploymentResult.CreateHttpClient(httpClientHandler); // 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); + 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 " + "connect to the server after multiple retries"); diff --git a/test/MusicStore.E2ETests/SmokeTestHelper.cs b/test/MusicStore.E2ETests/SmokeTestRunner.cs similarity index 67% rename from test/MusicStore.E2ETests/SmokeTestHelper.cs rename to test/MusicStore.E2ETests/SmokeTestRunner.cs index ec4f7ee934..838bdfd7a7 100644 --- a/test/MusicStore.E2ETests/SmokeTestHelper.cs +++ b/test/MusicStore.E2ETests/SmokeTestRunner.cs @@ -1,14 +1,66 @@ using System; +using System.Collections.Generic; +using System.IO; using System.Net.Http; using System.Threading.Tasks; using Microsoft.AspNetCore.Server.IntegrationTesting; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Testing; using Xunit; +using Xunit.Abstractions; 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( + 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) { var httpClientHandler = new HttpClientHandler(); @@ -110,5 +162,6 @@ namespace E2ETests logger.LogInformation("Variation completed successfully."); } + } } diff --git a/test/MusicStore.E2ETests/SmokeTests.cs b/test/MusicStore.E2ETests/SmokeTests.cs deleted file mode 100644 index 8ff5fdc102..0000000000 --- a/test/MusicStore.E2ETests/SmokeTests.cs +++ /dev/null @@ -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( - 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); - } - } - } - } -} diff --git a/test/MusicStore.E2ETests/SmokeTestsOnNanoServer.cs b/test/MusicStore.E2ETests/SmokeTestsOnNanoServer.cs index 07ba947f66..d474f1cfc2 100644 --- a/test/MusicStore.E2ETests/SmokeTestsOnNanoServer.cs +++ b/test/MusicStore.E2ETests/SmokeTestsOnNanoServer.cs @@ -258,7 +258,7 @@ namespace E2ETests { var deploymentResult = await deployer.DeployAsync(); - await SmokeTestHelper.RunTestsAsync(deploymentResult, logger); + await SmokeTestRunner.RunTestsAsync(deploymentResult, logger); } } } diff --git a/test/MusicStore.E2ETests/SmokeTestsUsingStore/SmokeTestsUsingStoreHelper.cs b/test/MusicStore.E2ETests/SmokeTestsUsingStore/SmokeTestsUsingStoreHelper.cs index 4961248e61..4f97573842 100644 --- a/test/MusicStore.E2ETests/SmokeTestsUsingStore/SmokeTestsUsingStoreHelper.cs +++ b/test/MusicStore.E2ETests/SmokeTestsUsingStore/SmokeTestsUsingStoreHelper.cs @@ -61,7 +61,7 @@ namespace E2ETests File.Exists(mvcCoreDllPath), $"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); } } } diff --git a/test/MusicStore.E2ETests/SmokeTests_X64.cs b/test/MusicStore.E2ETests/SmokeTests_X64.cs new file mode 100644 index 0000000000..57a5448530 --- /dev/null +++ b/test/MusicStore.E2ETests/SmokeTests_X64.cs @@ -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); + } + } +}