mirror of
https://github.com/vacp2p/linea-besu.git
synced 2026-01-08 04:33:56 -05:00
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:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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.");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user