Skip to content

Commit f88dfa0

Browse files
committed
Raise one timeout from 5 seconds to 20 seconds.
Some CI is just slower than others. The ConnectionPair has been configured to time out and dispose connections after 5 seconds. After making some of the test execution in CI happen in parallel it has begun triggering. Urgh.
1 parent e533134 commit f88dfa0

File tree

11 files changed

+15
-14
lines changed

11 files changed

+15
-14
lines changed

src/Tests/Tests.MonoTorrent.Client/MonoTorrent.Client.Modes/DownloadModeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class DownloadModeTests
5959
[SetUp]
6060
public void Setup ()
6161
{
62-
conn = new ConnectionPair ().WithTimeout ();
62+
conn = new ConnectionPair ().DisposeAfterTimeout ();
6363
Settings = new EngineSettings ();
6464
PieceWriter = new TestWriter ();
6565
DiskManager = new DiskManager (Settings, Factories.Default, PieceWriter);

src/Tests/Tests.MonoTorrent.Client/MonoTorrent.Client.Modes/HashingModeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class HashingModeTests
5656
public void Setup ()
5757
{
5858
TempDirectory = TempDir.Create ();
59-
conn = new ConnectionPair ().WithTimeout ();
59+
conn = new ConnectionPair ().DisposeAfterTimeout ();
6060
PieceWriter = new TestWriter ();
6161
TrackerManager = new ManualTrackerManager ();
6262

src/Tests/Tests.MonoTorrent.Client/MonoTorrent.Client.Modes/MetadataModeTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
using System.Threading.Tasks;
3838

3939
using MonoTorrent.Connections.Peer.Encryption;
40+
using MonoTorrent.Logging;
4041
using MonoTorrent.Messages.Peer;
4142
using MonoTorrent.Messages.Peer.FastPeer;
4243
using MonoTorrent.Messages.Peer.Libtorrent;
@@ -56,7 +57,8 @@ public class MetadataModeTests
5657

5758
public async Task Setup (bool metadataMode, bool multiFile = false, bool metadataOnly = false)
5859
{
59-
pair = new ConnectionPair ().WithTimeout ();
60+
LoggerFactory.Register (new TextWriterLogger (TestContext.Out));
61+
pair = new ConnectionPair ().DisposeAfterTimeout ();
6062
rig = multiFile ? TestRig.CreateMultiFile (32768, metadataMode) : TestRig.CreateSingleFile (Constants.BlockSize * 27, Constants.BlockSize * 2, metadataMode);
6163
rig.RecreateManager ().Wait ();
6264

@@ -80,6 +82,7 @@ public async Task Teardown ()
8082
await rig.Manager.StopAsync ();
8183
pair.Dispose ();
8284
rig.Dispose ();
85+
LoggerFactory.Register (null);
8386
}
8487

8588
[Test]

src/Tests/Tests.MonoTorrent.Client/MonoTorrent.Client.Modes/StartingModeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class StartingModeTests
5252
[SetUp]
5353
public void Setup ()
5454
{
55-
conn = new ConnectionPair ().WithTimeout ();
55+
conn = new ConnectionPair ().DisposeAfterTimeout ();
5656
Settings = new EngineSettings ();
5757
PieceWriter = new TestWriter ();
5858
DiskManager = new DiskManager (Settings, Factories.Default, PieceWriter);

src/Tests/Tests.MonoTorrent.Client/MonoTorrent.Client.Modes/StoppedModeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class StoppedModeTests
5151
[SetUp]
5252
public void Setup ()
5353
{
54-
conn = new ConnectionPair ().WithTimeout ();
54+
conn = new ConnectionPair ().DisposeAfterTimeout ();
5555
Settings = new EngineSettings ();
5656
DiskManager = new DiskManager (Settings, Factories.Default, new NullWriter ());
5757
ConnectionManager = new ConnectionManager ("LocalPeerId", Settings, Factories.Default, DiskManager);

src/Tests/Tests.MonoTorrent.Client/MonoTorrent.Client.Modes/StoppingModeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class StoppingModeTests
5252
[SetUp]
5353
public void Setup ()
5454
{
55-
conn = new ConnectionPair ().WithTimeout ();
55+
conn = new ConnectionPair ().DisposeAfterTimeout ();
5656
Settings = new EngineSettings ();
5757
DiskManager = new DiskManager (Settings, Factories.Default, new NullWriter ());
5858
ConnectionManager = new ConnectionManager ("LocalPeerId", Settings, Factories.Default, DiskManager);

src/Tests/Tests.MonoTorrent.Client/MonoTorrent.Client/EncryptorFactoryTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class EncryptorFactoryTests
5858
[SetUp]
5959
public void Setup ()
6060
{
61-
pair = new ConnectionPair ().WithTimeout ();
61+
pair = new ConnectionPair ().DisposeAfterTimeout ();
6262

6363
InfoHash = new InfoHash (Enumerable.Repeat ((byte) 255, 20).ToArray ());
6464
SKeys = new[] {

src/Tests/Tests.MonoTorrent.Client/MonoTorrent.Client/NetworkIOTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public class NetworkIOTests
5252
[SetUp]
5353
public void Setup ()
5454
{
55-
pair = new ConnectionPair ().WithTimeout ();
55+
pair = new ConnectionPair ().DisposeAfterTimeout ();
5656
}
5757

5858
[TearDown]

src/Tests/Tests.MonoTorrent.Client/MonoTorrent.Client/PeerIOTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class PeerIOTests
4646
[SetUp]
4747
public void Setup ()
4848
{
49-
pair = new ConnectionPair ().WithTimeout ();
49+
pair = new ConnectionPair ().DisposeAfterTimeout ();
5050
}
5151

5252
[TearDown]

src/Tests/Tests.MonoTorrent.Client/MonoTorrent.Client/TestRig.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,6 @@ public void Add (TorrentManager manager, IPeerConnection connection)
317317

318318
public class ConnectionPair : IDisposable
319319
{
320-
static readonly TimeSpan Timeout = System.Diagnostics.Debugger.IsAttached ? TimeSpan.FromHours (1) : TimeSpan.FromSeconds (5);
321-
322320
IDisposable CancellationRegistration { get; set; }
323321

324322
public CustomConnection Incoming { get; }
@@ -339,9 +337,9 @@ public void Dispose ()
339337
Outgoing.Dispose ();
340338
}
341339

342-
public ConnectionPair WithTimeout ()
340+
public ConnectionPair DisposeAfterTimeout ()
343341
{
344-
CancellationTokenSource cancellation = new CancellationTokenSource (Timeout);
342+
CancellationTokenSource cancellation = new CancellationTokenSource (TaskExtensions.Timeout);
345343
CancellationRegistration = cancellation.Token.Register (Dispose);
346344
return this;
347345
}

0 commit comments

Comments
 (0)