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>
<CoreFxVersion>4.4.0-*</CoreFxVersion>
<NETStandardImplicitPackageVersion>2.0.0-*</NETStandardImplicitPackageVersion>
<NETStandardLibraryNETFrameworkVersion>2.0.0-*</NETStandardLibraryNETFrameworkVersion>
<NuGetPackagesVersion>4.0.0</NuGetPackagesVersion>
<RuntimeFrameworkVersion Condition="'$(TargetFramework)'=='netcoreapp2.0'">2.0.0-*</RuntimeFrameworkVersion>
<TestSdkVersion>15.3.0-*</TestSdkVersion>

View File

@ -4,8 +4,9 @@
<PropertyGroup>
<Description>Music store application on ASP.NET Core</Description>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
<DefineConstants>$(DefineConstants);DEMO</DefineConstants>
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<RuntimeIdentifiers Condition="'$(MUSICSTORE_ASPNETCORE_STORE_FEED)' == ''">win7-x86;win7-x64;linux-x64;osx-x64</RuntimeIdentifiers>
</PropertyGroup>
@ -15,7 +16,32 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.AspNetCoreModule" Version="$(AspNetCoreModuleVersion)" />
</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>

View File

@ -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

View File

@ -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'

View File

@ -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",

View File

@ -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");

View File

@ -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<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)
{
var httpClientHandler = new HttpClientHandler();
@ -110,5 +162,6 @@ namespace E2ETests
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();
await SmokeTestHelper.RunTestsAsync(deploymentResult, logger);
await SmokeTestRunner.RunTestsAsync(deploymentResult, logger);
}
}
}

View File

@ -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);
}
}
}

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);
}
}
}