change autobahn tests to use dynamic port (#167)

This commit is contained in:
Andrew Stanton-Nurse 2017-04-14 10:48:44 -07:00 committed by GitHub
parent bad5d7c8f7
commit a9a8f45158
2 changed files with 3 additions and 8 deletions

View File

@ -27,7 +27,7 @@ namespace AutobahnTestApp
else if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) else if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT")))
{ {
// ANCM is hosting the process. // ANCM is hosting the process.
// The port will not yet be configure at this point, but will also not require HTTPS. // The port will not yet be configured at this point, but will also not require HTTPS.
builder.UseKestrel(); builder.UseKestrel();
} }
else else

View File

@ -16,7 +16,6 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn
{ {
public class AutobahnTester : IDisposable public class AutobahnTester : IDisposable
{ {
private int _nextPort;
private readonly List<IApplicationDeployer> _deployers = new List<IApplicationDeployer>(); private readonly List<IApplicationDeployer> _deployers = new List<IApplicationDeployer>();
private readonly List<AutobahnExpectations> _expectations = new List<AutobahnExpectations>(); private readonly List<AutobahnExpectations> _expectations = new List<AutobahnExpectations>();
private readonly ILoggerFactory _loggerFactory; private readonly ILoggerFactory _loggerFactory;
@ -24,11 +23,8 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn
public AutobahnSpec Spec { get; } public AutobahnSpec Spec { get; }
public AutobahnTester(ILoggerFactory loggerFactory, AutobahnSpec baseSpec) : this(7000, loggerFactory, baseSpec) { } public AutobahnTester(ILoggerFactory loggerFactory, AutobahnSpec baseSpec)
public AutobahnTester(int startPort, ILoggerFactory loggerFactory, AutobahnSpec baseSpec)
{ {
_nextPort = startPort;
_loggerFactory = loggerFactory; _loggerFactory = loggerFactory;
_logger = _loggerFactory.CreateLogger("AutobahnTester"); _logger = _loggerFactory.CreateLogger("AutobahnTester");
@ -89,8 +85,7 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn
public async Task DeployTestAndAddToSpec(ServerType server, bool ssl, string environment, CancellationToken cancellationToken, Action<AutobahnExpectations> expectationConfig = null) public async Task DeployTestAndAddToSpec(ServerType server, bool ssl, string environment, CancellationToken cancellationToken, Action<AutobahnExpectations> expectationConfig = null)
{ {
var port = Interlocked.Increment(ref _nextPort); var baseUrl = ssl ? "https://localhost:0" : "http://localhost:0";
var baseUrl = ssl ? $"https://localhost:{port}" : $"http://localhost:{port}";
var sslNamePart = ssl ? "SSL" : "NoSSL"; var sslNamePart = ssl ? "SSL" : "NoSSL";
var name = $"{server}|{sslNamePart}|{environment}"; var name = $"{server}|{sslNamePart}|{environment}";
var logger = _loggerFactory.CreateLogger($"AutobahnTestApp:{server}:{sslNamePart}:{environment}"); var logger = _loggerFactory.CreateLogger($"AutobahnTestApp:{server}:{sslNamePart}:{environment}");