port dotnet/corefx#17444 to WebSockets (#162)
This commit is contained in:
parent
9c2b7b7842
commit
e25a2eced8
|
|
@ -5,6 +5,7 @@ env:
|
|||
global:
|
||||
- DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
|
||||
- DOTNET_CLI_TELEMETRY_OPTOUT: 1
|
||||
- AUTOBAHN_SUITES_LOG: 1
|
||||
mono: none
|
||||
python:
|
||||
- "2.7"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.26228.4
|
||||
VisualStudioVersion = 15.0.26411.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2C7947A5-9FBD-4267-97C1-2D726D7B3BAF}"
|
||||
EndProject
|
||||
|
|
@ -25,6 +25,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EchoApp", "samples\EchoApp\
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutobahnTestApp", "test\AutobahnTestApp\AutobahnTestApp.csproj", "{150DF5A8-87C6-42F7-8886-CE07BFD02FD2}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{92CE12E6-E127-433B-96D3-164C0113EA17}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
build\common.props = build\common.props
|
||||
build\dependencies.props = build\dependencies.props
|
||||
build\Key.snk = build\Key.snk
|
||||
build\repo.props = build\repo.props
|
||||
build\repo.targets = build\repo.targets
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
init:
|
||||
- git config --global core.autocrlf true
|
||||
environment:
|
||||
AUTOBAHN_SUITES_LOG: 1
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project>
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<AspNetCoreVersion>2.0.0-*</AspNetCoreVersion>
|
||||
<AspNetCoreLabsVersion>0.3.0-*</AspNetCoreLabsVersion>
|
||||
<AspNetCoreIntegrationTestingVersion>0.4.0-*</AspNetCoreIntegrationTestingVersion>
|
||||
<AspNetCoreModuleVersion>1.0.0-*</AspNetCoreModuleVersion>
|
||||
<CoreFxVersion>4.3.0</CoreFxVersion>
|
||||
<InternalAspNetCoreSdkVersion>2.0.0-*</InternalAspNetCoreSdkVersion>
|
||||
|
|
|
|||
|
|
@ -732,9 +732,11 @@ namespace System.Net.WebSockets
|
|||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
throw _state == WebSocketState.Aborted ?
|
||||
new WebSocketException(WebSocketError.InvalidState, SR.Format(SR.net_WebSockets_InvalidState_ClosedOrAborted, "System.Net.WebSockets.InternalClientWebSocket", "Aborted"), exc) :
|
||||
new WebSocketException(WebSocketError.ConnectionClosedPrematurely, exc);
|
||||
if (_state == WebSocketState.Aborted)
|
||||
{
|
||||
throw new OperationCanceledException(nameof(WebSocketState.Aborted), exc);
|
||||
}
|
||||
throw new WebSocketException(WebSocketError.ConnectionClosedPrematurely, exc);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ 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;
|
||||
|
|
@ -106,8 +107,8 @@ namespace Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn
|
|||
ServerConfigTemplateContent = (server == ServerType.IISExpress) ? File.ReadAllText(configPath) : null,
|
||||
};
|
||||
|
||||
var deployer = ApplicationDeployerFactory.Create(parameters, logger);
|
||||
var result = deployer.Deploy();
|
||||
var deployer = ApplicationDeployerFactory.Create(parameters, _loggerFactory);
|
||||
var result = await deployer.DeployAsync();
|
||||
_deployers.Add(deployer);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,77 +1,77 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting;
|
||||
using Microsoft.AspNetCore.Server.IntegrationTesting.xunit;
|
||||
using Microsoft.AspNetCore.Testing.xunit;
|
||||
using Microsoft.AspNetCore.WebSockets.ConformanceTest.Autobahn;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Microsoft.AspNetCore.WebSockets.ConformanceTest
|
||||
{
|
||||
public class AutobahnTests
|
||||
public class AutobahnTests : LoggedTest
|
||||
{
|
||||
public AutobahnTests(ITestOutputHelper output) : base(output)
|
||||
{
|
||||
}
|
||||
|
||||
// Skip if wstest is not installed for now, see https://github.com/aspnet/WebSockets/issues/95
|
||||
// We will enable Wstest on every build once we've gotten the necessary infrastructure sorted out :).
|
||||
[ConditionalFact]
|
||||
[SkipIfWsTestNotPresent]
|
||||
public async Task AutobahnTestSuite()
|
||||
{
|
||||
var reportDir = Environment.GetEnvironmentVariable("AUTOBAHN_SUITES_REPORT_DIR");
|
||||
var outDir = !string.IsNullOrEmpty(reportDir) ?
|
||||
reportDir :
|
||||
Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "autobahnreports");
|
||||
|
||||
if (Directory.Exists(outDir))
|
||||
using (StartLog(out var loggerFactory))
|
||||
{
|
||||
Directory.Delete(outDir, recursive: true);
|
||||
}
|
||||
var reportDir = Environment.GetEnvironmentVariable("AUTOBAHN_SUITES_REPORT_DIR");
|
||||
var outDir = !string.IsNullOrEmpty(reportDir) ?
|
||||
reportDir :
|
||||
Path.Combine(PlatformServices.Default.Application.ApplicationBasePath, "autobahnreports");
|
||||
|
||||
outDir = outDir.Replace("\\", "\\\\");
|
||||
|
||||
// 9.* is Limits/Performance which is VERY SLOW; 12.*/13.* are compression which we don't implement
|
||||
var spec = new AutobahnSpec(outDir)
|
||||
.IncludeCase("*")
|
||||
.ExcludeCase("9.*", "12.*", "13.*");
|
||||
|
||||
var loggerFactory = new LoggerFactory(); // No logging by default! It's very loud...
|
||||
|
||||
if (string.Equals(Environment.GetEnvironmentVariable("AUTOBAHN_SUITES_LOG"), "1", StringComparison.Ordinal))
|
||||
{
|
||||
loggerFactory.AddConsole();
|
||||
}
|
||||
|
||||
var cts = new CancellationTokenSource();
|
||||
cts.CancelAfter(TimeSpan.FromMinutes(5)); // These tests generally complete in just over 1 minute.
|
||||
|
||||
AutobahnResult result;
|
||||
using (var tester = new AutobahnTester(loggerFactory, spec))
|
||||
{
|
||||
await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token);
|
||||
|
||||
// Windows-only WebListener tests, and Kestrel SSL tests (due to: https://github.com/aspnet/WebSockets/issues/102)
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
if (Directory.Exists(outDir))
|
||||
{
|
||||
await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: true, environment: "ManagedSockets", cancellationToken: cts.Token);
|
||||
|
||||
if (IsWindows8OrHigher())
|
||||
{
|
||||
// WebListener occasionally gives a non-strict response on 3.2. IIS Express seems to have the same behavior. Wonder if it's related to HttpSys?
|
||||
// For now, just allow the non-strict response, it's not a failure.
|
||||
await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token);
|
||||
}
|
||||
Directory.Delete(outDir, recursive: true);
|
||||
}
|
||||
|
||||
result = await tester.Run(cts.Token);
|
||||
tester.Verify(result);
|
||||
}
|
||||
outDir = outDir.Replace("\\", "\\\\");
|
||||
|
||||
// If it hasn't been cancelled yet, cancel the token just to be sure
|
||||
cts.Cancel();
|
||||
// 9.* is Limits/Performance which is VERY SLOW; 12.*/13.* are compression which we don't implement
|
||||
var spec = new AutobahnSpec(outDir)
|
||||
.IncludeCase("*")
|
||||
.ExcludeCase("9.*", "12.*", "13.*");
|
||||
|
||||
var cts = new CancellationTokenSource();
|
||||
cts.CancelAfter(TimeSpan.FromMinutes(5)); // These tests generally complete in just over 1 minute.
|
||||
|
||||
AutobahnResult result;
|
||||
using (var tester = new AutobahnTester(loggerFactory, spec))
|
||||
{
|
||||
await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token);
|
||||
|
||||
// Windows-only WebListener tests, and Kestrel SSL tests (due to: https://github.com/aspnet/WebSockets/issues/102)
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
await tester.DeployTestAndAddToSpec(ServerType.Kestrel, ssl: true, environment: "ManagedSockets", cancellationToken: cts.Token);
|
||||
|
||||
if (IsWindows8OrHigher())
|
||||
{
|
||||
// WebListener occasionally gives a non-strict response on 3.2. IIS Express seems to have the same behavior. Wonder if it's related to HttpSys?
|
||||
// For now, just allow the non-strict response, it's not a failure.
|
||||
await tester.DeployTestAndAddToSpec(ServerType.WebListener, ssl: false, environment: "ManagedSockets", cancellationToken: cts.Token);
|
||||
}
|
||||
}
|
||||
|
||||
result = await tester.Run(cts.Token);
|
||||
tester.Verify(result);
|
||||
}
|
||||
|
||||
// If it hasn't been cancelled yet, cancel the token just to be sure
|
||||
cts.Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsWindows8OrHigher()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IntegrationTesting" Version="$(AspNetCoreLabsVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.IntegrationTesting" Version="$(AspNetCoreIntegrationTestingVersion)" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(AspNetCoreVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(AspNetCoreVersion)" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue