react to aspnet/Hosting#1005 (#68)
This commit is contained in:
parent
c950e713c2
commit
50299cbac6
|
|
@ -1,6 +1,6 @@
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 15
|
# Visual Studio 15
|
||||||
VisualStudioVersion = 15.0.26228.10
|
VisualStudioVersion = 15.0.26403.0
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{49AB8AAA-8160-48DF-A18B-78F51E54E02A}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{49AB8AAA-8160-48DF-A18B-78F51E54E02A}"
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ using System.Net.Http;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||||
|
using Microsoft.AspNetCore.Server.IntegrationTesting.xunit;
|
||||||
using Microsoft.AspNetCore.Testing.xunit;
|
using Microsoft.AspNetCore.Testing.xunit;
|
||||||
using Microsoft.DotNet.PlatformAbstractions;
|
using Microsoft.DotNet.PlatformAbstractions;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
@ -15,13 +16,10 @@ using Xunit.Sdk;
|
||||||
|
|
||||||
namespace ServerComparison.FunctionalTests
|
namespace ServerComparison.FunctionalTests
|
||||||
{
|
{
|
||||||
public class HelloWorldTests
|
public class HelloWorldTests : LoggedTest
|
||||||
{
|
{
|
||||||
private readonly ITestOutputHelper _output;
|
public HelloWorldTests(ITestOutputHelper output) : base(output)
|
||||||
|
|
||||||
public HelloWorldTests(ITestOutputHelper output)
|
|
||||||
{
|
{
|
||||||
_output = output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests disabled on x86 because of https://github.com/aspnet/Hosting/issues/601
|
// Tests disabled on x86 because of https://github.com/aspnet/Hosting/issues/601
|
||||||
|
|
@ -60,13 +58,10 @@ namespace ServerComparison.FunctionalTests
|
||||||
public async Task HelloWorld(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType, [CallerMemberName] string testName = null)
|
public async Task HelloWorld(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType, [CallerMemberName] string testName = null)
|
||||||
{
|
{
|
||||||
testName = $"{testName}_{serverType}_{runtimeFlavor}_{architecture}_{applicationType}";
|
testName = $"{testName}_{serverType}_{runtimeFlavor}_{architecture}_{applicationType}";
|
||||||
var loggerFactory = TestLoggingUtilities.SetUpLogging<HelloWorldTests>(_output, testName);
|
using (StartLog(out var loggerFactory, testName))
|
||||||
var logger = loggerFactory.CreateLogger("TestHarness");
|
|
||||||
Console.WriteLine($"Starting test: {testName}");
|
|
||||||
logger.LogInformation("Starting test: {testName}", testName);
|
|
||||||
|
|
||||||
using (logger.BeginScope("HelloWorld"))
|
|
||||||
{
|
{
|
||||||
|
var logger = loggerFactory.CreateLogger("HelloWorld");
|
||||||
|
|
||||||
var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
|
var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
|
||||||
{
|
{
|
||||||
EnvironmentName = "HelloWorld", // Will pick the Start class named 'StartupHelloWorld',
|
EnvironmentName = "HelloWorld", // Will pick the Start class named 'StartupHelloWorld',
|
||||||
|
|
@ -84,13 +79,11 @@ namespace ServerComparison.FunctionalTests
|
||||||
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory))
|
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory))
|
||||||
{
|
{
|
||||||
var deploymentResult = await deployer.DeployAsync();
|
var deploymentResult = await deployer.DeployAsync();
|
||||||
var httpClientHandler = new HttpClientHandler();
|
|
||||||
var httpClient = new HttpClient(new LoggingHandler(loggerFactory, httpClientHandler)) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) };
|
|
||||||
|
|
||||||
// Request to base address and check if various parts of the body are rendered & measure the cold startup time.
|
// Request to base address and check if various parts of the body are rendered & measure the cold startup time.
|
||||||
var response = await RetryHelper.RetryRequest(() =>
|
var response = await RetryHelper.RetryRequest(() =>
|
||||||
{
|
{
|
||||||
return httpClient.GetAsync(string.Empty);
|
return deploymentResult.HttpClient.GetAsync(string.Empty);
|
||||||
}, logger, deploymentResult.HostShutdownToken);
|
}, logger, deploymentResult.HostShutdownToken);
|
||||||
|
|
||||||
var responseText = await response.Content.ReadAsStringAsync();
|
var responseText = await response.Content.ReadAsStringAsync();
|
||||||
|
|
@ -106,9 +99,6 @@ namespace ServerComparison.FunctionalTests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine($"Finished test: {testName}");
|
|
||||||
logger.LogInformation("Finished test: {testName}", testName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
using System.Net.Http;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace ServerComparison.FunctionalTests
|
|
||||||
{
|
|
||||||
internal class LoggingHandler : DelegatingHandler
|
|
||||||
{
|
|
||||||
private ILogger _logger;
|
|
||||||
|
|
||||||
public LoggingHandler(ILoggerFactory loggerFactory, HttpMessageHandler innerHandler) : base(innerHandler)
|
|
||||||
{
|
|
||||||
_logger = loggerFactory.CreateLogger<HttpClient>();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
_logger.LogDebug("Sending {method} {url}", request.Method, request.RequestUri);
|
|
||||||
var response = await base.SendAsync(request, cancellationToken);
|
|
||||||
_logger.LogDebug("Received {statusCode} {reasonPhrase} {url}", response.StatusCode, response.ReasonPhrase, request.RequestUri);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -8,6 +8,7 @@ using System.Net.Http;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||||
|
using Microsoft.AspNetCore.Server.IntegrationTesting.xunit;
|
||||||
using Microsoft.AspNetCore.Testing.xunit;
|
using Microsoft.AspNetCore.Testing.xunit;
|
||||||
using Microsoft.DotNet.PlatformAbstractions;
|
using Microsoft.DotNet.PlatformAbstractions;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
@ -17,13 +18,10 @@ using Xunit.Sdk;
|
||||||
|
|
||||||
namespace ServerComparison.FunctionalTests
|
namespace ServerComparison.FunctionalTests
|
||||||
{
|
{
|
||||||
public class NtlmAuthenticationTests
|
public class NtlmAuthenticationTests : LoggedTest
|
||||||
{
|
{
|
||||||
private readonly ITestOutputHelper _output;
|
public NtlmAuthenticationTests(ITestOutputHelper output) : base(output)
|
||||||
|
|
||||||
public NtlmAuthenticationTests(ITestOutputHelper output)
|
|
||||||
{
|
{
|
||||||
_output = output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ConditionalTheory, Trait("ServerComparison.FunctionalTests", "ServerComparison.FunctionalTests")]
|
[ConditionalTheory, Trait("ServerComparison.FunctionalTests", "ServerComparison.FunctionalTests")]
|
||||||
|
|
@ -38,13 +36,10 @@ namespace ServerComparison.FunctionalTests
|
||||||
public async Task NtlmAuthentication(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType)
|
public async Task NtlmAuthentication(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, ApplicationType applicationType)
|
||||||
{
|
{
|
||||||
var testName = $"NtlmAuthentication_{serverType}_{runtimeFlavor}_{architecture}_{applicationType}";
|
var testName = $"NtlmAuthentication_{serverType}_{runtimeFlavor}_{architecture}_{applicationType}";
|
||||||
var loggerFactory = TestLoggingUtilities.SetUpLogging<HelloWorldTests>(_output, testName);
|
using (StartLog(out var loggerFactory, testName))
|
||||||
var logger = loggerFactory.CreateLogger("TestHarness");
|
|
||||||
Console.WriteLine($"Starting test: {testName}");
|
|
||||||
logger.LogInformation("Starting test: {testName}", testName);
|
|
||||||
|
|
||||||
using (logger.BeginScope("NtlmAuthenticationTest"))
|
|
||||||
{
|
{
|
||||||
|
var logger = loggerFactory.CreateLogger("NtlmAuthenticationTest");
|
||||||
|
|
||||||
var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
|
var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
|
||||||
{
|
{
|
||||||
EnvironmentName = "NtlmAuthentication", // Will pick the Start class named 'StartupNtlmAuthentication'
|
EnvironmentName = "NtlmAuthentication", // Will pick the Start class named 'StartupNtlmAuthentication'
|
||||||
|
|
@ -62,8 +57,7 @@ namespace ServerComparison.FunctionalTests
|
||||||
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory))
|
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory))
|
||||||
{
|
{
|
||||||
var deploymentResult = await deployer.DeployAsync();
|
var deploymentResult = await deployer.DeployAsync();
|
||||||
var httpClientHandler = new HttpClientHandler();
|
var httpClient = deploymentResult.HttpClient;
|
||||||
var httpClient = new HttpClient(new LoggingHandler(loggerFactory, httpClientHandler)) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) };
|
|
||||||
|
|
||||||
// Request to base address and check if various parts of the body are rendered & measure the cold startup time.
|
// Request to base address and check if various parts of the body are rendered & measure the cold startup time.
|
||||||
var response = await RetryHelper.RetryRequest(() =>
|
var response = await RetryHelper.RetryRequest(() =>
|
||||||
|
|
@ -109,8 +103,9 @@ namespace ServerComparison.FunctionalTests
|
||||||
Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
|
Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
|
||||||
|
|
||||||
logger.LogInformation("Enabling Default Credentials");
|
logger.LogInformation("Enabling Default Credentials");
|
||||||
httpClientHandler = new HttpClientHandler() { UseDefaultCredentials = true };
|
|
||||||
httpClient = new HttpClient(httpClientHandler) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) };
|
// Change the http client to one that uses default credentials
|
||||||
|
httpClient = deploymentResult.CreateHttpClient(new HttpClientHandler() { UseDefaultCredentials = true });
|
||||||
|
|
||||||
logger.LogInformation("Testing /AutoForbid");
|
logger.LogInformation("Testing /AutoForbid");
|
||||||
response = await httpClient.GetAsync("/AutoForbid");
|
response = await httpClient.GetAsync("/AutoForbid");
|
||||||
|
|
@ -155,9 +150,6 @@ namespace ServerComparison.FunctionalTests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine($"Finished test: {testName}");
|
|
||||||
logger.LogInformation("Finished test: {testName}", testName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ using System.Net.Http;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||||
|
using Microsoft.AspNetCore.Server.IntegrationTesting.xunit;
|
||||||
using Microsoft.AspNetCore.Testing.xunit;
|
using Microsoft.AspNetCore.Testing.xunit;
|
||||||
using Microsoft.DotNet.PlatformAbstractions;
|
using Microsoft.DotNet.PlatformAbstractions;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
@ -21,15 +22,13 @@ using Xunit.Sdk;
|
||||||
|
|
||||||
namespace ServerComparison.FunctionalTests
|
namespace ServerComparison.FunctionalTests
|
||||||
{
|
{
|
||||||
public class ResponseCompressionTests
|
public class ResponseCompressionTests : LoggedTest
|
||||||
{
|
{
|
||||||
// NGinx's default min size is 20 bytes
|
// NGinx's default min size is 20 bytes
|
||||||
private static readonly string HelloWorldBody = "Hello World;" + new string('a', 20);
|
private static readonly string HelloWorldBody = "Hello World;" + new string('a', 20);
|
||||||
private readonly ITestOutputHelper _output;
|
|
||||||
|
|
||||||
public ResponseCompressionTests(ITestOutputHelper output)
|
public ResponseCompressionTests(ITestOutputHelper output) : base(output)
|
||||||
{
|
{
|
||||||
_output = output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
|
|
@ -127,13 +126,10 @@ namespace ServerComparison.FunctionalTests
|
||||||
public async Task ResponseCompression(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, Func<HttpClient, ILogger, Task> scenario, ApplicationType applicationType, bool hostCompression, [CallerMemberName] string testName = null)
|
public async Task ResponseCompression(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, Func<HttpClient, ILogger, Task> scenario, ApplicationType applicationType, bool hostCompression, [CallerMemberName] string testName = null)
|
||||||
{
|
{
|
||||||
testName = $"{testName}_{serverType}_{runtimeFlavor}_{architecture}_{applicationType}";
|
testName = $"{testName}_{serverType}_{runtimeFlavor}_{architecture}_{applicationType}";
|
||||||
var loggerFactory = TestLoggingUtilities.SetUpLogging<ResponseCompressionTests>(_output, testName);
|
using (StartLog(out var loggerFactory, testName))
|
||||||
var logger = loggerFactory.CreateLogger("TestHarness");
|
|
||||||
Console.WriteLine($"Starting test: {testName}");
|
|
||||||
logger.LogInformation("Starting test: {testName}", testName);
|
|
||||||
|
|
||||||
using (logger.BeginScope("ResponseCompression"))
|
|
||||||
{
|
{
|
||||||
|
var logger = loggerFactory.CreateLogger("ResponseCompression");
|
||||||
|
|
||||||
var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
|
var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
|
||||||
{
|
{
|
||||||
EnvironmentName = "ResponseCompression",
|
EnvironmentName = "ResponseCompression",
|
||||||
|
|
@ -155,7 +151,7 @@ namespace ServerComparison.FunctionalTests
|
||||||
var deploymentResult = await deployer.DeployAsync();
|
var deploymentResult = await deployer.DeployAsync();
|
||||||
var httpClientHandler = new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.None };
|
var httpClientHandler = new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.None };
|
||||||
Assert.True(httpClientHandler.SupportsAutomaticDecompression);
|
Assert.True(httpClientHandler.SupportsAutomaticDecompression);
|
||||||
var httpClient = new HttpClient(new LoggingHandler(loggerFactory, httpClientHandler)) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) };
|
var httpClient = deploymentResult.CreateHttpClient(httpClientHandler);
|
||||||
|
|
||||||
// Request to base address and check if various parts of the body are rendered & measure the cold startup time.
|
// Request to base address and check if various parts of the body are rendered & measure the cold startup time.
|
||||||
var response = await RetryHelper.RetryRequest(() =>
|
var response = await RetryHelper.RetryRequest(() =>
|
||||||
|
|
@ -178,9 +174,6 @@ namespace ServerComparison.FunctionalTests
|
||||||
await scenario(httpClient, logger);
|
await scenario(httpClient, logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine($"Finished test: {testName}");
|
|
||||||
logger.LogInformation("Finished test: {testName}", testName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task CheckNoCompressionAsync(HttpClient client, ILogger logger)
|
private static async Task CheckNoCompressionAsync(HttpClient client, ILogger logger)
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ using System.Net.Http;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||||
|
using Microsoft.AspNetCore.Server.IntegrationTesting.xunit;
|
||||||
using Microsoft.AspNetCore.Testing.xunit;
|
using Microsoft.AspNetCore.Testing.xunit;
|
||||||
using Microsoft.DotNet.PlatformAbstractions;
|
using Microsoft.DotNet.PlatformAbstractions;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
@ -18,13 +19,10 @@ using Xunit.Sdk;
|
||||||
|
|
||||||
namespace ServerComparison.FunctionalTests
|
namespace ServerComparison.FunctionalTests
|
||||||
{
|
{
|
||||||
public class ResponseTests
|
public class ResponseTests : LoggedTest
|
||||||
{
|
{
|
||||||
private readonly ITestOutputHelper _output;
|
public ResponseTests(ITestOutputHelper output) : base(output)
|
||||||
|
|
||||||
public ResponseTests(ITestOutputHelper output)
|
|
||||||
{
|
{
|
||||||
_output = output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ConditionalTheory]
|
[ConditionalTheory]
|
||||||
|
|
@ -165,13 +163,10 @@ namespace ServerComparison.FunctionalTests
|
||||||
public async Task ResponseFormats(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, Func<HttpClient, ILogger, Task> scenario, ApplicationType applicationType, [CallerMemberName] string testName = null)
|
public async Task ResponseFormats(ServerType serverType, RuntimeFlavor runtimeFlavor, RuntimeArchitecture architecture, Func<HttpClient, ILogger, Task> scenario, ApplicationType applicationType, [CallerMemberName] string testName = null)
|
||||||
{
|
{
|
||||||
testName = $"{testName}_{serverType}_{runtimeFlavor}_{architecture}_{applicationType}";
|
testName = $"{testName}_{serverType}_{runtimeFlavor}_{architecture}_{applicationType}";
|
||||||
var loggerFactory = TestLoggingUtilities.SetUpLogging<HelloWorldTests>(_output, testName);
|
using (StartLog(out var loggerFactory, testName))
|
||||||
var logger = loggerFactory.CreateLogger("TestHarness");
|
|
||||||
Console.WriteLine($"Starting test: {testName}");
|
|
||||||
logger.LogInformation("Starting test: {testName}", testName);
|
|
||||||
|
|
||||||
using (logger.BeginScope("ResponseFormats"))
|
|
||||||
{
|
{
|
||||||
|
var logger = loggerFactory.CreateLogger("ResponseFormats");
|
||||||
|
|
||||||
var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
|
var deploymentParameters = new DeploymentParameters(Helpers.GetApplicationPath(applicationType), serverType, runtimeFlavor, architecture)
|
||||||
{
|
{
|
||||||
EnvironmentName = "Responses",
|
EnvironmentName = "Responses",
|
||||||
|
|
@ -189,13 +184,11 @@ namespace ServerComparison.FunctionalTests
|
||||||
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory))
|
using (var deployer = ApplicationDeployerFactory.Create(deploymentParameters, loggerFactory))
|
||||||
{
|
{
|
||||||
var deploymentResult = await deployer.DeployAsync();
|
var deploymentResult = await deployer.DeployAsync();
|
||||||
var httpClientHandler = new HttpClientHandler();
|
|
||||||
var httpClient = new HttpClient(new LoggingHandler(loggerFactory, httpClientHandler)) { BaseAddress = new Uri(deploymentResult.ApplicationBaseUri) };
|
|
||||||
|
|
||||||
// Request to base address and check if various parts of the body are rendered & measure the cold startup time.
|
// Request to base address and check if various parts of the body are rendered & measure the cold startup time.
|
||||||
var response = await RetryHelper.RetryRequest(() =>
|
var response = await RetryHelper.RetryRequest(() =>
|
||||||
{
|
{
|
||||||
return httpClient.GetAsync(string.Empty);
|
return deploymentResult.HttpClient.GetAsync(string.Empty);
|
||||||
}, logger, deploymentResult.HostShutdownToken);
|
}, logger, deploymentResult.HostShutdownToken);
|
||||||
|
|
||||||
var responseText = await response.Content.ReadAsStringAsync();
|
var responseText = await response.Content.ReadAsStringAsync();
|
||||||
|
|
@ -210,12 +203,9 @@ namespace ServerComparison.FunctionalTests
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
await scenario(httpClient, logger);
|
await scenario(deploymentResult.HttpClient, logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine($"Finished test: {testName}");
|
|
||||||
logger.LogInformation("Finished test: {testName}", testName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task CheckContentLengthAsync(HttpClient client, ILogger logger)
|
private static async Task CheckContentLengthAsync(HttpClient client, ILogger logger)
|
||||||
|
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Serilog;
|
|
||||||
using Xunit.Abstractions;
|
|
||||||
|
|
||||||
namespace ServerComparison.FunctionalTests
|
|
||||||
{
|
|
||||||
public static class TestLoggingUtilities
|
|
||||||
{
|
|
||||||
public static readonly string TestOutputRoot = Environment.GetEnvironmentVariable("ASPNETCORE_TEST_LOG_DIR");
|
|
||||||
|
|
||||||
public static ILoggerFactory SetUpLogging<TTestClass>(ITestOutputHelper output, [CallerMemberName] string testName = null)
|
|
||||||
{
|
|
||||||
var loggerFactory = new LoggerFactory();
|
|
||||||
loggerFactory.AddXunit(output, LogLevel.Debug);
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(TestOutputRoot))
|
|
||||||
{
|
|
||||||
var testClass = typeof(TTestClass).GetTypeInfo();
|
|
||||||
var testOutputDir = Path.Combine(TestOutputRoot, testClass.Assembly.GetName().Name, testClass.FullName);
|
|
||||||
if (!Directory.Exists(testOutputDir))
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(testOutputDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
var testOutputFile = Path.Combine(testOutputDir, $"{testName}.log");
|
|
||||||
|
|
||||||
if (File.Exists(testOutputFile))
|
|
||||||
{
|
|
||||||
File.Delete(testOutputFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
var serilogger = new LoggerConfiguration()
|
|
||||||
.Enrich.FromLogContext()
|
|
||||||
.MinimumLevel.Verbose()
|
|
||||||
.WriteTo.File(testOutputFile, flushToDiskInterval: TimeSpan.FromSeconds(1))
|
|
||||||
.CreateLogger();
|
|
||||||
loggerFactory.AddSerilog(serilogger);
|
|
||||||
}
|
|
||||||
|
|
||||||
return loggerFactory;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue