mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-04 04:34:26 -04:00
Report pending latch counts on network stress test timeouts
This commit is contained in:
parent
97e6b942d3
commit
8eefecdc9c
1 changed files with 14 additions and 8 deletions
|
@ -197,11 +197,11 @@ public class NetworkStressTest {
|
||||||
@Test
|
@Test
|
||||||
public void test() throws InterruptedException {
|
public void test() throws InterruptedException {
|
||||||
// Wait for peers to get their preliminary data.
|
// Wait for peers to get their preliminary data.
|
||||||
org.junit.Assert.assertTrue("timed out while waiting for preliminary data",
|
assertLatch("timed out while waiting for preliminary data",
|
||||||
prelimDataLatch.await(30, TimeUnit.SECONDS));
|
prelimDataLatch, 30, TimeUnit.SECONDS);
|
||||||
// Wait for peers to complete their bootstrapping.
|
// Wait for peers to complete their bootstrapping.
|
||||||
org.junit.Assert.assertTrue("timed out while waiting for bootstrap",
|
assertLatch("timed out while waiting for bootstrap",
|
||||||
bootstrapLatch.await(30, TimeUnit.SECONDS));
|
bootstrapLatch, 30, TimeUnit.SECONDS);
|
||||||
|
|
||||||
// Test each peer sending a direct message to another random peer.
|
// Test each peer sending a direct message to another random peer.
|
||||||
final int nPeers = peerNodes.size();
|
final int nPeers = peerNodes.size();
|
||||||
|
@ -252,14 +252,14 @@ public class NetworkStressTest {
|
||||||
/** Time to transmit all messages in the worst random case, and with no computation delays. */
|
/** Time to transmit all messages in the worst random case, and with no computation delays. */
|
||||||
final long idealMaxDirectDelay = MAX_DIRECT_DELAY_MILLIS * directCount;
|
final long idealMaxDirectDelay = MAX_DIRECT_DELAY_MILLIS * directCount;
|
||||||
// Wait for peers to complete receiving. We are generous here.
|
// Wait for peers to complete receiving. We are generous here.
|
||||||
org.junit.Assert.assertTrue("timed out while receiving direct messages",
|
assertLatch("timed out while receiving direct messages",
|
||||||
receivedDirectLatch.await(2 * idealMaxDirectDelay, TimeUnit.MILLISECONDS));
|
receivedDirectLatch, 2 * idealMaxDirectDelay, TimeUnit.MILLISECONDS);
|
||||||
print("receiving %d direct messages per peer took %ss", directCount,
|
print("receiving %d direct messages per peer took %ss", directCount,
|
||||||
(System.currentTimeMillis() - sendStartMillis)/1000.0);
|
(System.currentTimeMillis() - sendStartMillis)/1000.0);
|
||||||
// Wait for peers to complete sending.
|
// Wait for peers to complete sending.
|
||||||
// This should be nearly instantaneous after waiting for reception is completed.
|
// This should be nearly instantaneous after waiting for reception is completed.
|
||||||
org.junit.Assert.assertTrue("timed out while sending direct messages",
|
assertLatch("timed out while sending direct messages",
|
||||||
sentDirectLatch.await(idealMaxDirectDelay / 10, TimeUnit.MILLISECONDS));
|
sentDirectLatch, idealMaxDirectDelay / 10, TimeUnit.MILLISECONDS);
|
||||||
print("sending %d direct messages per peer took %ss", directCount,
|
print("sending %d direct messages per peer took %ss", directCount,
|
||||||
(System.currentTimeMillis() - sendStartMillis)/1000.0);
|
(System.currentTimeMillis() - sendStartMillis)/1000.0);
|
||||||
org.junit.Assert.assertFalse("some peer(s) failed to send a direct message", sentDirectFailed.get());
|
org.junit.Assert.assertFalse("some peer(s) failed to send a direct message", sentDirectFailed.get());
|
||||||
|
@ -270,6 +270,12 @@ public class NetworkStressTest {
|
||||||
+ String.format(message, args));
|
+ String.format(message, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void assertLatch(String message, CountDownLatch latch, long timeout, TimeUnit unit)
|
||||||
|
throws InterruptedException {
|
||||||
|
if (!latch.await(timeout, unit))
|
||||||
|
org.junit.Assert.fail(String.format("%s (%d pending in latch)", message, latch.getCount()));
|
||||||
|
}
|
||||||
|
|
||||||
private Path createTestDataDirectory() throws IOException {
|
private Path createTestDataDirectory() throws IOException {
|
||||||
Path stressTestDirPath;
|
Path stressTestDirPath;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue