This repository has been archived by the owner on Sep 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added static nodes acceptance test (#1745)
- Loading branch information
1 parent
12d19a1
commit 3d1d766
Showing
11 changed files
with
165 additions
and
7 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/StaticNodesAcceptanceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2019 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.WaitUtils; | ||
import tech.pegasys.pantheon.tests.acceptance.dsl.node.Node; | ||
|
||
import java.util.Arrays; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class StaticNodesAcceptanceTest extends AcceptanceTestBase { | ||
|
||
private Node otherNode; | ||
private Node node; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
otherNode = pantheon.createNodeWithNoDiscovery("other-node"); | ||
cluster.start(otherNode); | ||
} | ||
|
||
@Test | ||
public void shouldConnectToNodeAddedAsStaticNode() throws Exception { | ||
node = pantheon.createNodeWithStaticNodes("node", Arrays.asList(otherNode)); | ||
cluster.addNode(node); | ||
|
||
node.verify(net.awaitPeerCount(1)); | ||
|
||
WaitUtils.waitFor(1000000, () -> {}); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...ance-tests/src/test/java/tech/pegasys/pantheon/tests/acceptance/dsl/StaticNodesUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2019 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.dsl; | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class StaticNodesUtils { | ||
|
||
public static Path createStaticNodesFile(final Path directory, final List<String> staticNodes) { | ||
try { | ||
final Path tempFile = Files.createTempFile(directory, "", ""); | ||
tempFile.toFile().deleteOnExit(); | ||
|
||
final Path staticNodesFile = tempFile.getParent().resolve("static-nodes.json"); | ||
Files.move(tempFile, staticNodesFile); | ||
staticNodesFile.toFile().deleteOnExit(); | ||
|
||
final String json = | ||
staticNodes.stream() | ||
.map(s -> String.format("\"%s\"", s)) | ||
.collect(Collectors.joining(",", "[", "]")); | ||
Files.write(staticNodesFile, json.getBytes(UTF_8)); | ||
|
||
return staticNodesFile; | ||
} catch (final IOException e) { | ||
throw new IllegalStateException(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters