Skip to content
This repository has been archived by the owner on Feb 23, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
analogrelay committed Apr 6, 2017
1 parent 200207b commit 0a1df2d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 45 deletions.
16 changes: 15 additions & 1 deletion Entropy.sln
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.9
VisualStudioVersion = 15.0.26405.2
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Builder", "Builder", "{097807B3-FE74-4DCD-B76B-2FCE1A272BE5}"
EndProject
Expand Down Expand Up @@ -136,6 +136,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{DA474CFD
build\dependencies.props = build\dependencies.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server.IntegrationTesting", "..\Hosting\src\Microsoft.AspNetCore.Server.IntegrationTesting\Microsoft.AspNetCore.Server.IntegrationTesting.csproj", "{93934259-2D02-4C6C-AAAA-7CFD853ECD0C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -734,6 +736,18 @@ Global
{FDD8875D-00D6-4E8C-9E21-D90C0A2C81B7}.Release|x64.Build.0 = Release|Any CPU
{FDD8875D-00D6-4E8C-9E21-D90C0A2C81B7}.Release|x86.ActiveCfg = Release|Any CPU
{FDD8875D-00D6-4E8C-9E21-D90C0A2C81B7}.Release|x86.Build.0 = Release|Any CPU
{93934259-2D02-4C6C-AAAA-7CFD853ECD0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{93934259-2D02-4C6C-AAAA-7CFD853ECD0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{93934259-2D02-4C6C-AAAA-7CFD853ECD0C}.Debug|x64.ActiveCfg = Debug|Any CPU
{93934259-2D02-4C6C-AAAA-7CFD853ECD0C}.Debug|x64.Build.0 = Debug|Any CPU
{93934259-2D02-4C6C-AAAA-7CFD853ECD0C}.Debug|x86.ActiveCfg = Debug|Any CPU
{93934259-2D02-4C6C-AAAA-7CFD853ECD0C}.Debug|x86.Build.0 = Debug|Any CPU
{93934259-2D02-4C6C-AAAA-7CFD853ECD0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{93934259-2D02-4C6C-AAAA-7CFD853ECD0C}.Release|Any CPU.Build.0 = Release|Any CPU
{93934259-2D02-4C6C-AAAA-7CFD853ECD0C}.Release|x64.ActiveCfg = Release|Any CPU
{93934259-2D02-4C6C-AAAA-7CFD853ECD0C}.Release|x64.Build.0 = Release|Any CPU
{93934259-2D02-4C6C-AAAA-7CFD853ECD0C}.Release|x86.ActiveCfg = Release|Any CPU
{93934259-2D02-4C6C-AAAA-7CFD853ECD0C}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
16 changes: 5 additions & 11 deletions test/FunctionalTests/E2ETestBase.cs
Expand Up @@ -11,17 +11,16 @@
using Microsoft.Extensions.Logging;
using Xunit;
using Xunit.Abstractions;
using Microsoft.AspNetCore.Server.IntegrationTesting.xunit;

namespace EntropyTests
{
public abstract class E2ETestBase
public abstract class E2ETestBase : LoggedTest
{
private string _siteName;
private ITestOutputHelper _output;

protected E2ETestBase(ITestOutputHelper output, string siteName)
protected E2ETestBase(ITestOutputHelper output, string siteName) : base(output)
{
_output = output;
_siteName = siteName;
}

Expand Down Expand Up @@ -109,21 +108,16 @@ protected virtual Task<HttpResponseMessage> GetResponse(HttpClient client)
[CallerMemberName] string testName = null)
{
testName = $"{GetType().FullName}.{testName}";
try
using (StartLog(out var loggerFactory, testName))
{
Console.WriteLine($"Starting test {testName}");
return TestServices.RunSiteTest(
_siteName,
serverType,
runtimeFlavor,
architecture,
_output,
loggerFactory,
ValidateAsync);
}
finally
{
Console.WriteLine($"Finished test {testName}");
}
}

protected virtual async Task ValidateAsync(
Expand Down
1 change: 1 addition & 0 deletions test/FunctionalTests/FunctionalTests.csproj
Expand Up @@ -32,6 +32,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Hosting\src\Microsoft.AspNetCore.Server.IntegrationTesting\Microsoft.AspNetCore.Server.IntegrationTesting.csproj" />
<ProjectReference Include="..\..\samples\Antiforgery.Angular1\Antiforgery.Angular1.csproj" />
<ProjectReference Include="..\..\samples\Antiforgery.MvcWithAuthAndAjax\Antiforgery.MvcWithAuthAndAjax.csproj" />
<ProjectReference Include="..\..\samples\Mvc.ActionConstraintSample.Web\Mvc.ActionConstraintSample.Web.csproj" />
Expand Down
52 changes: 19 additions & 33 deletions test/FunctionalTests/TestServices.cs
@@ -1,16 +1,14 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.PlatformAbstractions;
using System;
using System.IO;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Server.IntegrationTesting.Common;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.PlatformAbstractions;
using Xunit.Abstractions;
using Xunit.Sdk;

namespace EntropyTests
Expand Down Expand Up @@ -41,40 +39,28 @@ public static void LogResponseOnFailedAssert(this ILogger logger, HttpResponseMe
ServerType serverType,
RuntimeFlavor runtimeFlavor,
RuntimeArchitecture architecture,
ITestOutputHelper xunitOutput,
ILoggerFactory loggerFactory,
Func<HttpClient, ILogger, CancellationToken, Task> validator)
{
var factory = new LoggerFactory().AddConsole().AddXunit(xunitOutput, LogLevel.Debug);
var logger = factory.CreateLogger(siteName);
var logger = loggerFactory.CreateLogger(siteName);

using (logger.BeginScope("RunSiteTest"))
var deploymentParameters = new DeploymentParameters(GetApplicationDirectory(siteName), serverType, runtimeFlavor, architecture)
{
var deploymentParameters = new DeploymentParameters(GetApplicationDirectory(siteName), serverType, runtimeFlavor, architecture)
{
SiteName = "HttpTestSite",
ServerConfigTemplateContent = serverType == ServerType.Nginx ? File.ReadAllText(Path.Combine(WorkingDirectory, "nginx.conf")) : string.Empty,
PublishApplicationBeforeDeployment = true,
TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net46" : "netcoreapp2.0",
ApplicationType = runtimeFlavor == RuntimeFlavor.Clr ? ApplicationType.Standalone : ApplicationType.Portable
};
SiteName = "HttpTestSite",
ServerConfigTemplateContent = serverType == ServerType.Nginx ? File.ReadAllText(Path.Combine(WorkingDirectory, "nginx.conf")) : string.Empty,
PublishApplicationBeforeDeployment = true,
TargetFramework = runtimeFlavor == RuntimeFlavor.Clr ? "net46" : "netcoreapp2.0",
ApplicationType = runtimeFlavor == RuntimeFlavor.Clr ? ApplicationType.Standalone : ApplicationType.Portable
};

using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, factory))
{
logger.LogInformation($"Running deployment for {siteName}:{serverType}:{runtimeFlavor}:{architecture}");
var deploymentResult = await deployer.DeployAsync();
var httpClientHandler = new HttpClientHandler();
var httpClient = new HttpClient(httpClientHandler)
{
BaseAddress = new Uri(deploymentResult.ApplicationBaseUri),
Timeout = TimeSpan.FromSeconds(10)
};
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory))
{
logger.LogInformation($"Running deployment for {siteName}:{serverType}:{runtimeFlavor}:{architecture}");
var deploymentResult = await deployer.DeployAsync();
deploymentResult.HttpClient.Timeout = TimeSpan.FromSeconds(10);

using (httpClient)
{
logger.LogInformation($"Running validation for {siteName}:{serverType}:{runtimeFlavor}:{architecture}");
await validator(httpClient, logger, deploymentResult.HostShutdownToken);
}
}
logger.LogInformation($"Running validation for {siteName}:{serverType}:{runtimeFlavor}:{architecture}");
await validator(deploymentResult.HttpClient, logger, deploymentResult.HostShutdownToken);
}
}

Expand Down

0 comments on commit 0a1df2d

Please sign in to comment.