Skip to content

Commit f04967d

Browse files
committed
Rename testnet fixture to ephnet
As per the README update, changing the name of the fixture to `ephnet` (short for 'ephemeral network') is intended to ensure a less unambiguous name. The original name of `testnet` was chosen in ignorance of the common use of the term to refer to a persistent blockchain network used for testing. Also changed: - 'existing' is used instead of 'persistent' in reference to ephemeral networks that are started and stopped with the `ephnetctl` tool. Referring to an ephemeral network as 'persistent' seemed confusing. - `TESTNETCTL_*`-prefixed env vars are now prefixed with `EPHNET_` (minus the `CTL`) since they are used by both the ephnetctl cli and the ginkgo test suite. - The root directory for storing local networks becomes `.ephnet` instead of `.testnetctl`, also due to the path being shared between the ephnetctl cli and the ginkgo test suite.
1 parent 7f70fcf commit f04967d

28 files changed

+252
-233
lines changed

.github/workflows/test.e2e.persistent.yml renamed to .github/workflows/test.e2e.existing.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test e2e with persistent network
1+
name: Test e2e with existing network
22

33
on:
44
push:
@@ -15,7 +15,7 @@ permissions:
1515
contents: read
1616

1717
jobs:
18-
test_e2e_persistent:
18+
test_e2e_existing:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: Git checkout
@@ -28,12 +28,12 @@ jobs:
2828
- name: Build the avalanchego binary
2929
shell: bash
3030
run: ./scripts/build.sh -r
31-
- name: Run e2e tests with persistent network
31+
- name: Run e2e tests with existing network
3232
shell: bash
33-
run: E2E_SERIAL=1 ./scripts/tests.e2e.persistent.sh
34-
- name: Upload testnet network dir
33+
run: E2E_SERIAL=1 ./scripts/tests.e2e.existing.sh
34+
- name: Upload ephnet network dir
3535
uses: actions/upload-artifact@v3
3636
if: always()
3737
with:
38-
name: testnet-data
39-
path: ~/.testnetctl/networks/1000
38+
name: ephnet-data
39+
path: ~/.ephnet/networks/1000

.github/workflows/test.e2e.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ jobs:
3131
- name: Run e2e tests
3232
shell: bash
3333
run: E2E_SERIAL=1 ./scripts/tests.e2e.sh
34-
- name: Upload testnet network dir
34+
- name: Upload ephnet network dir
3535
uses: actions/upload-artifact@v3
3636
if: always()
3737
with:
38-
name: testnet-data
39-
path: ~/.testnetctl/networks/1000
38+
name: ephnet-data
39+
path: ~/.ephnet/networks/1000

.github/workflows/test.upgrade.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ jobs:
3030
run: ./scripts/build.sh
3131
- name: Run upgrade tests
3232
shell: bash
33-
# 1.10.7 is the first version compatible with the testnet fixture by
33+
# 1.10.7 is the first version compatible with the ephnet fixture by
3434
# virtue of writing a process context file on node start.
3535
run: ./scripts/tests.upgrade.sh 1.10.7
36-
- name: Upload testnet network dir
36+
- name: Upload ephnet network dir
3737
uses: actions/upload-artifact@v3
3838
if: always()
3939
with:
40-
name: testnet-data
41-
path: ~/.testnetctl/networks/1000
40+
name: ephnet-data
41+
path: ~/.ephnet/networks/1000

scripts/build_testnetctl.sh renamed to scripts/build_ephnetctl.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ AVALANCHE_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd )
77
# Load the constants
88
source "$AVALANCHE_PATH"/scripts/constants.sh
99

10-
echo "Building testnetctl..."
10+
echo "Building ephnetctl..."
1111
go build -ldflags\
1212
"-X github.com/ava-labs/avalanchego/version.GitCommit=$git_commit $static_ld_flags"\
13-
-o "$AVALANCHE_PATH/build/testnetctl"\
14-
"$AVALANCHE_PATH/tests/fixture/testnet/cmd/"*.go
13+
-o "$AVALANCHE_PATH/build/ephnetctl"\
14+
"$AVALANCHE_PATH/tests/fixture/ephnet/cmd/"*.go

scripts/tests.e2e.existing.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
################################################################
6+
# This script deploys an ephemeral network and configures
7+
# tests.e2e.sh to execute the e2e suite against it. This
8+
# validates that ephnetctl is capable of starting a network and
9+
# that the e2e suite is capable of executing against a network
10+
# that it did not create.
11+
################################################################
12+
13+
# e.g.,
14+
# ./scripts/build.sh
15+
# ./scripts/tests.e2e.existing.sh --ginkgo.label-filter=x # All arguments are supplied to ginkgo
16+
# E2E_SERIAL=1 ./scripts/tests.e2e.sh # Run tests serially
17+
# AVALANCHEGO_PATH=./build/avalanchego ./scripts/tests.e2e.existing.sh # Customization of avalanchego path
18+
if ! [[ "$0" =~ scripts/tests.e2e.existing.sh ]]; then
19+
echo "must be run from repository root"
20+
exit 255
21+
fi
22+
23+
# Ensure an absolute path to avoid dependency on the working directory
24+
# of script execution.
25+
export AVALANCHEGO_PATH="$(realpath ${AVALANCHEGO_PATH:-./build/avalanchego})"
26+
27+
# Provide visual separation between testing and setup/teardown
28+
function print_separator {
29+
printf '%*s\n' "${COLUMNS:-80}" '' | tr ' '
30+
}
31+
32+
# Ensure network cleanup on teardown
33+
function cleanup {
34+
print_separator
35+
echo "cleaning up ephemeral network"
36+
if [[ -n "${EPHNET_NETWORK_DIR:-}" ]]; then
37+
./build/ephnetctl stop-network
38+
fi
39+
}
40+
trap cleanup EXIT
41+
42+
# Start an ephemeral network
43+
./scripts/build_ephnetctl.sh
44+
print_separator
45+
./build/ephnetctl start-network
46+
47+
# Determine the network configuration path from the latest symlink
48+
LATEST_SYMLINK_PATH="${HOME}/.ephnet/networks/latest"
49+
if [[ -h "${LATEST_SYMLINK_PATH}" ]]; then
50+
export EPHNET_NETWORK_DIR="$(realpath ${LATEST_SYMLINK_PATH})"
51+
else
52+
echo "failed to find configuration path: ${LATEST_SYMLINK_PATH} symlink not found"
53+
exit 255
54+
fi
55+
56+
print_separator
57+
# - Setting E2E_USE_EXISTING_NETWORK configures tests.e2e.sh to use
58+
# the ephemeral network identified by EPHNET_NETWORK_DIR.
59+
# - Only a single test (selected with --ginkgo.focus-file) is required
60+
# to validate that an existing network can be used by an e2e test
61+
# suite run. Executing more tests would be duplicative of the testing
62+
# performed against a network created by the test suite.
63+
E2E_USE_EXISTING_NETWORK=1 ./scripts/tests.e2e.sh --ginkgo.focus-file=permissionless_subnets.go

scripts/tests.e2e.persistent.sh

Lines changed: 0 additions & 60 deletions
This file was deleted.

scripts/tests.e2e.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set -euo pipefail
77
# ./scripts/tests.e2e.sh --ginkgo.label-filter=x # All arguments are supplied to ginkgo
88
# E2E_SERIAL=1 ./scripts/tests.e2e.sh # Run tests serially
99
# AVALANCHEGO_PATH=./build/avalanchego ./scripts/tests.e2e.sh # Customization of avalanchego path
10-
# E2E_USE_PERSISTENT_NETWORK=1 TESTNETCTL_NETWORK_DIR=/path/to ./scripts/tests.e2e.sh # Execute against a persistent network
10+
# E2E_USE_EXISTING_NETWORK=1 EPHNET_NETWORK_DIR=/path/to ./scripts/tests.e2e.sh # Execute against an existing network
1111
if ! [[ "$0" =~ scripts/tests.e2e.sh ]]; then
1212
echo "must be run from repository root"
1313
exit 255
@@ -28,11 +28,11 @@ ACK_GINKGO_RC=true ginkgo build ./tests/e2e
2828
./tests/e2e/e2e.test --help
2929

