From 1910b66aef09c2ce6104eecb2baf05043f1b64a2 Mon Sep 17 00:00:00 2001 From: Ivan Vilata-i-Balaguer Date: Tue, 26 Apr 2016 14:04:41 +0200 Subject: [PATCH] Wait for peer nodes bootstrap in network stress test Once it threw a ``ConcurrentModificationException`` while shutting down but I've not been able to reproduce it, so keep an eye on it happening again. --- .../java/io/bitsquare/p2p/network/NetworkStressTest.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 603dfb0380..4dc0e00822 100644 --- a/network/src/test/java/io/bitsquare/p2p/network/NetworkStressTest.java +++ b/network/src/test/java/io/bitsquare/p2p/network/NetworkStressTest.java @@ -55,6 +55,8 @@ public class NetworkStressTest { /** A barrier to wait for concurrent reception of preliminary data in peers. */ private CountDownLatch prelimDataLatch = new CountDownLatch(NPEERS); + /** A barrier to wait for concurrent bootstrap of peers. */ + private CountDownLatch bootstrapLatch = new CountDownLatch(NPEERS); @Before public void setUp() throws Exception { @@ -146,7 +148,8 @@ public class NetworkStressTest { @Override public void onBootstrapComplete() { - // do nothing + // successful result + NetworkStressTest.this.bootstrapLatch.countDown(); } @Override @@ -195,6 +198,9 @@ public class NetworkStressTest { // Wait for peers to get their preliminary data. org.junit.Assert.assertTrue("timed out while waiting for preliminary data", prelimDataLatch.await(30, TimeUnit.SECONDS)); + // Wait for peers to complete their bootstrapping. + org.junit.Assert.assertTrue("timed out while waiting for bootstrap", + bootstrapLatch.await(30, TimeUnit.SECONDS)); } private Path createTempDirectory() throws IOException {