diff --git a/Entropy.sln b/Entropy.sln index bf875d08..8204c43d 100644 --- a/Entropy.sln +++ b/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 @@ -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 @@ -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 diff --git a/test/FunctionalTests/E2ETestBase.cs b/test/FunctionalTests/E2ETestBase.cs index ab951035..e4964f32 100644 --- a/test/FunctionalTests/E2ETestBase.cs +++ b/test/FunctionalTests/E2ETestBase.cs @@ -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; } @@ -109,21 +108,16 @@ protected virtual Task 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( diff --git a/test/FunctionalTests/FunctionalTests.csproj b/test/FunctionalTests/FunctionalTests.csproj index 6456abcb..8f12b6ab 100644 --- a/test/FunctionalTests/FunctionalTests.csproj +++ b/test/FunctionalTests/FunctionalTests.csproj @@ -32,6 +32,7 @@ + diff --git a/test/FunctionalTests/TestServices.cs b/test/FunctionalTests/TestServices.cs index e18a2dda..884eab80 100644 --- a/test/FunctionalTests/TestServices.cs +++ b/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 @@ -41,40 +39,28 @@ public static void LogResponseOnFailedAssert(this ILogger logger, HttpResponseMe ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, - ITestOutputHelper xunitOutput, + ILoggerFactory loggerFactory, Func 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); } }