Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit 337785a

Browse files
committed
fix EventQueueTimeout test
1 parent 86ff4a3 commit 337785a

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

SignalR.sln

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ EndProject
2626
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{6A35B453-52EC-48AF-89CA-D4A69800F131}"
2727
ProjectSection(SolutionItems) = preProject
2828
test\Directory.Build.props = test\Directory.Build.props
29-
test\xunit.runner.json = test\xunit.runner.json
3029
EndProjectSection
3130
EndProject
3231
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Sockets.Tests", "test\Microsoft.AspNetCore.Sockets.Tests\Microsoft.AspNetCore.Sockets.Tests.csproj", "{AAD719D5-5E31-4ED1-A60F-6EB92EFA66D9}"
@@ -86,7 +85,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JwtSample", "samples\JwtSam
8685
EndProject
8786
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JwtClientSample", "samples\JwtClientSample\JwtClientSample.csproj", "{1A953296-E869-4DE2-A693-FD5FCDE27057}"
8887
EndProject
89-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNetCore.SignalR.Tests.Utils", "test\Microsoft.AspNetCore.SignalR.Tests.Utils\Microsoft.AspNetCore.SignalR.Tests.Utils.csproj", "{0A0A6135-EA24-4307-95C2-CE1B7E164A5E}"
88+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SignalR.Tests.Utils", "test\Microsoft.AspNetCore.SignalR.Tests.Utils\Microsoft.AspNetCore.SignalR.Tests.Utils.csproj", "{0A0A6135-EA24-4307-95C2-CE1B7E164A5E}"
9089
EndProject
9190
Global
9291
GlobalSection(SolutionConfigurationPlatforms) = preSolution

src/Microsoft.AspNetCore.Sockets.Client.Http/HttpConnection.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ private async Task StartAsyncInternal()
191191
await _receiveLoopTask;
192192

193193
_logger.DrainEvents(_connectionId);
194-
await _eventQueue.Drain();
195194

196195
await Task.WhenAny(_eventQueue.Drain().NoThrow(), Task.Delay(_eventQueueDrainTimeout));
197196

test/Microsoft.AspNetCore.SignalR.Client.Tests/HttpConnectionTests.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
5+
using System.Diagnostics;
56
using System.Net;
67
using System.Net.Http;
78
using System.Text;
@@ -625,21 +626,27 @@ public async Task EventQueueTimeout()
625626
mockTransport.SetupGet(t => t.Mode).Returns(TransferMode.Text);
626627

627628
var blockReceiveCallbackTcs = new TaskCompletionSource<object>();
629+
var onReceivedCalledTcs = new TaskCompletionSource<object>();
628630

629631
var connection = new HttpConnection(new Uri("http://fakeuri.org/"), new TestTransportFactory(mockTransport.Object), loggerFactory,
630632
httpOptions: new HttpOptions { HttpMessageHandler = mockHttpHandler.Object });
631-
connection.OnReceived(_ => blockReceiveCallbackTcs.Task);
633+
connection.OnReceived(async _ =>
634+
{
635+
onReceivedCalledTcs.TrySetResult(null);
636+
await blockReceiveCallbackTcs.Task;
637+
});
632638

633639
logger.LogInformation("Starting connection");
634640
await connection.StartAsync().OrTimeout();
635641
logger.LogInformation("Started connection");
636642
channel.Writer.TryWrite(Array.Empty<byte>());
643+
await onReceivedCalledTcs.Task.OrTimeout();
637644

638645
// Ensure that SignalR isn't blocked by the receive callback
639646
Assert.False(channel.Reader.TryRead(out var message));
640647

641648
logger.LogInformation("Disposing connection");
642-
await connection.DisposeAsync().OrTimeout();
649+
await connection.DisposeAsync().OrTimeout(TimeSpan.FromSeconds(10));
643650
logger.LogInformation("Disposed connection");
644651
}
645652
}

test/Microsoft.AspNetCore.SignalR.Client.Tests/ServerSentEventsTransportTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public async Task SSETransportStopsSendAndReceiveLoopsWhenTransportStopped()
8686
var buffer = Encoding.ASCII.GetBytes("data: 3:abc\r\n\r\n");
8787
while (!eventStreamCts.IsCancellationRequested)
8888
{
89-
await stream.WriteAsync(buffer, 0, buffer.Length);
89+
await stream.WriteAsync(buffer, 0, buffer.Length).OrTimeout();
9090
}
9191
});
9292
mockStream.Setup(s => s.CanRead).Returns(true);

0 commit comments

Comments
 (0)