Skip to content

Commit

Permalink
more test deflaking (#4263)
Browse files Browse the repository at this point in the history
  • Loading branch information
analogrelay committed Nov 9, 2018
1 parent 98fa28d commit 355310a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public async Task ReconnectExceedingReconnectWindowDisconnects(HostType hostType
await connection.Start(host.Transport);

// Without this the connection start and reconnect can race with eachother resulting in a deadlock.
Thread.Sleep(TimeSpan.FromSeconds(3));
await Task.Delay(TimeSpan.FromSeconds(3));

host.Shutdown();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ public async Task RejoiningGroupsOnlyReceivesGroupsBelongingToHub()
var proxy = connection.CreateHubProxy("MultGroupHub");
var proxy2 = connection.CreateHubProxy("MultGroupHub2");

await connection.Start(host);
await connection.Start(host).OrTimeout();

var user = new User { Name = "tester" };
await proxy.Invoke("login", user).OrTimeout();
Expand All @@ -1409,14 +1409,14 @@ public async Task RejoiningGroupsOnlyReceivesGroupsBelongingToHub()

await Task.Delay(TimeSpan.FromSeconds(3));

Assert.True(logRejoiningGroups.GroupsRejoined["MultGroupHub"].Contains("foo"));
Assert.True(logRejoiningGroups.GroupsRejoined["MultGroupHub"].Contains("tester"));
Assert.False(logRejoiningGroups.GroupsRejoined["MultGroupHub"].Contains("foo2"));
Assert.False(logRejoiningGroups.GroupsRejoined["MultGroupHub"].Contains("tester2"));
Assert.True(logRejoiningGroups.GroupsRejoined["MultGroupHub2"].Contains("foo2"));
Assert.True(logRejoiningGroups.GroupsRejoined["MultGroupHub2"].Contains("tester2"));
Assert.False(logRejoiningGroups.GroupsRejoined["MultGroupHub2"].Contains("foo"));
Assert.False(logRejoiningGroups.GroupsRejoined["MultGroupHub2"].Contains("tester"));
Assert.Contains("foo", logRejoiningGroups.GroupsRejoined["MultGroupHub"]);
Assert.Contains("tester", logRejoiningGroups.GroupsRejoined["MultGroupHub"]);
Assert.DoesNotContain("foo2", logRejoiningGroups.GroupsRejoined["MultGroupHub"]);
Assert.DoesNotContain("tester2", logRejoiningGroups.GroupsRejoined["MultGroupHub"]);
Assert.Contains("foo2", logRejoiningGroups.GroupsRejoined["MultGroupHub2"]);
Assert.Contains("tester2", logRejoiningGroups.GroupsRejoined["MultGroupHub2"]);
Assert.DoesNotContain("foo", logRejoiningGroups.GroupsRejoined["MultGroupHub2"]);
Assert.DoesNotContain("tester", logRejoiningGroups.GroupsRejoined["MultGroupHub2"]);
}
}
}
Expand Down Expand Up @@ -1512,7 +1512,7 @@ public async Task ReturningNullFromConnectAndDisconnectAccepted()
var connection = new HubConnection("http://foo");

var hub = connection.CreateHubProxy("SomeHub");
await connection.Start(host);
await connection.Start(host).OrTimeout();

connection.Stop();
await Task.Delay(TimeSpan.FromSeconds(3));
Expand Down Expand Up @@ -1549,7 +1549,7 @@ public async Task ReturningNullFromReconnectAccepted()
var connection = new HubConnection("http://foo");

var hub = connection.CreateHubProxy("SomeHub");
await connection.Start(host);
await connection.Start(host).OrTimeout();

// Force Reconnect
await Task.Delay(TimeSpan.FromSeconds(3));
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,7 +12,7 @@ class AddGroupOnConnectedConnection : PersistentConnection
protected override async Task OnConnected(IRequest request, string connectionId)
{
await Groups.Add(connectionId, "test");
Thread.Sleep(TimeSpan.FromSeconds(1));
await Task.Delay(TimeSpan.FromSeconds(1));
await Groups.Add(connectionId, "test2");
}

Expand Down

0 comments on commit 355310a

Please sign in to comment.