3030
#################################
31-
# Since TESTNETCTL_NETWORK_DIR may be persistently set in the environment (e.g. to configure
32-
# ginkgo or testnetctl), configuring the use of a persistent network with this script
33-
# requires the extra step of setting E2E_USE_PERSISTENT_NETWORK=1.
34-
if [[ -n "${E2E_USE_PERSISTENT_NETWORK:-}" && -n "${TESTNETCTL_NETWORK_DIR:-}" ]]; then
35-
E2E_ARGS="--use-persistent-network"
31+
# Since EPHNET_NETWORK_DIR may be set in the environment (e.g. to configure ginkgo
32+
# or ephnetctl), configuring the use of an existing network with this script
33+
# requires the extra step of setting E2E_USE_EXISTING_NETWORK=1.
34+
if [[ -n "${E2E_USE_EXISTING_NETWORK:-}" && -n "${EPHNET_NETWORK_DIR:-}" ]]; then
35+
E2E_ARGS="--use-existing-network"
3636
else
3737
AVALANCHEGO_PATH="$(realpath ${AVALANCHEGO_PATH:-./build/avalanchego})"
3838
E2E_ARGS="--avalanchego-path=${AVALANCHEGO_PATH}"

tests/e2e/README.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Avalanche e2e test suites
22

3-
- Works with fixture-managed networks.
3+
- Works with fixture-managed ephemeral networks.
44
- Compiles to a single binary with customizable configurations.
55

66
## Running tests
@@ -57,44 +57,46 @@ packages. `x/transfer/virtuous.go` defines X-Chain transfer tests,
5757
labeled with `x`, which can be selected by `./tests/e2e/e2e.test
5858
--ginkgo.label-filter "x"`.
5959

60-
## Testing against a persistent network
60+
## Testing against an existing network
6161

6262
By default, a new ephemeral test network will be started before each
63-
test run. When developing e2e tests, it may be helpful to create a
64-
persistent test network to test against. This can increase the speed
65-
of iteration by removing the requirement to start a new network for
66-
every invocation of the test under development.
63+
test run and stopped at the end of the run. When developing e2e tests,
64+
it may be helpful to create an ephemeral network that can be used
65+
across multiple test runs. This can increase the speed of iteration by
66+
removing the requirement to start a new network for every invocation
67+
of the test under development.
6768

68-
To use a persistent network:
69+
To create an ephemeral network for use across test runs:
6970

7071
```bash
7172
# From the root of the avalanchego repo
7273

73-
# Build the testnetctl binary
74-
$ ./scripts/build_testnetctl.sh
74+
# Build the ephnetctl binary
75+
$ ./scripts/build_ephnetctl.sh
7576

7677
# Start a new network
77-
$ ./build/testnetctl start-network --avalanchego-path=/path/to/avalanchego
78+
$ ./build/ephnetctl start-network --avalanchego-path=/path/to/avalanchego
7879
...
79-
Started network 1000 @ /home/me/.testnetctl/networks/1000
80+
Started network 1000 @ /home/me/.ephnet/networks/1000
8081

81-
Configure testnetctl to target this network by default with one of the following statements:
82-
- source /home/me/.testnetctl/networks/1000/network.env
83-
- export TESTNETCTL_NETWORK_DIR=/home/me/.testnetctl/networks/1000
84-
- export TESTNETCTL_NETWORK_DIR=/home/me/.testnetctl/networks/latest
82+
Configure ephnetctl and the test suite to target this network by default
83+
with one of the following statements:
84+
- source /home/me/.ephnet/networks/1000/network.env
85+
- export EPHNET_NETWORK_DIR=/home/me/.ephnet/networks/1000
86+
- export EPHNET_NETWORK_DIR=/home/me/.ephnet/networks/latest
8587

86-
# Start a new test run using the persistent network
88+
# Start a new test run using the existing network
8789
ginkgo -v ./tests/e2e -- \
8890
--avalanchego-path=/path/to/avalanchego \
8991
--ginkgo.focus-file=[name of file containing test] \
90-
--use-persistent-network \
92+
--use-existing-network \
9193
--network-dir=/path/to/network
9294

9395
# It is also possible to set the AVALANCHEGO_PATH env var instead of supplying --avalanchego-path
94-
# and to set TESTNETCTL_NETWORK_DIR instead of supplying --network-dir.
96+
# and to set EPHNET_NETWORK_DIR instead of supplying --network-dir.
9597
```
9698

