From 789f824598a5544ab23f8b60bd93fc1436721016 Mon Sep 17 00:00:00 2001 From: shemnon Date: Mon, 13 May 2019 16:13:08 -0600 Subject: [PATCH 1/2] PAN-2634 - Make sure ThreadPantheonNodeRunner is exercised by automation To make sure it is automated I extende the cluster to accept a defined PantheonNode instead of an automatic one (where automatic is the default) and then cloned a simple test and forced it to use the ThreadPantheonNodeRunner. --- ...ClusterThreadNodeRunnerAcceptanceTest.java | 54 +++++++++++++++++++ .../acceptance/dsl/node/cluster/Cluster.java | 9 +++- 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterThreadNodeRunnerAcceptanceTest.java diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterThreadNodeRunnerAcceptanceTest.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterThreadNodeRunnerAcceptanceTest.java new file mode 100644 index 0000000000..0d0657426e --- /dev/null +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/ClusterThreadNodeRunnerAcceptanceTest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2018 ConsenSys AG. + * + * 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. + */ +package tech.pegasys.pantheon.tests.acceptance; + +import tech.pegasys.pantheon.tests.acceptance.dsl.AcceptanceTestBase; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNode; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.PantheonNodeRunner; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.ThreadPantheonNodeRunner; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.cluster.Cluster; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.cluster.ClusterConfiguration; +import tech.pegasys.pantheon.tests.acceptance.dsl.node.cluster.ClusterConfigurationBuilder; + +import org.junit.Before; +import org.junit.Test; + +public class ClusterThreadNodeRunnerAcceptanceTest extends AcceptanceTestBase { + + private Node fullNode; + private Cluster noDiscoveryCluster; + + @Before + public void setUp() throws Exception { + final ClusterConfiguration clusterConfiguration = + new ClusterConfigurationBuilder().setAwaitPeerDiscovery(false).build(); + final PantheonNodeRunner pantheonNodeRunner = new ThreadPantheonNodeRunner(); + noDiscoveryCluster = new Cluster(clusterConfiguration, net, pantheonNodeRunner); + final PantheonNode noDiscoveryNode = pantheon.createNodeWithNoDiscovery("noDiscovery"); + fullNode = pantheon.createArchiveNode("node2"); + noDiscoveryCluster.start(noDiscoveryNode, fullNode); + } + + @Test + public void shouldVerifySomething() { + // we don't care what verifies, just that it gets to the point something can verify + fullNode.verify(net.awaitPeerCount(0)); + } + + @Override + public void tearDownAcceptanceTestBase() { + noDiscoveryCluster.stop(); + super.tearDownAcceptanceTestBase(); + } +} diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/cluster/Cluster.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/cluster/Cluster.java index 7d6439678b..440e40f44f 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/cluster/Cluster.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/cluster/Cluster.java @@ -39,19 +39,24 @@ public class Cluster implements AutoCloseable { private static final Logger LOG = LogManager.getLogger(); private final Map nodes = new HashMap<>(); - private final PantheonNodeRunner pantheonNodeRunner = PantheonNodeRunner.instance(); + private final PantheonNodeRunner pantheonNodeRunner; private final Net net; private final ClusterConfiguration clusterConfiguration; private List originalNodes = emptyList(); private List bootnodes = emptyList(); public Cluster(final Net net) { - this(new ClusterConfigurationBuilder().build(), net); + this(new ClusterConfigurationBuilder().build(), net, PantheonNodeRunner.instance()); } public Cluster(final ClusterConfiguration clusterConfiguration, final Net net) { + this(clusterConfiguration, net, PantheonNodeRunner.instance()); + } + + public Cluster(final ClusterConfiguration clusterConfiguration, final Net net, final PantheonNodeRunner pantheonNodeRunner) { this.clusterConfiguration = clusterConfiguration; this.net = net; + this.pantheonNodeRunner = pantheonNodeRunner; } public void start(final Node... nodes) { From 71f68e8719ae75f6fb12426830d720158ea8a4a2 Mon Sep 17 00:00:00 2001 From: shemnon Date: Mon, 13 May 2019 17:53:30 -0600 Subject: [PATCH 2/2] spotless --- .../pantheon/tests/acceptance/dsl/node/cluster/Cluster.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/cluster/Cluster.java b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/cluster/Cluster.java index 440e40f44f..38c073e8e2 100644 --- a/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/cluster/Cluster.java +++ b/acceptance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/node/cluster/Cluster.java @@ -53,7 +53,10 @@ public Cluster(final ClusterConfiguration clusterConfiguration, final Net net) { this(clusterConfiguration, net, PantheonNodeRunner.instance()); } - public Cluster(final ClusterConfiguration clusterConfiguration, final Net net, final PantheonNodeRunner pantheonNodeRunner) { + public Cluster( + final ClusterConfiguration clusterConfiguration, + final Net net, + final PantheonNodeRunner pantheonNodeRunner) { this.clusterConfiguration = clusterConfiguration; this.net = net; this.pantheonNodeRunner = pantheonNodeRunner;