Add condition checks to stabilize BFT soaking test (#8379)

* Add delays to stabilize BFT soaking test

Signed-off-by: Bhanu Pulluri <bhanu.pulluri@kaleido.io>

* Enable specifying timeout for peer discovery in ATs

Signed-off-by: Bhanu Pulluri <bhanu.pulluri@kaleido.io>

---------

Signed-off-by: Bhanu Pulluri <bhanu.pulluri@kaleido.io>
Signed-off-by: Bhanu Pulluri <59369753+pullurib@users.noreply.github.com>
Co-authored-by: Bhanu Pulluri <bhanu.pulluri@kaleido.io>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
This commit is contained in:
Bhanu Pulluri
2025-03-13 19:25:52 -04:00
committed by GitHub
parent 5215c953e0
commit f39b90bd25
6 changed files with 37 additions and 8 deletions

View File

@@ -27,15 +27,25 @@ public class AwaitNetPeerCount implements Condition {
private final NetPeerCountTransaction transaction;
private final BigInteger expectedPeerCount;
private final int timeout;
public AwaitNetPeerCount(
final NetPeerCountTransaction transaction, final BigInteger expectedPeerCount) {
this(transaction, expectedPeerCount, 30);
}
public AwaitNetPeerCount(
final NetPeerCountTransaction transaction,
final BigInteger expectedPeerCount,
final int timeout) {
this.transaction = transaction;
this.expectedPeerCount = expectedPeerCount;
this.timeout = timeout;
}
@Override
public void verify(final Node node) {
WaitUtils.waitFor(50, () -> assertThat(node.execute(transaction)).isEqualTo(expectedPeerCount));
WaitUtils.waitFor(
timeout, () -> assertThat(node.execute(transaction)).isEqualTo(expectedPeerCount));
}
}

View File

@@ -47,6 +47,11 @@ public class NetConditions {
return new AwaitNetPeerCount(transactions.peerCount(), BigInteger.valueOf(awaitPeerCount));
}
public Condition awaitPeerCount(final int awaitPeerCount, final int timeout) {
return new AwaitNetPeerCount(
transactions.peerCount(), BigInteger.valueOf(awaitPeerCount), timeout);
}
public Condition netVersionExceptional(final String expectedMessage) {
return new ExpectNetVersionConnectionException(transactions.netVersion(), expectedMessage);
}

View File

@@ -91,12 +91,14 @@ public class Cluster implements AutoCloseable {
.forEach(this::startNode);
if (clusterConfiguration.isAwaitPeerDiscovery()) {
int timeoutSeconds = clusterConfiguration.getPeerDiscoveryTimeoutSeconds();
for (final RunnableNode node : nodes) {
LOG.info(
"Awaiting peer discovery for node {}, expecting {} peers",
"Awaiting peer discovery for node {}, expecting {} peers, timeout {} seconds",
node.getName(),
nodes.size() - 1);
node.awaitPeerDiscovery(net.awaitPeerCount(nodes.size() - 1));
nodes.size() - 1,
timeoutSeconds);
node.awaitPeerDiscovery(net.awaitPeerCount(nodes.size() - 1, timeoutSeconds));
}
}
LOG.info("Cluster startup complete.");

View File

@@ -17,12 +17,18 @@ package org.hyperledger.besu.tests.acceptance.dsl.node.cluster;
public class ClusterConfiguration {
private final boolean awaitPeerDiscovery;
private final int peerDiscoveryTimeoutSeconds;
ClusterConfiguration(final boolean awaitPeerDiscovery) {
ClusterConfiguration(final boolean awaitPeerDiscovery, final int peerDiscoveryTimeoutSeconds) {
this.awaitPeerDiscovery = awaitPeerDiscovery;
this.peerDiscoveryTimeoutSeconds = peerDiscoveryTimeoutSeconds;
}
public boolean isAwaitPeerDiscovery() {
return awaitPeerDiscovery;
}
public int getPeerDiscoveryTimeoutSeconds() {
return peerDiscoveryTimeoutSeconds;
}
}

View File

@@ -16,13 +16,19 @@ package org.hyperledger.besu.tests.acceptance.dsl.node.cluster;
public class ClusterConfigurationBuilder {
private boolean awaitPeerDiscovery = true;
private int peerDiscoveryTimeoutSeconds = 60; // Default 60 second timeout
public ClusterConfigurationBuilder awaitPeerDiscovery(final boolean awaitPeerDiscovery) {
this.awaitPeerDiscovery = awaitPeerDiscovery;
return this;
}
public ClusterConfigurationBuilder peerDiscoveryTimeout(final int timeoutSeconds) {
this.peerDiscoveryTimeoutSeconds = timeoutSeconds;
return this;
}
public ClusterConfiguration build() {
return new ClusterConfiguration(awaitPeerDiscovery);
return new ClusterConfiguration(awaitPeerDiscovery, peerDiscoveryTimeoutSeconds);
}
}

View File

@@ -155,9 +155,9 @@ public class BftMiningSoakTest extends ParameterizedBftTestBase {
chainHeight = minerNode1.execute(ethTransactions.blockNumber());
lastChainHeight = chainHeight;
// Leave the chain stalled for 3 minutes. Check no new blocks are mined. Then
// Leave the chain stalled for 1 minute. Check no new blocks are mined. Then
// resume the other validators.
nextStepEndTime = previousStepEndTime.plus(3, ChronoUnit.MINUTES);
nextStepEndTime = previousStepEndTime.plus(1, ChronoUnit.MINUTES);
while (System.currentTimeMillis() < nextStepEndTime.toEpochMilli()) {
Thread.sleep(ONE_MINUTE);
chainHeight = minerNode1.execute(ethTransactions.blockNumber());