mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-01 19:26:09 -04:00
Show progress of network stress test operations
This commit is contained in:
parent
ac3dbe9160
commit
663cd82432
1 changed files with 22 additions and 4 deletions
|
@ -100,6 +100,24 @@ public class NetworkStressTest {
|
||||||
System.exit(result.wasSuccessful() ? 0 : 1);
|
System.exit(result.wasSuccessful() ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Return a string of a character repeated a number of times. */
|
||||||
|
private static String nChars(char c, int n) {
|
||||||
|
String ret = "";
|
||||||
|
for (int i = 0; i < n; i++)
|
||||||
|
ret += c;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Decrease latch count and print pending as a progress bar based on the given character. */
|
||||||
|
private void countDownAndPrint(CountDownLatch latch, char c) {
|
||||||
|
latch.countDown();
|
||||||
|
int remaining = (int)latch.getCount();
|
||||||
|
if (remaining > 0)
|
||||||
|
System.err.print(String.format("\r%s: %s ", this.getClass().getSimpleName(), nChars(c, remaining)));
|
||||||
|
if (remaining == 1)
|
||||||
|
System.err.println();
|
||||||
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
// Parse test parameter environment variables.
|
// Parse test parameter environment variables.
|
||||||
|
@ -235,11 +253,11 @@ public class NetworkStressTest {
|
||||||
|
|
||||||
// Stop peer nodes.
|
// Stop peer nodes.
|
||||||
for (P2PService peer : peerNodes) {
|
for (P2PService peer : peerNodes) {
|
||||||
peer.shutDown(shutdownLatch::countDown);
|
peer.shutDown(() -> countDownAndPrint(shutdownLatch, '.'));
|
||||||
}
|
}
|
||||||
// Stop the seed node.
|
// Stop the seed node.
|
||||||
if (seedNode != null) {
|
if (seedNode != null) {
|
||||||
seedNode.shutDown(shutdownLatch::countDown);
|
seedNode.shutDown(() -> countDownAndPrint(shutdownLatch, '.'));
|
||||||
}
|
}
|
||||||
// Wait for concurrent tasks to finish.
|
// Wait for concurrent tasks to finish.
|
||||||
shutdownLatch.await();
|
shutdownLatch.await();
|
||||||
|
@ -531,7 +549,7 @@ public class NetworkStressTest {
|
||||||
@Override
|
@Override
|
||||||
public void onRequestingDataCompleted() {
|
public void onRequestingDataCompleted() {
|
||||||
// preliminary data received
|
// preliminary data received
|
||||||
prelimDataLatch.countDown();
|
countDownAndPrint(prelimDataLatch, 'p');
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -547,7 +565,7 @@ public class NetworkStressTest {
|
||||||
@Override
|
@Override
|
||||||
public void onBootstrapComplete() {
|
public void onBootstrapComplete() {
|
||||||
// peer bootstrapped
|
// peer bootstrapped
|
||||||
bootstrapLatch.countDown();
|
countDownAndPrint(bootstrapLatch, 'b');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue