зеркало из https://github.com/aspnet/MusicStore.git
Updated runtime store tests and friends
This commit is contained in:
Родитель
fc56105d83
Коммит
f8ccf05715
|
@ -1,22 +0,0 @@
|
|||
namespace E2ETests
|
||||
{
|
||||
public class DefaultLocationSetupFixture : BaseStoreSetupFixture
|
||||
{
|
||||
public DefaultLocationSetupFixture() :
|
||||
base(
|
||||
createInDefaultLocation: true,
|
||||
loggerName: nameof(DefaultLocationSetupFixture))
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class CustomLocationSetupFixture : BaseStoreSetupFixture
|
||||
{
|
||||
public CustomLocationSetupFixture() :
|
||||
base(
|
||||
createInDefaultLocation: false,
|
||||
loggerName: nameof(CustomLocationSetupFixture))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Microsoft.AspNetCore.Testing.xunit;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace E2ETests
|
||||
{
|
||||
public class SmokeTestsUsingDefaultLocation : IClassFixture<DefaultLocationSetupFixture>
|
||||
{
|
||||
private readonly DefaultLocationSetupFixture _testFixture;
|
||||
private readonly ITestOutputHelper _output;
|
||||
|
||||
public SmokeTestsUsingDefaultLocation(
|
||||
DefaultLocationSetupFixture testFixure,
|
||||
ITestOutputHelper output)
|
||||
{
|
||||
_testFixture = testFixure;
|
||||
_output = output;
|
||||
}
|
||||
|
||||
[EnvironmentVariableSkipCondition(Store.MusicStoreAspNetCoreStoreFeed, null, SkipOnMatch = false)]
|
||||
[ConditionalFact]
|
||||
[Trait("smoketests", "usestore")]
|
||||
[Trait("smoketests", "usestore-defaultlocation")]
|
||||
public async Task DefaultLocation_Kestrel()
|
||||
{
|
||||
var tests = new SmokeTestsUsingStoreHelper(_output);
|
||||
await tests.SmokeTestSuite(
|
||||
ServerType.Kestrel,
|
||||
_testFixture.CreateStoreInDefaultLocation,
|
||||
_testFixture.StoreDirectory);
|
||||
}
|
||||
|
||||
[OSSkipCondition(OperatingSystems.Linux)]
|
||||
[OSSkipCondition(OperatingSystems.MacOSX)]
|
||||
[EnvironmentVariableSkipCondition(Store.MusicStoreAspNetCoreStoreFeed, null, SkipOnMatch = false)]
|
||||
[ConditionalFact]
|
||||
[Trait("smoketests", "usestore")]
|
||||
[Trait("smoketests", "usestore-defaultlocation")]
|
||||
public async Task DefaultLocation_WebListener()
|
||||
{
|
||||
var tests = new SmokeTestsUsingStoreHelper(_output);
|
||||
await tests.SmokeTestSuite(
|
||||
ServerType.WebListener,
|
||||
_testFixture.CreateStoreInDefaultLocation,
|
||||
_testFixture.StoreDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
public class SmokeTestsUsingInCustomLocation : IClassFixture<CustomLocationSetupFixture>
|
||||
{
|
||||
private readonly CustomLocationSetupFixture _testFixture;
|
||||
private readonly ITestOutputHelper _output;
|
||||
|
||||
public SmokeTestsUsingInCustomLocation(
|
||||
CustomLocationSetupFixture testFixure,
|
||||
ITestOutputHelper output)
|
||||
{
|
||||
_testFixture = testFixure;
|
||||
_output = output;
|
||||
}
|
||||
|
||||
[EnvironmentVariableSkipCondition(Store.MusicStoreAspNetCoreStoreFeed, null, SkipOnMatch = false)]
|
||||
[ConditionalFact]
|
||||
[Trait("smoketests", "usestore")]
|
||||
[Trait("smoketests", "usestore-customlocation")]
|
||||
public async Task CustomLocation_Kestrel()
|
||||
{
|
||||
var tests = new SmokeTestsUsingStoreHelper(_output);
|
||||
await tests.SmokeTestSuite(
|
||||
ServerType.Kestrel,
|
||||
_testFixture.CreateStoreInDefaultLocation,
|
||||
_testFixture.StoreDirectory);
|
||||
}
|
||||
|
||||
[OSSkipCondition(OperatingSystems.Linux)]
|
||||
[OSSkipCondition(OperatingSystems.MacOSX)]
|
||||
[EnvironmentVariableSkipCondition(Store.MusicStoreAspNetCoreStoreFeed, null, SkipOnMatch = false)]
|
||||
[ConditionalFact]
|
||||
[Trait("smoketests", "usestore")]
|
||||
[Trait("smoketests", "usestore-customlocation")]
|
||||
public async Task CustomLocation_WebListener()
|
||||
{
|
||||
var tests = new SmokeTestsUsingStoreHelper(_output);
|
||||
await tests.SmokeTestSuite(
|
||||
ServerType.WebListener,
|
||||
_testFixture.CreateStoreInDefaultLocation,
|
||||
_testFixture.StoreDirectory);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,7 +7,6 @@ using System.Reflection;
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Microsoft.Extensions.CommandLineUtils;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NuGet.Configuration;
|
||||
using NuGet.Packaging.Core;
|
||||
|
@ -29,9 +28,9 @@ namespace E2ETests
|
|||
_logger = loggerFactory.CreateLogger<Store>();
|
||||
}
|
||||
|
||||
public string CreateStore(bool createInDefaultLocation)
|
||||
public string CreateStore()
|
||||
{
|
||||
var storeParentDir = GetStoreParentDirectory(createInDefaultLocation);
|
||||
var storeParentDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
|
||||
InstallStore(storeParentDir);
|
||||
|
||||
|
@ -226,22 +225,5 @@ namespace E2ETests
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string GetStoreParentDirectory(bool createInDefaultLocation)
|
||||
{
|
||||
string storeParentDir;
|
||||
if (createInDefaultLocation)
|
||||
{
|
||||
// On Windows: ..\.dotnet\x64\dotnet.exe
|
||||
// On Linux : ../.dotnet/dotnet
|
||||
var dotnetDir = new FileInfo(DotNetMuxer.MuxerPath).Directory.FullName;
|
||||
storeParentDir = dotnetDir;
|
||||
}
|
||||
else
|
||||
{
|
||||
storeParentDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
}
|
||||
return storeParentDir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,36 +4,31 @@ using Microsoft.Extensions.Logging.Testing;
|
|||
|
||||
namespace E2ETests
|
||||
{
|
||||
public class BaseStoreSetupFixture : IDisposable
|
||||
public class StoreSetupFixture : IDisposable
|
||||
{
|
||||
private readonly IDisposable _logToken;
|
||||
private readonly ILogger<BaseStoreSetupFixture> _logger;
|
||||
private readonly ILogger<StoreSetupFixture> _logger;
|
||||
private readonly Store _store;
|
||||
|
||||
public BaseStoreSetupFixture(bool createInDefaultLocation, string loggerName)
|
||||
public StoreSetupFixture()
|
||||
{
|
||||
if (!Store.IsEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var testLog = AssemblyTestLog.ForAssembly(typeof(BaseStoreSetupFixture).Assembly);
|
||||
var loggerName = nameof(StoreSetupFixture);
|
||||
var testLog = AssemblyTestLog.ForAssembly(typeof(StoreSetupFixture).Assembly);
|
||||
ILoggerFactory loggerFactory;
|
||||
_logToken = testLog.StartTestLog(null, loggerName, out loggerFactory, testName: loggerName);
|
||||
_logger = loggerFactory.CreateLogger<BaseStoreSetupFixture>();
|
||||
|
||||
CreateStoreInDefaultLocation = createInDefaultLocation;
|
||||
|
||||
_logger.LogInformation(
|
||||
"Setting up store in the location: {location}",
|
||||
createInDefaultLocation ? "default" : "custom");
|
||||
_logger = loggerFactory.CreateLogger<StoreSetupFixture>();
|
||||
|
||||
_store = new Store(loggerFactory);
|
||||
|
||||
StoreDirectory = _store.CreateStore(createInDefaultLocation);
|
||||
}
|
||||
StoreDirectory = _store.CreateStore();
|
||||
|
||||
public bool CreateStoreInDefaultLocation { get; }
|
||||
_logger.LogInformation($"Store was setup at {StoreDirectory}");
|
||||
}
|
||||
|
||||
public string StoreDirectory { get; }
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
|
@ -6,21 +7,21 @@ using Microsoft.Extensions.Logging.Testing;
|
|||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace E2ETests
|
||||
namespace E2ETests.SmokeTestsUsingStore
|
||||
{
|
||||
public class SmokeTestsUsingStoreHelper : LoggedTest
|
||||
public class TestHelper : LoggedTest
|
||||
{
|
||||
public SmokeTestsUsingStoreHelper(ITestOutputHelper output) : base(output)
|
||||
public TestHelper(ITestOutputHelper output) : base(output)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task SmokeTestSuite(ServerType serverType, bool isStoreInDefaultLocation, string storeDirectory)
|
||||
public async Task SmokeTestSuite(ServerType serverType, string storeDirectory)
|
||||
{
|
||||
var targetFramework = "netcoreapp2.0";
|
||||
var testName = $"SmokeTestsUsingStore_{serverType}";
|
||||
using (StartLog(out var loggerFactory, testName))
|
||||
{
|
||||
var logger = loggerFactory.CreateLogger(nameof(SmokeTestsUsingStoreHelper));
|
||||
var logger = loggerFactory.CreateLogger(nameof(TestHelper));
|
||||
var musicStoreDbName = DbUtils.GetUniqueName();
|
||||
|
||||
var deploymentParameters = new DeploymentParameters(
|
||||
|
@ -45,11 +46,8 @@ namespace E2ETests
|
|||
MusicStoreConfig.ConnectionStringKey,
|
||||
DbUtils.CreateConnectionString(musicStoreDbName)));
|
||||
|
||||
if (!isStoreInDefaultLocation)
|
||||
{
|
||||
deploymentParameters.EnvironmentVariables.Add(
|
||||
new KeyValuePair<string, string>("DOTNET_SHARED_STORE", storeDirectory));
|
||||
}
|
||||
|
||||
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory))
|
||||
{
|
|
@ -0,0 +1,46 @@
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Microsoft.AspNetCore.Testing.xunit;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace E2ETests.SmokeTestsUsingStore
|
||||
{
|
||||
public class SmokeTests : IClassFixture<StoreSetupFixture>
|
||||
{
|
||||
private readonly StoreSetupFixture _testFixture;
|
||||
private readonly ITestOutputHelper _output;
|
||||
|
||||
public SmokeTests(
|
||||
StoreSetupFixture testFixure,
|
||||
ITestOutputHelper output)
|
||||
{
|
||||
_testFixture = testFixure;
|
||||
_output = output;
|
||||
}
|
||||
|
||||
[EnvironmentVariableSkipCondition(Store.MusicStoreAspNetCoreStoreFeed, null, SkipOnMatch = false)]
|
||||
[ConditionalFact]
|
||||
[Trait("smoketests", "usestore1")]
|
||||
public async Task DefaultLocation_Kestrel()
|
||||
{
|
||||
var tests = new TestHelper(_output);
|
||||
await tests.SmokeTestSuite(
|
||||
ServerType.Kestrel,
|
||||
_testFixture.StoreDirectory);
|
||||
}
|
||||
|
||||
[OSSkipCondition(OperatingSystems.Linux)]
|
||||
[OSSkipCondition(OperatingSystems.MacOSX)]
|
||||
[EnvironmentVariableSkipCondition(Store.MusicStoreAspNetCoreStoreFeed, null, SkipOnMatch = false)]
|
||||
[ConditionalFact]
|
||||
[Trait("smoketests", "usestore")]
|
||||
public async Task DefaultLocation_WebListener()
|
||||
{
|
||||
var tests = new TestHelper(_output);
|
||||
await tests.SmokeTestSuite(
|
||||
ServerType.WebListener,
|
||||
_testFixture.StoreDirectory);
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче