[2.1.1] Gracefully handle disposing while writing (#2180) (#2355)

This commit is contained in:
Andrew Stanton-Nurse 2018-05-30 10:33:31 -07:00 committed by GitHub
parent 0452f460c6
commit c976d0aa6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 310 additions and 134 deletions

View File

@ -83,7 +83,16 @@ namespace System.IO.Pipelines
return default;
async ValueTask WriteSlowAsync(ValueTask<FlushResult> flushTask) => await flushTask;
async ValueTask WriteSlowAsync(ValueTask<FlushResult> flushTask)
{
var flushResult = await flushTask;
// Cancellation can be triggered by PipeWriter.CancelPendingFlush
if (flushResult.IsCanceled)
{
throw new OperationCanceledException();
}
}
}
public void Reset()

View File

@ -178,7 +178,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
public async Task DisposeAsync(bool closeGracefully = false)
{
var disposeTask = Task.CompletedTask;
Task disposeTask;
await StateLock.WaitAsync();
try
@ -267,6 +267,9 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
{
Log.ShuttingDownTransportAndApplication(_logger, TransportType);
// Cancel any pending flushes from back pressure
Application?.Output.CancelPendingFlush();
// Shutdown both sides and wait for nothing
Transport?.Output.Complete(applicationTask.Exception?.InnerException);
Application?.Output.Complete(transportTask.Exception?.InnerException);

View File

@ -11,10 +11,10 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
private static class Log
{
private static readonly Action<ILogger, string, Exception> _connectionDisposed =
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(1, "ConnectionDisposed"), "Connection Id {TransportConnectionId} was disposed.");
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(1, "ConnectionDisposed"), "Connection {TransportConnectionId} was disposed.");
private static readonly Action<ILogger, string, string, Exception> _connectionAlreadyActive =
LoggerMessage.Define<string, string>(LogLevel.Debug, new EventId(2, "ConnectionAlreadyActive"), "Connection Id {TransportConnectionId} is already active via {RequestId}.");
LoggerMessage.Define<string, string>(LogLevel.Debug, new EventId(2, "ConnectionAlreadyActive"), "Connection {TransportConnectionId} is already active via {RequestId}.");
private static readonly Action<ILogger, string, string, Exception> _pollCanceled =
LoggerMessage.Define<string, string>(LogLevel.Trace, new EventId(3, "PollCanceled"), "Previous poll canceled for {TransportConnectionId} on {RequestId}.");
@ -46,6 +46,9 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
private static readonly Action<ILogger, Exception> _terminatingConnection =
LoggerMessage.Define(LogLevel.Trace, new EventId(12, "TerminatingConection"), "Terminating Long Polling connection due to a DELETE request.");
private static readonly Action<ILogger, string, Exception> _connectionDisposedWhileWriteInProgress =
LoggerMessage.Define<string>(LogLevel.Debug, new EventId(13, "ConnectionDisposedWhileWriteInProgress"), "Connection {TransportConnectionId} was disposed while a write was in progress.");
public static void ConnectionDisposed(ILogger logger, string connectionId)
{
_connectionDisposed(logger, connectionId, null);
@ -105,6 +108,11 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
{
_terminatingConnection(logger, null);
}
public static void ConnectionDisposedWhileWriteInProgress(ILogger logger, string connectionId, Exception ex)
{
_connectionDisposedWhileWriteInProgress(logger, connectionId, ex);
}
}
}
}

View File

@ -479,12 +479,40 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal
return;
}
await context.Request.Body.CopyToAsync(connection.ApplicationStream, bufferSize);
try
{
try
{
await context.Request.Body.CopyToAsync(connection.ApplicationStream, bufferSize);
}
catch (InvalidOperationException ex)
{
// PipeWriter will throw an error if it is written to while dispose is in progress and the writer has been completed
// Dispose isn't taking WriteLock because it could be held because of backpressure, and calling CancelPendingFlush
// then taking the lock introduces a race condition that could lead to a deadlock
Log.ConnectionDisposedWhileWriteInProgress(_logger, connection.ConnectionId, ex);
Log.ReceivedBytes(_logger, connection.ApplicationStream.Length);
context.Response.StatusCode = StatusCodes.Status404NotFound;
context.Response.ContentType = "text/plain";
return;
}
catch (OperationCanceledException)
{
// CancelPendingFlush has canceled pending writes caused by backpresure
Log.ConnectionDisposed(_logger, connection.ConnectionId);
// Clear the amount of read bytes so logging is accurate
connection.ApplicationStream.Reset();
context.Response.StatusCode = StatusCodes.Status404NotFound;
context.Response.ContentType = "text/plain";
return;
}
Log.ReceivedBytes(_logger, connection.ApplicationStream.Length);
}
finally
{
// Clear the amount of read bytes so logging is accurate
connection.ApplicationStream.Reset();
}
}
finally
{

View File

@ -41,7 +41,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task NegotiateReservesConnectionIdAndReturnsIt()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var dispatcher = new HttpConnectionDispatcher(manager, loggerFactory);
@ -64,7 +64,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task CheckThatThresholdValuesAreEnforced()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var dispatcher = new HttpConnectionDispatcher(manager, loggerFactory);
@ -102,7 +102,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[InlineData(HttpTransportType.ServerSentEvents)]
public async Task CheckThatThresholdValuesAreEnforcedWithSends(HttpTransportType transportType)
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var dispatcher = new HttpConnectionDispatcher(manager, loggerFactory);
@ -154,7 +154,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[InlineData(HttpTransportType.LongPolling | HttpTransportType.WebSockets)]
public async Task NegotiateReturnsAvailableTransportsAfterFilteringByOptions(HttpTransportType transports)
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var dispatcher = new HttpConnectionDispatcher(manager, loggerFactory);
@ -188,7 +188,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[InlineData(HttpTransportType.LongPolling)]
public async Task EndpointsThatAcceptConnectionId404WhenUnknownConnectionIdProvided(HttpTransportType transportType)
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var dispatcher = new HttpConnectionDispatcher(manager, loggerFactory);
@ -225,7 +225,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task EndpointsThatAcceptConnectionId404WhenUnknownConnectionIdProvidedForPost()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var dispatcher = new HttpConnectionDispatcher(manager, loggerFactory);
@ -260,7 +260,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task PostNotAllowedForWebSocketConnections()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var dispatcher = new HttpConnectionDispatcher(manager, loggerFactory);
@ -297,7 +297,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task PostReturns404IfConnectionDisposed()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var dispatcher = new HttpConnectionDispatcher(manager, loggerFactory);
@ -335,7 +335,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[InlineData(HttpTransportType.WebSockets)]
public async Task TransportEndingGracefullyWaitsOnApplication(HttpTransportType transportType)
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var dispatcher = new HttpConnectionDispatcher(manager, loggerFactory);
@ -396,7 +396,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task TransportEndingGracefullyWaitsOnApplicationLongPolling()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var dispatcher = new HttpConnectionDispatcher(manager, loggerFactory);
@ -459,7 +459,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[InlineData(HttpTransportType.ServerSentEvents)]
public async Task PostSendsToConnection(HttpTransportType transportType)
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var dispatcher = new HttpConnectionDispatcher(manager, loggerFactory);
@ -508,7 +508,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[InlineData(HttpTransportType.ServerSentEvents)]
public async Task PostSendsToConnectionInParallel(HttpTransportType transportType)
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var dispatcher = new HttpConnectionDispatcher(manager, loggerFactory);
@ -593,7 +593,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task HttpContextFeatureForLongpollingWorksBetweenPolls()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var dispatcher = new HttpConnectionDispatcher(manager, loggerFactory);
@ -690,7 +690,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[InlineData(HttpTransportType.LongPolling)]
public async Task EndpointsThatRequireConnectionId400WhenNoConnectionIdProvided(HttpTransportType transportType)
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var dispatcher = new HttpConnectionDispatcher(manager, loggerFactory);
@ -722,7 +722,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task EndpointsThatRequireConnectionId400WhenNoConnectionIdProvidedForPost()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var dispatcher = new HttpConnectionDispatcher(manager, loggerFactory);
@ -754,7 +754,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[InlineData(HttpTransportType.ServerSentEvents, 404)]
public async Task EndPointThatOnlySupportsLongPollingRejectsOtherTransports(HttpTransportType transportType, int status)
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
await CheckTransportSupported(HttpTransportType.LongPolling, transportType, status, loggerFactory);
}
@ -766,7 +766,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[InlineData(HttpTransportType.LongPolling, 404)]
public async Task EndPointThatOnlySupportsSSERejectsOtherTransports(HttpTransportType transportType, int status)
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
await CheckTransportSupported(HttpTransportType.ServerSentEvents, transportType, status, loggerFactory);
}
@ -778,7 +778,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[InlineData(HttpTransportType.LongPolling, 404)]
public async Task EndPointThatOnlySupportsWebSockesRejectsOtherTransports(HttpTransportType transportType, int status)
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
await CheckTransportSupported(HttpTransportType.WebSockets, transportType, status, loggerFactory);
}
@ -788,7 +788,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[InlineData(HttpTransportType.LongPolling, 404)]
public async Task EndPointThatOnlySupportsWebSocketsAndSSERejectsLongPolling(HttpTransportType transportType, int status)
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
await CheckTransportSupported(HttpTransportType.WebSockets | HttpTransportType.ServerSentEvents, transportType, status, loggerFactory);
}
@ -797,7 +797,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task CompletedEndPointEndsConnection()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -831,7 +831,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
writeContext.EventId.Name == "FailedDispose";
}
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug, expectedErrorsFilter: ExpectedErrors))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug, expectedErrorsFilter: ExpectedErrors))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -858,7 +858,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task CompletedEndPointEndsLongPollingConnection()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -889,7 +889,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task LongPollingTimeoutSets200StatusCode()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -915,7 +915,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task WebSocketTransportTimesOutWhenCloseFrameNotReceived()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Trace))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Trace))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -945,7 +945,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[InlineData(HttpTransportType.ServerSentEvents)]
public async Task RequestToActiveConnectionId409ForStreamingTransports(HttpTransportType transportType)
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -988,7 +988,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task RequestToActiveConnectionIdKillsPreviousConnectionLongPolling()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -1029,7 +1029,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[InlineData(HttpTransportType.LongPolling)]
public async Task RequestToDisposedConnectionIdReturns404(HttpTransportType transportType)
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -1057,7 +1057,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task ConnectionStateSetToInactiveAfterPoll()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -1092,7 +1092,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task BlockingConnectionWorksWithStreamingConnections()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -1127,7 +1127,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task BlockingConnectionWorksWithLongPollingConnection()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -1168,7 +1168,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task AttemptingToPollWhileAlreadyPollingReplacesTheCurrentPoll()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -1213,7 +1213,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[InlineData(HttpTransportType.WebSockets, TransferFormat.Binary | TransferFormat.Text)]
public async Task TransferModeSet(HttpTransportType transportType, TransferFormat? expectedTransferFormats)
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -1245,7 +1245,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task UnauthorizedConnectionFailsToStartEndPoint()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -1291,7 +1291,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task AuthenticatedUserWithoutPermissionCausesForbidden()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -1339,7 +1339,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task AuthorizedConnectionCanConnectToEndPoint()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -1399,7 +1399,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task AllPoliciesRequiredForAuthorizedEndPoint()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -1486,7 +1486,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task AuthorizedConnectionWithAcceptedSchemesCanConnectToEndPoint()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -1549,7 +1549,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task AuthorizedConnectionWithRejectedSchemesFailsToConnectToEndPoint()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -1603,7 +1603,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task SetsInherentKeepAliveFeatureOnFirstLongPollingRequest()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -1635,7 +1635,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[InlineData(HttpTransportType.WebSockets)]
public async Task DeleteEndpointRejectsRequestToTerminateNonLongPollingTransport(HttpTransportType transportType)
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -1676,7 +1676,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task DeleteEndpointGracefullyTerminatesLongPolling()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -1727,7 +1727,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task DeleteEndpointGracefullyTerminatesLongPollingEvenWhenBetweenPolls()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var connection = manager.CreateConnection();
@ -1775,7 +1775,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task NegotiateDoesNotReturnWebSocketsWhenNotAvailable()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var dispatcher = new HttpConnectionDispatcher(manager, loggerFactory);
@ -1797,10 +1797,138 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
}
}
private class ControllableMemoryStream : MemoryStream
{
private readonly SyncPoint _syncPoint;
public ControllableMemoryStream(SyncPoint syncPoint)
{
_syncPoint = syncPoint;
}
public override async Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken)
{
await _syncPoint.WaitToContinue();
await base.CopyToAsync(destination, bufferSize, cancellationToken);
}
}
[Fact]
public async Task WriteThatIsDisposedBeforeCompleteReturns404()
{
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var pipeOptions = new PipeOptions(pauseWriterThreshold: 13, resumeWriterThreshold: 10);
var connection = manager.CreateConnection(pipeOptions, pipeOptions);
connection.TransportType = HttpTransportType.LongPolling;
var dispatcher = new HttpConnectionDispatcher(manager, loggerFactory);
var services = new ServiceCollection();
services.AddSingleton<TestConnectionHandler>();
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseConnectionHandler<TestConnectionHandler>();
var app = builder.Build();
var options = new HttpConnectionDispatcherOptions();
SyncPoint streamCopySyncPoint = new SyncPoint();
using (var responseBody = new MemoryStream())
using (var requestBody = new ControllableMemoryStream(streamCopySyncPoint))
{
var context = new DefaultHttpContext();
context.Request.Body = requestBody;
context.Response.Body = responseBody;
context.Request.Path = "/foo";
context.Request.Method = "POST";
var values = new Dictionary<string, StringValues>();
values["id"] = connection.ConnectionId;
var qs = new QueryCollection(values);
context.Request.Query = qs;
var buffer = Encoding.UTF8.GetBytes("Hello, world");
requestBody.Write(buffer, 0, buffer.Length);
requestBody.Seek(0, SeekOrigin.Begin);
// Write
var sendTask = dispatcher.ExecuteAsync(context, options, app);
// Wait on the sync point inside ApplicationStream.CopyToAsync
await streamCopySyncPoint.WaitForSyncPoint();
// Start disposing. This will close the output and cause the write to error
var disposeTask = connection.DisposeAsync().OrTimeout();
// Continue writing on a completed writer
streamCopySyncPoint.Continue();
await sendTask.OrTimeout();
await disposeTask.OrTimeout();
// Ensure response status is correctly set
Assert.Equal(404, context.Response.StatusCode);
}
}
}
[Fact]
public async Task CanDisposeWhileWriteLockIsBlockedOnBackpressureAndResponseReturns404()
{
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var pipeOptions = new PipeOptions(pauseWriterThreshold: 13, resumeWriterThreshold: 10);
var connection = manager.CreateConnection(pipeOptions, pipeOptions);
connection.TransportType = HttpTransportType.LongPolling;
var dispatcher = new HttpConnectionDispatcher(manager, loggerFactory);
var services = new ServiceCollection();
services.AddSingleton<TestConnectionHandler>();
var builder = new ConnectionBuilder(services.BuildServiceProvider());
builder.UseConnectionHandler<TestConnectionHandler>();
var app = builder.Build();
var options = new HttpConnectionDispatcherOptions();
using (var responseBody = new MemoryStream())
using (var requestBody = new MemoryStream())
{
var context = new DefaultHttpContext();
context.Request.Body = requestBody;
context.Response.Body = responseBody;
context.Request.Path = "/foo";
context.Request.Method = "POST";
var values = new Dictionary<string, StringValues>();
values["id"] = connection.ConnectionId;
var qs = new QueryCollection(values);
context.Request.Query = qs;
var buffer = Encoding.UTF8.GetBytes("Hello, world");
requestBody.Write(buffer, 0, buffer.Length);
requestBody.Seek(0, SeekOrigin.Begin);
// Write some data to the pipe to fill it up and make the next write wait
await connection.ApplicationStream.WriteAsync(buffer, 0, buffer.Length).OrTimeout();
// Write. This will take the WriteLock and block because of back pressure
var sendTask = dispatcher.ExecuteAsync(context, options, app);
// Start disposing. This will take the StateLock and attempt to take the WriteLock
// Dispose will cancel pending flush and should unblock WriteLock
await connection.DisposeAsync().OrTimeout();
// Sends were unblocked
await sendTask.OrTimeout();
Assert.Equal(404, context.Response.StatusCode);
}
}
}
[Fact]
public async Task LongPollingCanPollIfWritePipeHasBackpressure()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var manager = CreateConnectionManager(loggerFactory);
var pipeOptions = new PipeOptions(pauseWriterThreshold: 13, resumeWriterThreshold: 10);

