From d8b172445482a22332cb5ac556d0edadd3324a9a Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Tue, 18 Apr 2017 11:53:45 -0700 Subject: [PATCH] improve logging of Autobahn tests (#166) --- test/AutobahnTestApp/Program.cs | 11 +++++++++++ test/AutobahnTestApp/Startup.cs | 3 ++- .../Autobahn/AutobahnTester.cs | 1 - 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/test/AutobahnTestApp/Program.cs b/test/AutobahnTestApp/Program.cs index 9349f21aab..89a4d9ec4a 100644 --- a/test/AutobahnTestApp/Program.cs +++ b/test/AutobahnTestApp/Program.cs @@ -3,6 +3,7 @@ using System.IO; using System.Net; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; namespace AutobahnTestApp { @@ -14,7 +15,12 @@ namespace AutobahnTestApp .AddCommandLine(args) .Build(); + var loggerFactory = new LoggerFactory() + .AddConsole(); + var logger = loggerFactory.CreateLogger(); + var builder = new WebHostBuilder() + .UseLoggerFactory(loggerFactory) .UseConfiguration(config) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() @@ -22,12 +28,14 @@ namespace AutobahnTestApp if (string.Equals(builder.GetSetting("server"), "Microsoft.AspNetCore.Server.HttpSys", System.StringComparison.Ordinal)) { + logger.LogInformation("Using HttpSys server"); builder.UseHttpSys(); } else if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) { // ANCM is hosting the process. // The port will not yet be configured at this point, but will also not require HTTPS. + logger.LogInformation("Detected ANCM, using Kestrel"); builder.UseKestrel(); } else @@ -36,6 +44,8 @@ namespace AutobahnTestApp var urls = builder.GetSetting(WebHostDefaults.ServerUrlsKey) ?? builder.GetSetting("server.urls"); builder.UseSetting(WebHostDefaults.ServerUrlsKey, string.Empty); + logger.LogInformation("Using Kestrel, URL: {url}", urls); + if (urls.Contains(";")) { throw new NotSupportedException("This test app does not support multiple endpoints."); @@ -50,6 +60,7 @@ namespace AutobahnTestApp if (uri.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase)) { var certPath = Path.Combine(AppContext.BaseDirectory, "TestResources", "testCert.pfx"); + logger.LogInformation("Using SSL with certificate: {certPath}", certPath); listenOptions.UseHttps(certPath, "testPassword"); } }); diff --git a/test/AutobahnTestApp/Startup.cs b/test/AutobahnTestApp/Startup.cs index a7005b2247..671d503968 100644 --- a/test/AutobahnTestApp/Startup.cs +++ b/test/AutobahnTestApp/Startup.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Features; using Microsoft.Extensions.Logging; namespace AutobahnTestApp @@ -17,10 +16,12 @@ namespace AutobahnTestApp { app.UseWebSockets(); + var logger = loggerFactory.CreateLogger(); app.Use(async (context, next) => { if (context.WebSockets.IsWebSocketRequest) { + logger.LogInformation("Received WebSocket request"); var webSocket = await context.WebSockets.AcceptWebSocketAsync(); await Echo(webSocket); } diff --git a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs index 50ac782996..52fdae6b7a 100644 --- a/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs +++ b/test/Microsoft.AspNetCore.WebSockets.ConformanceTest/Autobahn/AutobahnTester.cs @@ -7,7 +7,6 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Server.IntegrationTesting; -using Microsoft.AspNetCore.Server.IntegrationTesting.xunit; using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; using Xunit;