From 2a24ce94a304c668eb9a685333b8e0fe49ff8183 Mon Sep 17 00:00:00 2001 From: Ivan Vilata-i-Balaguer Date: Wed, 18 May 2016 12:40:13 +0200 Subject: [PATCH] Constant for mailbox message delay in network stress test --- .../io/bitsquare/p2p/network/NetworkStressTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/network/src/test/java/io/bitsquare/p2p/network/NetworkStressTest.java b/network/src/test/java/io/bitsquare/p2p/network/NetworkStressTest.java index 6c8bfb9ee6..de487e4284 100644 --- a/network/src/test/java/io/bitsquare/p2p/network/NetworkStressTest.java +++ b/network/src/test/java/io/bitsquare/p2p/network/NetworkStressTest.java @@ -71,6 +71,8 @@ public class NetworkStressTest { private static long MIN_DIRECT_DELAY_MILLIS = Math.round(1.25 * (1.0 / Connection.MSG_THROTTLE_PER_SEC) * 1000); /** Maximum delay between direct messages in milliseconds, 10 times larger than minimum. */ private static long MAX_DIRECT_DELAY_MILLIS = 10 * MIN_DIRECT_DELAY_MILLIS; + /** Estimated delay in seconds to send or receive a mailbox message. */ + private static long MAILBOX_DELAY_SECS = 2; // Instance fields @@ -613,9 +615,8 @@ public class NetworkStressTest { } }); } - // TODO: Use meaningful timeout. assertLatch("timed out while sending from peer " + firstOnline, - sendLatch, 2 * mailboxCount, TimeUnit.SECONDS); + sendLatch, MAILBOX_DELAY_SECS * mailboxCount, TimeUnit.SECONDS); // When done, put first online peer offline. final CountDownLatch stopLatch = new CountDownLatch(1); @@ -631,12 +632,11 @@ public class NetworkStressTest { peerNodes.set(firstOffline, startedPeer); startedPeer.start(new MailboxStartListener(startLatch)); assertLatch("timed out while starting peer " + firstOffline, - startLatch, 10, TimeUnit.SECONDS); + startLatch, 10 + MAILBOX_DELAY_SECS * nPeers, TimeUnit.SECONDS); //print("put peer %d online", firstOffline); } - // TODO: Use meaningful timeout. assertLatch("timed out while receiving mailbox messages", - receivedMailboxLatch, 120, TimeUnit.SECONDS); + receivedMailboxLatch, 2 * (MAILBOX_DELAY_SECS + 1) * nPeers * mailboxCount, TimeUnit.SECONDS); org.junit.Assert.assertFalse("some peer(s) failed to send a message", sentMailboxFailed.get()); }