View File

@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[InlineData(nameof(WebSocketMessageType.Binary))]
public async Task ReceivedFramesAreWrittenToChannel(string webSocketMessageType)
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var pair = DuplexPipe.CreateConnectionPair(PipeOptions.Default, PipeOptions.Default);
var connection = new HttpConnectionContext("foo", pair.Transport, pair.Application);
@ -83,7 +83,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[InlineData(TransferFormat.Binary, nameof(WebSocketMessageType.Binary))]
public async Task WebSocketTransportSetsMessageTypeBasedOnTransferFormatFeature(TransferFormat transferFormat, string expectedMessageType)
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var pair = DuplexPipe.CreateConnectionPair(PipeOptions.Default, PipeOptions.Default);
var connection = new HttpConnectionContext("foo", pair.Transport, pair.Application);
@ -120,7 +120,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task TransportCommunicatesErrorToApplicationWhenClientDisconnectsAbnormally()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var pair = DuplexPipe.CreateConnectionPair(PipeOptions.Default, PipeOptions.Default);
var connection = new HttpConnectionContext("foo", pair.Transport, pair.Application);
@ -173,7 +173,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task ClientReceivesInternalServerErrorWhenTheApplicationFails()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var pair = DuplexPipe.CreateConnectionPair(PipeOptions.Default, PipeOptions.Default);
var connection = new HttpConnectionContext("foo", pair.Transport, pair.Application);
@ -205,7 +205,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task TransportClosesOnCloseTimeoutIfClientDoesNotSendCloseFrame()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var pair = DuplexPipe.CreateConnectionPair(PipeOptions.Default, PipeOptions.Default);
var connection = new HttpConnectionContext("foo", pair.Transport, pair.Application);
@ -240,7 +240,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task TransportFailsOnTimeoutWithErrorWhenApplicationFailsAndClientDoesNotSendCloseFrame()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var pair = DuplexPipe.CreateConnectionPair(PipeOptions.Default, PipeOptions.Default);
var connection = new HttpConnectionContext("foo", pair.Transport, pair.Application);
@ -275,7 +275,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task ServerGracefullyClosesWhenApplicationEndsThenClientSendsCloseFrame()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var pair = DuplexPipe.CreateConnectionPair(PipeOptions.Default, PipeOptions.Default);
var connection = new HttpConnectionContext("foo", pair.Transport, pair.Application);
@ -315,7 +315,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
[Fact]
public async Task ServerGracefullyClosesWhenClientSendsCloseFrameThenApplicationEnds()
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var pair = DuplexPipe.CreateConnectionPair(PipeOptions.Default, PipeOptions.Default);
var connection = new HttpConnectionContext("foo", pair.Transport, pair.Application);
@ -358,7 +358,7 @@ namespace Microsoft.AspNetCore.Http.Connections.Tests
const string ExpectedSubProtocol = "expected";
var providedSubProtocols = new[] {"provided1", "provided2"};
using (StartVerifableLog(out var loggerFactory, LogLevel.Debug))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Debug))
{
var pair = DuplexPipe.CreateConnectionPair(PipeOptions.Default, PipeOptions.Default);
var connection = new HttpConnectionContext("foo", pair.Transport, pair.Application);

View File

@ -69,7 +69,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
public async Task CheckFixedMessage(string protocolName, HttpTransportType transportType, string path)
{
var protocol = HubProtocols[protocolName];
using (StartVerifableLog(out var loggerFactory, $"{nameof(CheckFixedMessage)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
using (StartVerifiableLog(out var loggerFactory, $"{nameof(CheckFixedMessage)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
{
var connectionBuilder = new HubConnectionBuilder()
.WithLoggerFactory(loggerFactory)
@ -103,7 +103,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
public async Task CanSendAndReceiveMessage(string protocolName, HttpTransportType transportType, string path)
{
var protocol = HubProtocols[protocolName];
using (StartVerifableLog(out var loggerFactory, $"{nameof(CanSendAndReceiveMessage)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
using (StartVerifiableLog(out var loggerFactory, $"{nameof(CanSendAndReceiveMessage)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
{
const string originalMessage = "SignalR";
var connection = CreateHubConnection(path, transportType, protocol, loggerFactory);
@ -132,7 +132,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
public async Task CanStopAndStartConnection(string protocolName, HttpTransportType transportType, string path)
{
var protocol = HubProtocols[protocolName];
using (StartVerifableLog(out var loggerFactory, LogLevel.Trace, $"{nameof(CanStopAndStartConnection)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Trace, $"{nameof(CanStopAndStartConnection)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
{
const string originalMessage = "SignalR";
var connection = CreateHubConnection(path, transportType, protocol, loggerFactory);
@ -163,7 +163,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
public async Task CanStartConnectionFromClosedEvent(string protocolName, HttpTransportType transportType, string path)
{
var protocol = HubProtocols[protocolName];
using (StartVerifableLog(out var loggerFactory, LogLevel.Trace, $"{nameof(CanStartConnectionFromClosedEvent)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Trace, $"{nameof(CanStartConnectionFromClosedEvent)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
{
var logger = loggerFactory.CreateLogger<HubConnectionTests>();
const string originalMessage = "SignalR";
@ -225,7 +225,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
public async Task MethodsAreCaseInsensitive(string protocolName, HttpTransportType transportType, string path)
{
var protocol = HubProtocols[protocolName];
using (StartVerifableLog(out var loggerFactory, $"{nameof(MethodsAreCaseInsensitive)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
using (StartVerifiableLog(out var loggerFactory, $"{nameof(MethodsAreCaseInsensitive)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
{
const string originalMessage = "SignalR";
var connection = CreateHubConnection(path, transportType, protocol, loggerFactory);
@ -254,7 +254,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
public async Task CanInvokeClientMethodFromServer(string protocolName, HttpTransportType transportType, string path)
{
var protocol = HubProtocols[protocolName];
using (StartVerifableLog(out var loggerFactory, LogLevel.Trace, $"{nameof(CanInvokeClientMethodFromServer)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Trace, $"{nameof(CanInvokeClientMethodFromServer)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
{
const string originalMessage = "SignalR";
@ -287,7 +287,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
public async Task InvokeNonExistantClientMethodFromServer(string protocolName, HttpTransportType transportType, string path)
{
var protocol = HubProtocols[protocolName];
using (StartVerifableLog(out var loggerFactory, LogLevel.Trace, $"{nameof(InvokeNonExistantClientMethodFromServer)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Trace, $"{nameof(InvokeNonExistantClientMethodFromServer)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
{
var connection = CreateHubConnection(path, transportType, protocol, loggerFactory);
var closeTcs = new TaskCompletionSource<object>();
@ -328,7 +328,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
public async Task CanStreamClientMethodFromServer(string protocolName, HttpTransportType transportType, string path)
{
var protocol = HubProtocols[protocolName];
using (StartVerifableLog(out var loggerFactory, LogLevel.Trace, $"{nameof(CanStreamClientMethodFromServer)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Trace, $"{nameof(CanStreamClientMethodFromServer)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
{
var connection = CreateHubConnection(path, transportType, protocol, loggerFactory);
try
@ -357,7 +357,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
public async Task CanCloseStreamMethodEarly(string protocolName, HttpTransportType transportType, string path)
{
var protocol = HubProtocols[protocolName];
using (StartVerifableLog(out var loggerFactory, $"{nameof(CanCloseStreamMethodEarly)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
using (StartVerifiableLog(out var loggerFactory, $"{nameof(CanCloseStreamMethodEarly)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
{
var connection = CreateHubConnection(path, transportType, protocol, loggerFactory);
try
@ -397,7 +397,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
public async Task StreamDoesNotStartIfTokenAlreadyCanceled(string protocolName, HttpTransportType transportType, string path)
{
var protocol = HubProtocols[protocolName];
using (StartVerifableLog(out var loggerFactory, LogLevel.Trace, $"{nameof(StreamDoesNotStartIfTokenAlreadyCanceled)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Trace, $"{nameof(StreamDoesNotStartIfTokenAlreadyCanceled)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}"))
{
var connection = CreateHubConnection(path, transportType, protocol, loggerFactory);
try
@ -435,7 +435,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
}
var protocol = HubProtocols[protocolName];
using (StartVerifableLog(out var loggerFactory, $"{nameof(ExceptionFromStreamingSentToClient)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
using (StartVerifiableLog(out var loggerFactory, $"{nameof(ExceptionFromStreamingSentToClient)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
{
var connection = CreateHubConnection(path, transportType, protocol, loggerFactory);
try
@ -469,7 +469,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
}
var hubProtocol = HubProtocols[hubProtocolName];
using (StartVerifableLog(out var loggerFactory, $"{nameof(ServerThrowsHubExceptionIfHubMethodCannotBeResolved)}_{hubProtocol.Name}_{transportType}_{hubPath.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
using (StartVerifiableLog(out var loggerFactory, $"{nameof(ServerThrowsHubExceptionIfHubMethodCannotBeResolved)}_{hubProtocol.Name}_{transportType}_{hubPath.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
{
var connection = CreateHubConnection(hubPath, transportType, hubProtocol, loggerFactory);
try
@ -502,7 +502,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
}
var hubProtocol = HubProtocols[hubProtocolName];
using (StartVerifableLog(out var loggerFactory, $"{nameof(ServerThrowsHubExceptionOnHubMethodArgumentCountMismatch)}_{hubProtocol.Name}_{transportType}_{hubPath.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
using (StartVerifiableLog(out var loggerFactory, $"{nameof(ServerThrowsHubExceptionOnHubMethodArgumentCountMismatch)}_{hubProtocol.Name}_{transportType}_{hubPath.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
{
var connection = CreateHubConnection(hubPath, transportType, hubProtocol, loggerFactory);
try
@ -535,7 +535,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
}
var hubProtocol = HubProtocols[hubProtocolName];
using (StartVerifableLog(out var loggerFactory, $"{nameof(ServerThrowsHubExceptionOnHubMethodArgumentTypeMismatch)}_{hubProtocol.Name}_{transportType}_{hubPath.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
using (StartVerifiableLog(out var loggerFactory, $"{nameof(ServerThrowsHubExceptionOnHubMethodArgumentTypeMismatch)}_{hubProtocol.Name}_{transportType}_{hubPath.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
{
var connection = CreateHubConnection(hubPath, transportType, hubProtocol, loggerFactory);
try
@ -568,7 +568,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
}
var hubProtocol = HubProtocols[hubProtocolName];
using (StartVerifableLog(out var loggerFactory, $"{nameof(ServerThrowsHubExceptionIfStreamingHubMethodCannotBeResolved)}_{hubProtocol.Name}_{transportType}_{hubPath.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
using (StartVerifiableLog(out var loggerFactory, $"{nameof(ServerThrowsHubExceptionIfStreamingHubMethodCannotBeResolved)}_{hubProtocol.Name}_{transportType}_{hubPath.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
{
var connection = CreateHubConnection(hubPath, transportType, hubProtocol, loggerFactory);
try
@ -602,7 +602,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
}
var hubProtocol = HubProtocols[hubProtocolName];
using (StartVerifableLog(out var loggerFactory, $"{nameof(ServerThrowsHubExceptionOnStreamingHubMethodArgumentCountMismatch)}_{hubProtocol.Name}_{transportType}_{hubPath.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
using (StartVerifiableLog(out var loggerFactory, $"{nameof(ServerThrowsHubExceptionOnStreamingHubMethodArgumentCountMismatch)}_{hubProtocol.Name}_{transportType}_{hubPath.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
{
loggerFactory.AddConsole(LogLevel.Trace);
var connection = CreateHubConnection(hubPath, transportType, hubProtocol, loggerFactory);
@ -637,7 +637,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
}
var hubProtocol = HubProtocols[hubProtocolName];
using (StartVerifableLog(out var loggerFactory, $"{nameof(ServerThrowsHubExceptionOnStreamingHubMethodArgumentTypeMismatch)}_{hubProtocol.Name}_{transportType}_{hubPath.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
using (StartVerifiableLog(out var loggerFactory, $"{nameof(ServerThrowsHubExceptionOnStreamingHubMethodArgumentTypeMismatch)}_{hubProtocol.Name}_{transportType}_{hubPath.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
{
var connection = CreateHubConnection(hubPath, transportType, hubProtocol, loggerFactory);
try
@ -671,7 +671,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
}
var hubProtocol = HubProtocols[hubProtocolName];
using (StartVerifableLog(out var loggerFactory, $"{nameof(ServerThrowsHubExceptionIfNonStreamMethodInvokedWithStreamAsync)}_{hubProtocol.Name}_{transportType}_{hubPath.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
using (StartVerifiableLog(out var loggerFactory, $"{nameof(ServerThrowsHubExceptionIfNonStreamMethodInvokedWithStreamAsync)}_{hubProtocol.Name}_{transportType}_{hubPath.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
{
var connection = CreateHubConnection(hubPath, transportType, hubProtocol, loggerFactory);
try
@ -704,7 +704,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
}
var hubProtocol = HubProtocols[hubProtocolName];
using (StartVerifableLog(out var loggerFactory, $"{nameof(ServerThrowsHubExceptionIfStreamMethodInvokedWithInvoke)}_{hubProtocol.Name}_{transportType}_{hubPath.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
using (StartVerifiableLog(out var loggerFactory, $"{nameof(ServerThrowsHubExceptionIfStreamMethodInvokedWithInvoke)}_{hubProtocol.Name}_{transportType}_{hubPath.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
{
var connection = CreateHubConnection(hubPath, transportType, hubProtocol, loggerFactory);
try
@ -737,7 +737,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
}
var hubProtocol = HubProtocols[hubProtocolName];
using (StartVerifableLog(out var loggerFactory, $"{nameof(ServerThrowsHubExceptionIfBuildingAsyncEnumeratorIsNotPossible)}_{hubProtocol.Name}_{transportType}_{hubPath.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
using (StartVerifiableLog(out var loggerFactory, $"{nameof(ServerThrowsHubExceptionIfBuildingAsyncEnumeratorIsNotPossible)}_{hubProtocol.Name}_{transportType}_{hubPath.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors))
{
var connection = CreateHubConnection(hubPath, transportType, hubProtocol, loggerFactory);
try
@ -763,7 +763,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
[MemberData(nameof(TransportTypes))]
public async Task ClientCanUseJwtBearerTokenForAuthentication(HttpTransportType transportType)
{
using (StartVerifableLog(out var loggerFactory, $"{nameof(ClientCanUseJwtBearerTokenForAuthentication)}_{transportType}"))
using (StartVerifiableLog(out var loggerFactory, $"{nameof(ClientCanUseJwtBearerTokenForAuthentication)}_{transportType}"))
{
async Task<string> AccessTokenProvider()
{
@ -801,7 +801,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
[MemberData(nameof(TransportTypes))]
public async Task ClientCanUseJwtBearerTokenForAuthenticationWhenRedirected(HttpTransportType transportType)
{
using (StartVerifableLog(out var loggerFactory, $"{nameof(ClientCanUseJwtBearerTokenForAuthenticationWhenRedirected)}_{transportType}"))
using (StartVerifiableLog(out var loggerFactory, $"{nameof(ClientCanUseJwtBearerTokenForAuthenticationWhenRedirected)}_{transportType}"))
{
var hubConnection = new HubConnectionBuilder()
.WithLoggerFactory(loggerFactory)
@ -829,7 +829,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
[MemberData(nameof(TransportTypes))]
public async Task ClientCanSendHeaders(HttpTransportType transportType)
{
using (StartVerifableLog(out var loggerFactory, $"{nameof(ClientCanSendHeaders)}_{transportType}"))
using (StartVerifiableLog(out var loggerFactory, $"{nameof(ClientCanSendHeaders)}_{transportType}"))
{
var hubConnection = new HubConnectionBuilder()
.WithLoggerFactory(loggerFactory)
@ -861,7 +861,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
[WebSocketsSupportedCondition]
public async Task WebSocketOptionsAreApplied()
{
using (StartVerifableLog(out var loggerFactory, $"{nameof(WebSocketOptionsAreApplied)}"))
using (StartVerifiableLog(out var loggerFactory, $"{nameof(WebSocketOptionsAreApplied)}"))
{
// System.Net has a HttpTransportType type which means we need to fully-qualify this rather than 'use' the namespace
var cookieJar = new System.Net.CookieContainer();
@ -895,7 +895,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
[Fact]
public async Task CheckHttpConnectionFeatures()
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
var hubConnection = new HubConnectionBuilder()
.WithLoggerFactory(loggerFactory)
@ -931,7 +931,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
[Fact]
public async Task UserIdProviderCanAccessHttpContext()
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
var hubConnection = new HubConnectionBuilder()
.WithLoggerFactory(loggerFactory)
@ -962,7 +962,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
[Fact]
public async Task NegotiationSkipsServerSentEventsWhenUsingBinaryProtocol()
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
var hubConnectionBuilder = new HubConnectionBuilder()
.WithLoggerFactory(loggerFactory)
@ -992,7 +992,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
[Fact]
public async Task StopCausesPollToReturnImmediately()
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
PollTrackingMessageHandler pollTracker = null;
var hubConnection = new HubConnectionBuilder()

View File

@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
[Fact]
public async Task CanStartStartedConnection()
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
await WithConnectionAsync(CreateConnection(loggerFactory: loggerFactory), async (connection) =>
{
@ -41,7 +41,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
[Fact]
public async Task CanStartStartingConnection()
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
await WithConnectionAsync(
CreateConnection(loggerFactory: loggerFactory, transport: new TestTransport(onTransportStart: SyncPoint.Create(out var syncPoint))),
@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
[Fact]
public async Task CannotStartConnectionOnceDisposed()
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
await WithConnectionAsync(
CreateConnection(loggerFactory: loggerFactory),
@ -89,7 +89,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
writeContext.EventId.Name == "ErrorStartingTransport";
}
using (StartVerifableLog(out var loggerFactory, expectedErrorsFilter: ExpectedErrors))
using (StartVerifiableLog(out var loggerFactory, expectedErrorsFilter: ExpectedErrors))
{
var startCounter = 0;
var expected = new Exception("Transport failed to start");
@ -140,7 +140,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
writeContext.EventId.Name == "ErrorStartingTransport";
}
using (StartVerifableLog(out var loggerFactory, expectedErrorsFilter: ExpectedErrors))
using (StartVerifiableLog(out var loggerFactory, expectedErrorsFilter: ExpectedErrors))
{
var startCounter = 0;
var availableTransports = 3;
@ -175,7 +175,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
[Fact]
public async Task CanDisposeUnstartedConnection()
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
await WithConnectionAsync(
CreateConnection(loggerFactory: loggerFactory),
@ -190,7 +190,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
[Fact]
public async Task CanDisposeStartingConnection()
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
await WithConnectionAsync(
CreateConnection(
@ -224,7 +224,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
[Fact]
public async Task CanDisposeDisposingConnection()
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
await WithConnectionAsync(
CreateConnection(
@ -289,7 +289,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
writeContext.EventId.Name == "ErrorSending";
}
using (StartVerifableLog(out var loggerFactory, expectedErrorsFilter: ExpectedErrors))
using (StartVerifiableLog(out var loggerFactory, expectedErrorsFilter: ExpectedErrors))
{
var httpHandler = new TestHttpMessageHandler();
@ -332,7 +332,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
writeContext.EventId.Name == "ErrorStartingTransport";
}
using (StartVerifableLog(out var loggerFactory, expectedErrorsFilter: ExpectedErrors))
using (StartVerifiableLog(out var loggerFactory, expectedErrorsFilter: ExpectedErrors))
{
var httpHandler = new TestHttpMessageHandler();
@ -356,7 +356,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
[Fact]
public async Task SSEWaitsForResponseToStart()
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
var httpHandler = new TestHttpMessageHandler();

View File

@ -81,7 +81,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
[InlineData(HttpTransportType.ServerSentEvents, false)]
public async Task HttpConnectionSetsInherentKeepAliveFeature(HttpTransportType transportType, bool expectedValue)
{
using (StartVerifableLog(out var loggerFactory, testName: $"HttpConnectionSetsInherentKeepAliveFeature_{transportType}_{expectedValue}"))
using (StartVerifiableLog(out var loggerFactory, testName: $"HttpConnectionSetsInherentKeepAliveFeature_{transportType}_{expectedValue}"))
{
var testHttpHandler = new TestHttpMessageHandler(autoNegotiate: false);

View File

@ -126,7 +126,7 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests
writeContext.EventId.Name == "ShutdownWithError";
}
using (StartVerifableLog(out var loggerFactory, LogLevel.Trace, expectedErrorsFilter: ExpectedErrors))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Trace, expectedErrorsFilter: ExpectedErrors))
{
var hubConnection = CreateHubConnection(new TestConnection(), loggerFactory: loggerFactory);
hubConnection.ServerTimeout = TimeSpan.FromMilliseconds(2000);

View File

@ -43,7 +43,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
[MemberData(nameof(TransportTypesAndProtocolTypes))]
public async Task HubConnectionCanSendAndReceiveMessages(HttpTransportType transportType, string protocolName)
{
using (StartVerifableLog(out var loggerFactory, testName:
using (StartVerifiableLog(out var loggerFactory, testName:
$"{nameof(HubConnectionCanSendAndReceiveMessages)}_{transportType.ToString()}_{protocolName}"))
{
var protocol = HubProtocolHelpers.GetHubProtocol(protocolName);
@ -64,7 +64,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
[MemberData(nameof(TransportTypesAndProtocolTypes))]
public async Task HubConnectionCanSendAndReceiveGroupMessages(HttpTransportType transportType, string protocolName)
{
using (StartVerifableLog(out var loggerFactory, testName:
using (StartVerifiableLog(out var loggerFactory, testName:
$"{nameof(HubConnectionCanSendAndReceiveGroupMessages)}_{transportType.ToString()}_{protocolName}"))
{
var protocol = HubProtocolHelpers.GetHubProtocol(protocolName);
@ -95,7 +95,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
[MemberData(nameof(TransportTypesAndProtocolTypes))]
public async Task CanSendAndReceiveUserMessagesFromMultipleConnectionsWithSameUser(HttpTransportType transportType, string protocolName)
{
using (StartVerifableLog(out var loggerFactory, testName:
using (StartVerifiableLog(out var loggerFactory, testName:
$"{nameof(CanSendAndReceiveUserMessagesFromMultipleConnectionsWithSameUser)}_{transportType.ToString()}_{protocolName}"))
{
var protocol = HubProtocolHelpers.GetHubProtocol(protocolName);
@ -128,7 +128,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests
// Regression test:
// When multiple connections from the same user were connected and one left, it used to unsubscribe from the user channel
// Now we keep track of users connections and only unsubscribe when no users are listening
using (StartVerifableLog(out var loggerFactory, testName:
using (StartVerifiableLog(out var loggerFactory, testName:
$"{nameof(CanSendAndReceiveUserMessagesWhenOneConnectionWithUserDisconnects)}_{transportType.ToString()}_{protocolName}"))
{
var protocol = HubProtocolHelpers.GetHubProtocol(protocolName);

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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 System;
@ -17,18 +17,18 @@ namespace Microsoft.AspNetCore.SignalR.Tests
{
}
public virtual IDisposable StartVerifableLog(out ILoggerFactory loggerFactory, [CallerMemberName] string testName = null, Func<WriteContext, bool> expectedErrorsFilter = null)
public virtual IDisposable StartVerifiableLog(out ILoggerFactory loggerFactory, [CallerMemberName] string testName = null, Func<WriteContext, bool> expectedErrorsFilter = null)
{
var disposable = StartLog(out loggerFactory, testName);
return new VerifyNoErrorsScope(loggerFactory, disposable, expectedErrorsFilter);
}
public virtual IDisposable StartVerifableLog(out ILoggerFactory loggerFactory, LogLevel minLogLevel, [CallerMemberName] string testName = null, Func<WriteContext, bool> expectedErrorsFilter = null)
public virtual IDisposable StartVerifiableLog(out ILoggerFactory loggerFactory, LogLevel minLogLevel, [CallerMemberName] string testName = null, Func<WriteContext, bool> expectedErrorsFilter = null)
{
var disposable = StartLog(out loggerFactory, minLogLevel, testName);
return new VerifyNoErrorsScope(loggerFactory, disposable, expectedErrorsFilter);
}
}
}
}

View File

@ -53,15 +53,15 @@ namespace Microsoft.AspNetCore.SignalR.Tests
};
}
public override IDisposable StartVerifableLog(out ILoggerFactory loggerFactory, LogLevel minLogLevel, [CallerMemberName] string testName = null, Func<WriteContext, bool> expectedErrorsFilter = null)
public override IDisposable StartVerifiableLog(out ILoggerFactory loggerFactory, LogLevel minLogLevel, [CallerMemberName] string testName = null, Func<WriteContext, bool> expectedErrorsFilter = null)
{
var disposable = base.StartVerifableLog(out loggerFactory, minLogLevel, testName, ResolveExpectedErrorsFilter(expectedErrorsFilter));
var disposable = base.StartVerifiableLog(out loggerFactory, minLogLevel, testName, ResolveExpectedErrorsFilter(expectedErrorsFilter));
return new ServerLogScope(ServerFixture, loggerFactory, disposable);
}
public override IDisposable StartVerifableLog(out ILoggerFactory loggerFactory, [CallerMemberName] string testName = null, Func<WriteContext, bool> expectedErrorsFilter = null)
public override IDisposable StartVerifiableLog(out ILoggerFactory loggerFactory, [CallerMemberName] string testName = null, Func<WriteContext, bool> expectedErrorsFilter = null)
{
var disposable = base.StartVerifableLog(out loggerFactory, testName, ResolveExpectedErrorsFilter(expectedErrorsFilter));
var disposable = base.StartVerifiableLog(out loggerFactory, testName, ResolveExpectedErrorsFilter(expectedErrorsFilter));
return new ServerLogScope(ServerFixture, loggerFactory, disposable);
}
}

View File

@ -44,7 +44,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
[Fact]
public async Task CanStartAndStopConnectionUsingDefaultTransport()
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
var url = ServerFixture.Url + "/echo";
// The test should connect to the server using WebSockets transport on Windows 8 and newer.
@ -64,7 +64,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
writeContext.EventId.Name == "ErrorStartingTransport";
}
using (StartVerifableLog(out var loggerFactory, expectedErrorsFilter: ExpectedErrors))
using (StartVerifiableLog(out var loggerFactory, expectedErrorsFilter: ExpectedErrors))
{
var url = ServerFixture.Url + "/echo";
// The test should connect to the server using WebSockets transport on Windows 8 and newer.
@ -81,7 +81,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
[MemberData(nameof(TransportTypes))]
public async Task CanStartAndStopConnectionUsingGivenTransport(HttpTransportType transportType)
{
using (StartVerifableLog(out var loggerFactory, minLogLevel: LogLevel.Trace, testName: $"CanStartAndStopConnectionUsingGivenTransport_{transportType}"))
using (StartVerifiableLog(out var loggerFactory, minLogLevel: LogLevel.Trace, testName: $"CanStartAndStopConnectionUsingGivenTransport_{transportType}"))
{
var url = ServerFixture.Url + "/echo";
var connection = new HttpConnection(new Uri(url), transportType, loggerFactory);
@ -94,7 +94,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
[WebSocketsSupportedCondition]
public async Task WebSocketsTest()
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
var logger = loggerFactory.CreateLogger<EndToEndTests>();
@ -131,7 +131,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
[WebSocketsSupportedCondition]
public async Task WebSocketsReceivesAndSendsPartialFramesTest()
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
var logger = loggerFactory.CreateLogger<EndToEndTests>();
@ -169,7 +169,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
[WebSocketsSupportedCondition]
public async Task HttpRequestsNotSentWhenWebSocketsTransportRequestedAndSkipNegotiationSet()
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
var logger = loggerFactory.CreateLogger<EndToEndTests>();
var url = ServerFixture.Url + "/echo";
@ -219,7 +219,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
[InlineData(HttpTransportType.ServerSentEvents)]
public async Task HttpConnectionThrowsIfSkipNegotiationSetAndTransportIsNotWebSockets(HttpTransportType transportType)
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
var logger = loggerFactory.CreateLogger<EndToEndTests>();
var url = ServerFixture.Url + "/echo";
@ -261,7 +261,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
[MemberData(nameof(TransportTypesAndTransferFormats))]
public async Task ConnectionCanSendAndReceiveMessages(HttpTransportType transportType, TransferFormat requestedTransferFormat)
{
using (StartVerifableLog(out var loggerFactory, minLogLevel: LogLevel.Trace, testName: $"ConnectionCanSendAndReceiveMessages_{transportType.ToString()}_{requestedTransferFormat.ToString()}"))
using (StartVerifiableLog(out var loggerFactory, minLogLevel: LogLevel.Trace, testName: $"ConnectionCanSendAndReceiveMessages_{transportType.ToString()}_{requestedTransferFormat.ToString()}"))
{
var logger = loggerFactory.CreateLogger<EndToEndTests>();
@ -325,7 +325,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
[MemberData(nameof(MessageSizesData))]
public async Task ConnectionCanSendAndReceiveDifferentMessageSizesWebSocketsTransport(string message)
{
using (StartVerifableLog(out var loggerFactory, LogLevel.Trace, testName: $"ConnectionCanSendAndReceiveDifferentMessageSizesWebSocketsTransport_{message.Length}"))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Trace, testName: $"ConnectionCanSendAndReceiveDifferentMessageSizesWebSocketsTransport_{message.Length}"))
{
var logger = loggerFactory.CreateLogger<EndToEndTests>();
@ -373,7 +373,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
writeContext.EventId.Name == "ErrorWithNegotiation";
}
using (StartVerifableLog(out var loggerFactory, LogLevel.Trace, expectedErrorsFilter: ExpectedErrors))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Trace, expectedErrorsFilter: ExpectedErrors))
{
var logger = loggerFactory.CreateLogger<EndToEndTests>();
@ -396,7 +396,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
writeContext.EventId.Name == "ErrorStartingTransport";
}
using (StartVerifableLog(out var loggerFactory, LogLevel.Trace, expectedErrorsFilter: ExpectedErrors))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Trace, expectedErrorsFilter: ExpectedErrors))
{
var logger = loggerFactory.CreateLogger<EndToEndTests>();
@ -425,7 +425,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
writeContext.EventId.Name == "ErrorWithNegotiation";
}
using (StartVerifableLog(out var loggerFactory, LogLevel.Trace, testName: $"{nameof(UnauthorizedConnectionDoesNotConnect)}_{transportType}", expectedErrorsFilter: ExpectedErrors))
using (StartVerifiableLog(out var loggerFactory, LogLevel.Trace, testName: $"{nameof(UnauthorizedConnectionDoesNotConnect)}_{transportType}", expectedErrorsFilter: ExpectedErrors))
{
var logger = loggerFactory.CreateLogger<EndToEndTests>();
@ -482,7 +482,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
private async Task ServerClosesConnectionWithErrorIfHubCannotBeCreated(HttpTransportType transportType)
{
using (StartVerifableLog(out var loggerFactory, testName: $"ConnectionCanSendAndReceiveMessages_{transportType.ToString()}"))
using (StartVerifiableLog(out var loggerFactory, testName: $"ConnectionCanSendAndReceiveMessages_{transportType.ToString()}"))
{
var logger = loggerFactory.CreateLogger<EndToEndTests>();

View File

@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
[WebSocketsSupportedCondition]
public async Task WebSocketsTransportStopsSendAndReceiveLoopsWhenTransportIsStopped()
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: loggerFactory, accessTokenProvider: null);
await webSocketsTransport.StartAsync(new Uri(ServerFixture.WebSocketsUrl + "/echo"),
@ -71,7 +71,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
[WebSocketsSupportedCondition]
public async Task WebSocketsTransportSendsUserAgent()
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: loggerFactory, accessTokenProvider: null);
await webSocketsTransport.StartAsync(new Uri(ServerFixture.WebSocketsUrl + "/httpheader"),
@ -99,7 +99,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
[WebSocketsSupportedCondition]
public async Task WebSocketsTransportSendsXRequestedWithHeader()
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: loggerFactory, accessTokenProvider: null);
await webSocketsTransport.StartAsync(new Uri(ServerFixture.WebSocketsUrl + "/httpheader"),
@ -122,7 +122,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
[WebSocketsSupportedCondition]
public async Task WebSocketsTransportStopsWhenConnectionChannelClosed()
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: loggerFactory, accessTokenProvider: null);
await webSocketsTransport.StartAsync(new Uri(ServerFixture.WebSocketsUrl + "/echo"),
@ -138,7 +138,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
[InlineData(TransferFormat.Binary)]
public async Task WebSocketsTransportStopsWhenConnectionClosedByTheServer(TransferFormat transferFormat)
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: loggerFactory, accessTokenProvider: null);
await webSocketsTransport.StartAsync(new Uri(ServerFixture.WebSocketsUrl + "/echoAndClose"), transferFormat);
@ -160,7 +160,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
[InlineData(TransferFormat.Binary)]
public async Task WebSocketsTransportSetsTransferFormat(TransferFormat transferFormat)
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: loggerFactory, accessTokenProvider: null);
@ -178,7 +178,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests
[WebSocketsSupportedCondition]
public async Task WebSocketsTransportThrowsForInvalidTransferFormat(TransferFormat transferFormat)
{
using (StartVerifableLog(out var loggerFactory))
using (StartVerifiableLog(out var loggerFactory))
{
var webSocketsTransport = new WebSocketsTransport(httpConnectionOptions: null, loggerFactory: loggerFactory, accessTokenProvider: null);
var exception = await Assert.ThrowsAsync<ArgumentException>(() =>