From 0ec335fbf1a5b2156a47c861a1f7a281287544a1 Mon Sep 17 00:00:00 2001 From: Matt Whitehead Date: Wed, 21 Aug 2024 09:42:52 +0100 Subject: [PATCH] BFT soak test - use both db modes (#7496) * For test node runners use provided data storage config Signed-off-by: Matthew Whitehead * Make the BFT soak mining tests use both Forest and Bonsai DBs Signed-off-by: Matthew Whitehead --------- Signed-off-by: Matthew Whitehead --- .../node/configuration/BesuNodeFactory.java | 19 +++++++++++++++++-- .../BftAcceptanceTestParameterization.java | 15 +++++++++++---- .../acceptance/bftsoak/BftMiningSoakTest.java | 9 +++++---- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java index ed4a28422d..efbf91246b 100644 --- a/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java +++ b/acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/configuration/BesuNodeFactory.java @@ -32,7 +32,9 @@ import org.hyperledger.besu.ethereum.core.MiningParameters; import org.hyperledger.besu.ethereum.core.PrivacyParameters; import org.hyperledger.besu.ethereum.permissioning.LocalPermissioningConfiguration; import org.hyperledger.besu.ethereum.permissioning.PermissioningConfiguration; +import org.hyperledger.besu.ethereum.worldstate.DataStorageConfiguration; import org.hyperledger.besu.pki.keystore.KeyStoreWrapper; +import org.hyperledger.besu.plugin.services.storage.DataStorageFormat; import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; import org.hyperledger.besu.tests.acceptance.dsl.node.Node; import org.hyperledger.besu.tests.acceptance.dsl.node.RunnableNode; @@ -476,7 +478,9 @@ public class BesuNodeFactory { .build()); } - public BesuNode createIbft2Node(final String name, final boolean fixedPort) throws IOException { + public BesuNode createIbft2Node( + final String name, final boolean fixedPort, final DataStorageFormat storageFormat) + throws IOException { JsonRpcConfiguration rpcConfig = node.createJsonRpcWithIbft2EnabledConfig(false); rpcConfig.addRpcApi("ADMIN,TXPOOL"); if (fixedPort) { @@ -484,6 +488,7 @@ public class BesuNodeFactory { Math.abs(name.hashCode() % 60000) + 1024); // Generate a consistent port for p2p based on node name } + BesuNodeConfigurationBuilder builder = new BesuNodeConfigurationBuilder() .name(name) @@ -491,6 +496,10 @@ public class BesuNodeFactory { .jsonRpcConfiguration(rpcConfig) .webSocketConfiguration(node.createWebSocketEnabledConfig()) .devMode(false) + .dataStorageConfiguration( + storageFormat == DataStorageFormat.FOREST + ? DataStorageConfiguration.DEFAULT_FOREST_CONFIG + : DataStorageConfiguration.DEFAULT_BONSAI_CONFIG) .genesisConfigProvider(GenesisConfigurationFactory::createIbft2GenesisConfig); if (fixedPort) { builder.p2pPort( @@ -527,7 +536,9 @@ public class BesuNodeFactory { return createQbftNodeWithTLS(name, KeyStoreWrapper.KEYSTORE_TYPE_PKCS11); } - public BesuNode createQbftNode(final String name, final boolean fixedPort) throws IOException { + public BesuNode createQbftNode( + final String name, final boolean fixedPort, final DataStorageFormat storageFormat) + throws IOException { JsonRpcConfiguration rpcConfig = node.createJsonRpcWithQbftEnabledConfig(false); rpcConfig.addRpcApi("ADMIN,TXPOOL"); if (fixedPort) { @@ -543,6 +554,10 @@ public class BesuNodeFactory { .jsonRpcConfiguration(rpcConfig) .webSocketConfiguration(node.createWebSocketEnabledConfig()) .devMode(false) + .dataStorageConfiguration( + storageFormat == DataStorageFormat.FOREST + ? DataStorageConfiguration.DEFAULT_FOREST_CONFIG + : DataStorageConfiguration.DEFAULT_BONSAI_CONFIG) .genesisConfigProvider(GenesisConfigurationFactory::createQbftGenesisConfig); if (fixedPort) { builder.p2pPort( diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftAcceptanceTestParameterization.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftAcceptanceTestParameterization.java index 15872070d0..2351f740bf 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftAcceptanceTestParameterization.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bft/BftAcceptanceTestParameterization.java @@ -14,6 +14,7 @@ */ package org.hyperledger.besu.tests.acceptance.bft; +import org.hyperledger.besu.plugin.services.storage.DataStorageFormat; import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.BesuNodeFactory; @@ -38,7 +39,9 @@ public class BftAcceptanceTestParameterization { @FunctionalInterface public interface NodeCreator { - BesuNode create(BesuNodeFactory factory, String name, boolean fixedPort) throws Exception; + BesuNode create( + BesuNodeFactory factory, String name, boolean fixedPort, DataStorageFormat storageFormat) + throws Exception; } @FunctionalInterface @@ -64,11 +67,15 @@ public class BftAcceptanceTestParameterization { } public BesuNode createNode(BesuNodeFactory factory, String name) throws Exception { - return creatorFn.create(factory, name, false); + return creatorFn.create(factory, name, false, DataStorageFormat.FOREST); + } + + public BesuNode createBonsaiNodeFixedPort(BesuNodeFactory factory, String name) throws Exception { + return creatorFn.create(factory, name, true, DataStorageFormat.BONSAI); } - public BesuNode createNodeFixedPort(BesuNodeFactory factory, String name) throws Exception { - return creatorFn.create(factory, name, true); + public BesuNode createForestNodeFixedPort(BesuNodeFactory factory, String name) throws Exception { + return creatorFn.create(factory, name, true, DataStorageFormat.FOREST); } public BesuNode createNodeWithValidators( diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bftsoak/BftMiningSoakTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bftsoak/BftMiningSoakTest.java index 9861a7dab6..878e503ba3 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bftsoak/BftMiningSoakTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bftsoak/BftMiningSoakTest.java @@ -60,10 +60,11 @@ public class BftMiningSoakTest extends ParameterizedBftTestBase { // in between certain steps. There should be no upper-limit to how long the test is run for assertThat(getTestDurationMins()).isGreaterThanOrEqualTo(MIN_TEST_TIME_MINS); - final BesuNode minerNode1 = nodeFactory.createNodeFixedPort(besu, "miner1"); - final BesuNode minerNode2 = nodeFactory.createNodeFixedPort(besu, "miner2"); - final BesuNode minerNode3 = nodeFactory.createNodeFixedPort(besu, "miner3"); - final BesuNode minerNode4 = nodeFactory.createNodeFixedPort(besu, "miner4"); + // Create a mix of Bonsai and Forest DB nodes + final BesuNode minerNode1 = nodeFactory.createBonsaiNodeFixedPort(besu, "miner1"); + final BesuNode minerNode2 = nodeFactory.createForestNodeFixedPort(besu, "miner2"); + final BesuNode minerNode3 = nodeFactory.createBonsaiNodeFixedPort(besu, "miner3"); + final BesuNode minerNode4 = nodeFactory.createForestNodeFixedPort(besu, "miner4"); // Each step should be given a minimum of 3 minutes to complete successfully. If the time // give to run the soak test results in a time-per-step lower than this then the time