Skip to content

Commit 46a2964

Browse files
committed
testing: Switch upgrade test to the testnet fixture
1 parent 09bb1e4 commit 46a2964

File tree

8 files changed

+80
-197
lines changed

8 files changed

+80
-197
lines changed

.github/workflows/test.upgrade.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,12 @@ jobs:
2828
run: ./scripts/build.sh
2929
- name: Run upgrade tests
3030
shell: bash
31-
run: scripts/tests.upgrade.sh 1.10.1 ./build/avalanchego
31+
# 1.10.7 is the first version compatible with the testnet fixture by
32+
# virtue of writing a process context file on node start.
33+
run: ./scripts/tests.upgrade.sh 1.10.7
34+
- name: Upload testnet network dir
35+
uses: actions/upload-artifact@v3
36+
if: always()
37+
with:
38+
name: testnet-data
39+
path: ~/.testnetctl/networks/1000

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ require (
1111
github.com/DataDog/zstd v1.5.2
1212
github.com/Microsoft/go-winio v0.5.2
1313
github.com/NYTimes/gziphandler v1.1.1
14-
github.com/ava-labs/avalanche-network-runner-sdk v0.3.0
1514
github.com/ava-labs/coreth v0.12.5-rc.3
1615
github.com/ava-labs/ledger-avalanche/go v0.0.0-20230105152938-00a24d05a8c7
1716
github.com/btcsuite/btcd/btcutil v1.1.3

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156 h1:eMwmnE/GDgah
6161
github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
6262
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
6363
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
64-
github.com/ava-labs/avalanche-network-runner-sdk v0.3.0 h1:TVi9JEdKNU/RevYZ9PyW4pULbEdS+KQDA9Ki2DUvuAs=
65-
github.com/ava-labs/avalanche-network-runner-sdk v0.3.0/go.mod h1:SgKJvtqvgo/Bl/c8fxEHCLaSxEbzimYfBopcfrajxQk=
6664
github.com/ava-labs/coreth v0.12.5-rc.3 h1:cpmC+fSZMsO4gaFWqXHzAHrJACf05u5HPAYmwh7nmkU=
6765
github.com/ava-labs/coreth v0.12.5-rc.3/go.mod h1:HI+jTIflnDFBd0bledgkgid1Uurwr8q1h7zb3LsFsSo=
6866
github.com/ava-labs/ledger-avalanche/go v0.0.0-20230105152938-00a24d05a8c7 h1:EdxD90j5sClfL5Ngpz2TlnbnkNYdFPDXa0jDOjam65c=

scripts/install_anr.sh

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

scripts/tests.upgrade.sh

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
set -euo pipefail
44

55
# e.g.,
6-
# ./scripts/build.sh
7-
# ./scripts/tests.upgrade.sh 1.7.16 ./build/avalanchego
6+
# ./scripts/tests.upgrade.sh 1.7.16
7+
# AVALANCHEGO_PATH=./path/to/avalanchego ./scripts/tests.upgrade.sh 1.7.16 # Customization of avalanchego path
88
if ! [[ "$0" =~ scripts/tests.upgrade.sh ]]; then
99
echo "must be run from repository root"
1010
exit 255
@@ -13,16 +13,16 @@ fi
1313
VERSION="${1:-}"
1414
if [[ -z "${VERSION}" ]]; then
1515
echo "Missing version argument!"
16-
echo "Usage: ${0} [VERSION] [NEW-BINARY]" >>/dev/stderr
16+
echo "Usage: ${0} [VERSION]" >>/dev/stderr
1717
exit 255
1818
fi
1919

20-
NEW_BINARY="${2:-}"
21-
if [[ -z "${NEW_BINARY}" ]]; then
22-
echo "Missing new binary path argument!"
23-
echo "Usage: ${0} [VERSION] [NEW-BINARY]" >>/dev/stderr
20+
AVALANCHEGO_PATH="${AVALANCHEGO_PATH:-./build/avalanchego}"
21+
if [[ -z "${AVALANCHEGO_PATH}" ]]; then
22+
echo "Empty AVALANCHEGO_PATH env var!"
2423
exit 255
2524
fi
25+
AVALANCHEGO_PATH="$(realpath ${AVALANCHEGO_PATH})"
2626

2727
#################################
2828
# download avalanchego
@@ -52,11 +52,6 @@ elif [[ ${GOOS} == "darwin" ]]; then
5252
fi
5353
find /tmp/avalanchego-v${VERSION}
5454

55-
#################################
56-
echo "installing avalanche-network-runner"
57-
ANR_WORKDIR="/tmp"
58-
./scripts/install_anr.sh
59-
6055
# Sourcing constants.sh ensures that the necessary CGO flags are set to
6156
# build the portable version of BLST. Without this, ginkgo may fail to
6257
# build the test binary if run on a host (e.g. github worker) that lacks
@@ -70,35 +65,10 @@ go install -v github.com/onsi/ginkgo/v2/[email protected]
7065
ACK_GINKGO_RC=true ginkgo build ./tests/upgrade
7166
./tests/upgrade/upgrade.test --help
7267

73-
#################################
74-
# run "avalanche-network-runner" server
75-
echo "launch avalanche-network-runner in the background"
76-
$ANR_WORKDIR/avalanche-network-runner \
77-
server \
78-
--log-level debug \
79-
--port=":12340" \
80-
--disable-grpc-gateway &
81-
PID=${!}
82-
8368
#################################
8469
# By default, it runs all upgrade test cases!
85-
echo "running upgrade tests against the local cluster with ${NEW_BINARY}"
70+
echo "running upgrade tests against the local cluster with ${AVALANCHEGO_PATH}"
8671
./tests/upgrade/upgrade.test \
8772
--ginkgo.v \
88-
--log-level debug \
89-
--network-runner-grpc-endpoint="0.0.0.0:12340" \
90-
--network-runner-avalanchego-path=/tmp/avalanchego-v${VERSION}/avalanchego \
91-
--network-runner-avalanchego-path-to-upgrade=${NEW_BINARY} \
92-
--network-runner-avalanchego-log-level="WARN" || EXIT_CODE=$?
93-
94-
# "e2e.test" already terminates the cluster
95-
# just in case tests are aborted, manually terminate them again
96-
pkill -P ${PID} || true
97-
kill -2 ${PID}
98-
99-
if [[ "${EXIT_CODE:-}" -gt 0 ]]; then
100-
echo "FAILURE with exit code ${EXIT_CODE}"
101-
exit ${EXIT_CODE}
102-
else
103-
echo "ALL SUCCESS!"
104-
fi
73+
--avalanchego-path=/tmp/avalanchego-v${VERSION}/avalanchego \
74+
--avalanchego-path-to-upgrade-to=${AVALANCHEGO_PATH}

tests/e2e/e2e.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,7 @@ func AddEphemeralNode(network testnet.Network, flags testnet.FlagsMap) testnet.N
237237

238238
// Wait for the given node to report healthy.
239239
func WaitForHealthy(node testnet.Node) {
240-
ctx, cancel := context.WithTimeout(context.Background(), DefaultTimeout)
241-
defer cancel()
242-
require.NoError(ginkgo.GinkgoT(), testnet.WaitForHealthy(ctx, node))
240+
require.NoError(ginkgo.GinkgoT(), testnet.WaitForHealthy(DefaultContext(), node))
243241
}
244242

245243
// Sends an eth transaction, waits for the transaction receipt to be issued

tests/fixture/testnet/local/network.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -677,20 +677,33 @@ func (ln *LocalNetwork) AddLocalNode(w io.Writer, node *LocalNode, isEphemeral b
677677
return nil, err
678678
}
679679

680-
// Collect staking addresses of running nodes for use in bootstraping the new node
681-
if err := ln.ReadNodes(); err != nil {
682-
return nil, fmt.Errorf("failed to read local network nodes: %w", err)
680+
bootstrapIPs, bootstrapIDs, err := ln.GetBootstrapIPsAndIds()
681+
if err != nil {
682+
return nil, err
683683
}
684684

685685
var (
686686
// Use dynamic port allocation.
687687
httpPort uint16 = 0
688688
stakingPort uint16 = 0
689+
)
690+
node.SetNetworkingConfigDefaults(httpPort, stakingPort, bootstrapIDs, bootstrapIPs)
691+
692+
if err := node.WriteConfig(); err != nil {
693+
return nil, err
694+
}
695+
return node, node.Start(w, ln.ExecPath)
696+
}
689697

698+
func (ln *LocalNetwork) GetBootstrapIPsAndIds() ([]string, []string, error) {
699+
// Collect staking addresses of running nodes for use in bootstrapping a node
700+
if err := ln.ReadNodes(); err != nil {
701+
return nil, nil, fmt.Errorf("failed to read local network nodes: %w", err)
702+
}
703+
var (
690704
bootstrapIPs = make([]string, 0, len(ln.Nodes))
691705
bootstrapIDs = make([]string, 0, len(ln.Nodes))
692706
)
693-
694707
for _, node := range ln.Nodes {
695708
if len(node.StakingAddress) == 0 {
696709
// Node is not running
@@ -700,14 +713,10 @@ func (ln *LocalNetwork) AddLocalNode(w io.Writer, node *LocalNode, isEphemeral b
700713
bootstrapIPs = append(bootstrapIPs, node.StakingAddress)
701714
bootstrapIDs = append(bootstrapIDs, node.NodeID.String())
702715
}
716+
703717
if len(bootstrapIDs) == 0 {
704-
return nil, errMissingBootstrapNodes
718+
return nil, nil, errMissingBootstrapNodes
705719
}
706720

707-
node.SetNetworkingConfigDefaults(httpPort, stakingPort, bootstrapIDs, bootstrapIPs)
708-
709-
if err := node.WriteConfig(); err != nil {
710-
return nil, err
711-
}
712-
return node, node.Start(w, ln.ExecPath)
721+
return bootstrapIPs, bootstrapIDs, nil
713722
}

0 commit comments

Comments
 (0)