97-
See the testnet fixture [README](../fixture/testnet/README.md) for more details.
99+
See the ephnet fixture [README](../fixture/ephnet/README.md) for more details.
98100

99101
## Skipping bootstrap checks
100102

tests/e2e/c/dynamic_fees.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020

2121
"github.com/ava-labs/avalanchego/tests"
2222
"github.com/ava-labs/avalanchego/tests/fixture/e2e"
23-
"github.com/ava-labs/avalanchego/tests/fixture/testnet"
23+
"github.com/ava-labs/avalanchego/tests/fixture/ephnet"
2424
"github.com/ava-labs/avalanchego/utils/crypto/secp256k1"
2525
)
2626

@@ -47,7 +47,7 @@ var _ = e2e.DescribeCChain("[Dynamic Fees]", func() {
4747

4848
ginkgo.By("initializing a coreth client")
4949
node := privateNetwork.GetNodes()[0]
50-
nodeURI := testnet.NodeURI{
50+
nodeURI := ephnet.NodeURI{
5151
NodeID: node.GetID(),
5252
URI: node.GetProcessContext().URI,
5353
}

tests/e2e/faultinjection/duplicate_node_id.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/ava-labs/avalanchego/config"
1616
"github.com/ava-labs/avalanchego/ids"
1717
"github.com/ava-labs/avalanchego/tests/fixture/e2e"
18-
"github.com/ava-labs/avalanchego/tests/fixture/testnet"
18+
"github.com/ava-labs/avalanchego/tests/fixture/ephnet"
1919
"github.com/ava-labs/avalanchego/utils/set"
2020
)
2121

@@ -27,15 +27,15 @@ var _ = ginkgo.Describe("Duplicate node handling", func() {
2727
nodes := network.GetNodes()
2828

2929
ginkgo.By("creating new node")
30-
node1 := e2e.AddEphemeralNode(network, testnet.FlagsMap{})
30+
node1 := e2e.AddEphemeralNode(network, ephnet.FlagsMap{})
3131
e2e.WaitForHealthy(node1)
3232

3333
ginkgo.By("checking that the new node is connected to its peers")
3434
checkConnectedPeers(nodes, node1)
3535

3636
ginkgo.By("creating a second new node with the same staking keypair as the first new node")
3737
node1Flags := node1.GetConfig().Flags
38-
node2Flags := testnet.FlagsMap{
38+
node2Flags := ephnet.FlagsMap{
3939
config.StakingTLSKeyContentKey: node1Flags[config.StakingTLSKeyContentKey],
4040
config.StakingCertContentKey: node1Flags[config.StakingCertContentKey],
4141
// Construct a unique data dir to ensure the two nodes' data will be stored
@@ -46,7 +46,7 @@ var _ = ginkgo.Describe("Duplicate node handling", func() {
4646
node2 := e2e.AddEphemeralNode(network, node2Flags)
4747

4848
ginkgo.By("checking that the second new node fails to become healthy before timeout")
49-
err := testnet.WaitForHealthy(e2e.DefaultContext(), node2)
49+
err := ephnet.WaitForHealthy(e2e.DefaultContext(), node2)
5050
require.ErrorIs(err, context.DeadlineExceeded)
5151

5252
ginkgo.By("stopping the first new node")
@@ -63,7 +63,7 @@ var _ = ginkgo.Describe("Duplicate node handling", func() {
6363
})
6464

6565
// Check that a new node is connected to existing nodes and vice versa
66-
func checkConnectedPeers(existingNodes []testnet.Node, newNode testnet.Node) {
66+
func checkConnectedPeers(existingNodes []ephnet.Node, newNode ephnet.Node) {
6767
require := require.New(ginkgo.GinkgoT())
6868

6969
// Collect the node ids of the new node's peers

0 commit comments

Comments
 (0)