Skip to content

Commit

Permalink
Increase timeouts for some tests
Browse files Browse the repository at this point in the history
They're randomly failing on VSTS. I assume the machine is just a bit
slow/overloaded. This is the most sequential 'async' code imaginable.
It's hard to believe it's racey.
  • Loading branch information
alanmcgovern committed Jul 28, 2024
1 parent 38d003c commit 816e337
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
using System.Threading.Tasks;

using MonoTorrent.BEncoding;
using MonoTorrent.Connections;
using MonoTorrent.Connections.Tracker;
using MonoTorrent.Connections.TrackerServer;
using MonoTorrent.Messages.UdpTracker;
Expand Down Expand Up @@ -334,17 +335,19 @@ public async Task AnnounceTest_NoConnect ()
[Test]
public async Task AnnounceTest_NoConnect_ThenConnect ()
{
trackerConnection.RetryDelay = TimeSpan.Zero;
Assert.AreEqual (listener.Status, ListenerStatus.Listening, "listener is listening");

trackerConnection.RetryDelay = TimeSpan.FromSeconds(0);
listener.IgnoreConnects = true;
var response = await tracker.AnnounceAsync (announceparams, CancellationToken.None).WithTimeout ();
Assert.AreEqual (TrackerState.Offline, tracker.Status);
Assert.AreEqual (TrackerState.Offline, response.State);
Assert.AreEqual (TrackerState.Offline, tracker.Status, "tracker status should be offline");
Assert.AreEqual (TrackerState.Offline, response.State, "response status shoudl be offline");

trackerConnection.RetryDelay = TimeSpan.FromSeconds (5);
listener.IgnoreConnects = false;
response = await tracker.AnnounceAsync (announceparams, CancellationToken.None);
Assert.AreEqual (TrackerState.Ok, tracker.Status);
Assert.AreEqual (TrackerState.Ok, response.State);
Assert.AreEqual (TrackerState.Ok, tracker.Status, "tracker status should be ok");
Assert.AreEqual (TrackerState.Ok, response.State, "response status should be ok");
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Tests.MonoTorrent.Client/TaskExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ namespace MonoTorrent
{
static class TaskExtensions
{
static readonly TimeSpan Timeout = System.Diagnostics.Debugger.IsAttached ? TimeSpan.FromHours (1) : TimeSpan.FromSeconds (5);
static readonly TimeSpan Timeout = System.Diagnostics.Debugger.IsAttached ? TimeSpan.FromHours (1) : TimeSpan.FromSeconds (10);

public static T TakeWithTimeout<T> (this BlockingCollection<T> collection, string message = null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public async Task ReplaceNodeTest ()
Node nodeToReplace = engine.RoutingTable.Buckets[0].Nodes[3];

ReplaceNodeTask task = new ReplaceNodeTask (engine, engine.RoutingTable.Buckets[0], replacement);
await task.Execute ().WithTimeout (1000);
await task.Execute ().WithTimeout ();
Assert.IsFalse (engine.RoutingTable.Buckets[0].Nodes.Contains (nodeToReplace), "#1");
Assert.IsTrue (engine.RoutingTable.Buckets[0].Nodes.Contains (replacement), "#2");
}
Expand Down

0 comments on commit 816e337

Please sign in to comment.