Skip to content

Fix flaky HubConnectionHandler test #18388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 16, 2020
Merged

Fix flaky HubConnectionHandler test #18388

merged 2 commits into from
Jan 16, 2020

Conversation

BrennanConroy
Copy link
Member

There was a race where the test assumed certain state and ran some code before that state was true.

@BrennanConroy BrennanConroy added the area-signalr Includes: SignalR clients and servers label Jan 16, 2020
@dougbu
Copy link
Contributor

dougbu commented Jan 16, 2020

Not looking at the details of this. But, I'm very glad to see the fix is coming. Thanks @BrennanConroy

@@ -2813,6 +2875,9 @@ public async Task HubMethodInvokeDoesNotCountTowardsClientTimeout()

using (var client = new TestClient(new JsonHubProtocol()))
{
var customDuplex = new CustomDuplex(client.Connection.Transport);
client.Connection.Transport = customDuplex;

var connectionHandlerTask = await client.ConnectAsync(connectionHandler);
// This starts the timeout logic
await client.SendHubMessageAsync(PingMessage.Instance);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a risk that the client will timeout between sending the ping and invoking the long running method given the ClientTimeoutInterval is 0 seconds? Can we use a mock system clock or something like that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a risk that the client will timeout between sending the ping and invoking the long running method given the ClientTimeoutInterval is 0 seconds? Can we use a mock system clock or something like that?

No risk because that logic lives in HttpConnectionManager and we are only working with the HubConnectionHandler layer.


public bool IsWaitingForRead()
{
return _waitingForRead;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make the test pass faster by using a TCS to implement a WaitForRead method that returns a task that completes once a read starts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that but was worried I'd have to write a bunch of synchronization logic to make sure the TCS is reset properly. I'll try it out, the test logic would look a lot nicer if we used a TCS...

@analogrelay analogrelay added the tell-mode Indicates a PR which is being merged during tell-mode label Jan 16, 2020
@analogrelay
Copy link
Contributor

analogrelay commented Jan 16, 2020

Test-only change, so tell-mode. If we can get review signoff (poke @halter73) I can merge this whenever 3.0 is open (and I think it still is today)

@Pilchie
Copy link
Member

Pilchie commented Jan 16, 2020

Yes, let's take this today while dependencies are still flowing.

@analogrelay analogrelay added this to the 3.0.3 milestone Jan 16, 2020
@analogrelay analogrelay merged commit bd11e95 into release/3.0 Jan 16, 2020
@analogrelay analogrelay deleted the brecon/test branch January 16, 2020 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-signalr Includes: SignalR clients and servers tell-mode Indicates a PR which is being merged during tell-mode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants