forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtests.e2e.existing.sh
More file actions
executable file
·52 lines (42 loc) · 1.84 KB
/
tests.e2e.existing.sh
File metadata and controls
executable file
·52 lines (42 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
set -euo pipefail
# This script verifies that a network can be reused across test runs.
# e.g.,
# ./scripts/build.sh
# ./scripts/tests.e2e.sh --ginkgo.label-filter=x # All arguments are supplied to ginkgo
# AVALANCHEGO_PATH=./build/avalanchego ./scripts/tests.e2e.existing.sh # Customization of avalanchego path
if ! [[ "$0" =~ scripts/tests.e2e.existing.sh ]]; then
echo "must be run from repository root"
exit 255
fi
# Provide visual separation between testing and setup/teardown
function print_separator {
printf '%*s\n' "${COLUMNS:-80}" '' | tr ' ' ─
}
# Ensure network cleanup on teardown
function cleanup {
print_separator
echo "cleaning up reusable network"
./bin/ginkgo -v ./tests/e2e -- --stop-network
}
trap cleanup EXIT
# TMPNET_NETWORK_DIR needs to be unset to ensure --reuse-network won't target an existing network
unset TMPNET_NETWORK_DIR
print_separator
echo "starting initial test run that should create the reusable network"
./scripts/tests.e2e.sh --reuse-network --ginkgo.focus-file=xsvm.go "${@}"
print_separator
echo "determining the network path of the reusable network created by the first test run"
SYMLINK_PATH="${HOME}/.tmpnet/networks/latest_avalanchego-e2e"
INITIAL_NETWORK_DIR="$(realpath "${SYMLINK_PATH}")"
print_separator
echo "starting second test run that should reuse the network created by the first run"
echo "the network is first restarted to verify that the network state was correctly serialized"
./scripts/tests.e2e.sh --restart-network --ginkgo.focus-file=xsvm.go "${@}"
SUBSEQUENT_NETWORK_DIR="$(realpath "${SYMLINK_PATH}")"
echo "checking that the symlink path remains the same, indicating that the network was reused"
if [[ "${INITIAL_NETWORK_DIR}" != "${SUBSEQUENT_NETWORK_DIR}" ]]; then
print_separator
echo "network was not reused across test runs"
exit 1
fi