82 lines
3.0 KiB
C#
82 lines
3.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Threading.Tasks;
|
|
using E2ETests.Common;
|
|
using Microsoft.AspNetCore.Server.Testing;
|
|
using Microsoft.AspNetCore.Testing.xunit;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Logging;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace E2ETests
|
|
{
|
|
public class SmokeTestsOnNanoServer : IDisposable
|
|
{
|
|
private readonly XunitLogger _logger;
|
|
private readonly RemoteDeploymentConfig _remoteDeploymentConfig;
|
|
|
|
public SmokeTestsOnNanoServer(ITestOutputHelper output)
|
|
{
|
|
_logger = new XunitLogger(output, LogLevel.Information);
|
|
|
|
var configuration = new ConfigurationBuilder()
|
|
.SetBasePath(Directory.GetCurrentDirectory())
|
|
.AddJsonFile("remoteDeploymentConfig.json")
|
|
.AddEnvironmentVariables()
|
|
.Build();
|
|
|
|
_remoteDeploymentConfig = new RemoteDeploymentConfig();
|
|
configuration.GetSection("NanoServer").Bind(_remoteDeploymentConfig);
|
|
}
|
|
|
|
[ConditionalTheory, Trait("E2Etests", "NanoServer")]
|
|
[OSSkipCondition(OperatingSystems.Linux)]
|
|
[OSSkipCondition(OperatingSystems.MacOSX)]
|
|
[SkipIfEnvironmentVariableNotEnabled("RUN_TESTS_ON_NANO")]
|
|
[InlineData(ServerType.Kestrel, 5000)]
|
|
[InlineData(ServerType.WebListener, 5000)]
|
|
public async Task Test(ServerType serverType, int portToListen)
|
|
{
|
|
var applicationBaseUrl = $"http://{_remoteDeploymentConfig.ServerName}:{portToListen}/";
|
|
await RunTestsAsync(serverType, applicationBaseUrl);
|
|
}
|
|
|
|
private async Task RunTestsAsync(ServerType serverType, string applicationBaseUrl)
|
|
{
|
|
using (_logger.BeginScope("SmokeTestSuite"))
|
|
{
|
|
var deploymentParameters = new RemoteWindowsDeploymentParameters(
|
|
Helpers.GetApplicationPath(),
|
|
serverType,
|
|
RuntimeFlavor.CoreClr,
|
|
RuntimeArchitecture.x64,
|
|
_remoteDeploymentConfig.FileSharePath,
|
|
_remoteDeploymentConfig.ServerName,
|
|
_remoteDeploymentConfig.AccountName,
|
|
_remoteDeploymentConfig.AccountPassword,
|
|
_remoteDeploymentConfig.ExecutableRelativePath)
|
|
{
|
|
PublishTargetFramework = "netstandardapp1.5",
|
|
ApplicationBaseUriHint = applicationBaseUrl
|
|
};
|
|
deploymentParameters.EnvironmentVariables.Add(
|
|
new KeyValuePair<string, string>("ASPNETCORE_ENVIRONMENT", "SocialTesting"));
|
|
|
|
using (var deployer = new RemoteWindowsDeployer(deploymentParameters, _logger))
|
|
{
|
|
var deploymentResult = deployer.Deploy();
|
|
|
|
await SmokeTestHelper.RunTestsAsync(deploymentResult, _logger);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_logger.Dispose();
|
|
}
|
|
}
|
|
}
|