Skip to content

Commit

Permalink
Fix test flackyness of acceptanceTestsPermissioning (#6384)
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
  • Loading branch information
fab-10 and macfarla committed Jan 12, 2024
1 parent 945a44c commit c660546
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Expand Up @@ -269,7 +269,7 @@ jobs:
- capture_test_logs

acceptanceTestsPermissioning:
executor: besu_executor_xl
executor: besu_executor_med
steps:
- prepare
- attach_workspace:
Expand All @@ -278,7 +278,7 @@ jobs:
name: AcceptanceTests (Non-Mainnet)
no_output_timeout: 20m
command: |
./gradlew --no-daemon acceptanceTestPermissioning
./gradlew --no-daemon --max-workers=1 acceptanceTestPermissioning
- capture_test_results
- capture_test_logs

Expand Down Expand Up @@ -428,12 +428,12 @@ workflows:
- acceptanceTestsPermissioning:
requires:
- assemble
- acceptanceTestsCliqueBft
- buildDocker:
requires:
- assemble
- buildArm64Docker:
requires:
- buildDocker
- assemble
- publish:
filters:
Expand Down
Expand Up @@ -77,6 +77,10 @@ public Condition miningStatus(final boolean isMining) {
return new MiningStatusCondition(transactions.mining(), isMining);
}

public Condition syncingStatus(final boolean isSyncing) {
return new SyncingStatusCondition(transactions.syncing(), isSyncing);
}

public Condition expectNewPendingTransactions(
final BigInteger filterId, final List<String> transactionHashes) {
return new NewPendingTransactionFilterChangesCondition(
Expand Down
@@ -0,0 +1,40 @@
/*
* Copyright Hyperledger Besu Contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.tests.acceptance.dsl.condition.eth;

import static org.assertj.core.api.Assertions.assertThat;

import org.hyperledger.besu.tests.acceptance.dsl.WaitUtils;
import org.hyperledger.besu.tests.acceptance.dsl.condition.Condition;
import org.hyperledger.besu.tests.acceptance.dsl.node.Node;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.eth.EthSyncingTransaction;

public class SyncingStatusCondition implements Condition {

private final EthSyncingTransaction transaction;
private final boolean syncingMiningStatus;

public SyncingStatusCondition(
final EthSyncingTransaction transaction, final boolean syncingStatus) {
this.transaction = transaction;
this.syncingMiningStatus = syncingStatus;
}

@Override
public void verify(final Node node) {
WaitUtils.waitFor(
10, () -> assertThat(node.execute(transaction)).isEqualTo(syncingMiningStatus));
}
}
Expand Up @@ -86,11 +86,8 @@ public void start(final List<? extends RunnableNode> nodes) {
final Optional<? extends RunnableNode> bootnode = selectAndStartBootnode(nodes);

nodes.parallelStream()
.filter(
node -> {
LOG.info("starting non-bootnode {}", node.getName());
return bootnode.map(boot -> boot != node).orElse(true);
})
.filter(node -> bootnode.map(boot -> boot != node).orElse(true))
.peek(node -> LOG.info("starting non-bootnode {}", node.getName()))
.forEach(this::startNode);

if (clusterConfiguration.isAwaitPeerDiscovery()) {
Expand Down
@@ -0,0 +1,40 @@
/*
* Copyright Hyperledger Besu Contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.tests.acceptance.dsl.transaction.eth;

import static org.assertj.core.api.Assertions.assertThat;

import org.hyperledger.besu.tests.acceptance.dsl.transaction.NodeRequests;
import org.hyperledger.besu.tests.acceptance.dsl.transaction.Transaction;

import java.io.IOException;

import org.web3j.protocol.core.methods.response.EthSyncing;

public class EthSyncingTransaction implements Transaction<Boolean> {

EthSyncingTransaction() {}

@Override
public Boolean execute(final NodeRequests node) {
try {
EthSyncing response = node.eth().ethSyncing().send();
assertThat(response).isNotNull();
return response.isSyncing();
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
}
Expand Up @@ -73,6 +73,10 @@ public EthMiningTransaction mining() {
return new EthMiningTransaction();
}

public EthSyncingTransaction syncing() {
return new EthSyncingTransaction();
}

public EthNewPendingTransactionFilterTransaction newPendingTransactionsFilter() {
return new EthNewPendingTransactionFilterTransaction();
}
Expand Down
Expand Up @@ -49,6 +49,11 @@ public void setUp() {

permissionedNode.verify(admin.addPeer(bootnode));
permissionedNode.verify(admin.addPeer(allowedNode));

allowedNode.verify(eth.syncingStatus(false));
bootnode.verify(eth.syncingStatus(false));
permissionedNode.verify(eth.syncingStatus(false));
forbiddenNode.verify(eth.syncingStatus(false));
}

@Test
Expand Down
Expand Up @@ -46,6 +46,11 @@ public void setUp() {

permissionedNode.execute(allowNode(permissionedNode));
permissionedNode.verify(connectionIsAllowed(permissionedNode));

allowedNode.verify(eth.syncingStatus(false));
bootnode.verify(eth.syncingStatus(false));
permissionedNode.verify(eth.syncingStatus(false));
forbiddenNode.verify(eth.syncingStatus(false));
}

@Test
Expand Down
Expand Up @@ -4,7 +4,7 @@
"londonBlock": 0,
"zeroBaseFee": true,
"ethash": {
"fixeddifficulty": 100
"fixeddifficulty": 500
}
},
"nonce": "0x42",
Expand Down
Expand Up @@ -4,7 +4,7 @@
"londonBlock": 0,
"zeroBaseFee": true,
"ethash": {
"fixeddifficulty": 100
"fixeddifficulty": 500
}
},
"nonce": "0x42",
Expand Down

0 comments on commit c660546

Please sign in to comment.