-
Notifications
You must be signed in to change notification settings - Fork 739
/
Copy pathtests.upgrade.sh
executable file
·70 lines (59 loc) · 2.58 KB
/
tests.upgrade.sh
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
set -euo pipefail
# e.g.,
# ./scripts/tests.upgrade.sh # Use default version
# ./scripts/tests.upgrade.sh 1.11.0 # Specify a version
# AVALANCHEGO_PATH=./path/to/avalanchego ./scripts/tests.upgrade.sh 1.11.0 # Customization of avalanchego path
if ! [[ "$0" =~ scripts/tests.upgrade.sh ]]; then
echo "must be run from repository root"
exit 255
fi
# The AvalancheGo local network does not support long-lived
# backwards-compatible networks. When a breaking change is made to the
# local network, this flag must be updated to the last compatible
# version with the latest code.
#
# v1.12.0 is the earliest version that supports Etna.
DEFAULT_VERSION="1.12.0"
VERSION="${1:-${DEFAULT_VERSION}}"
if [[ -z "${VERSION}" ]]; then
echo "Missing version argument!"
echo "Usage: ${0} [VERSION]" >>/dev/stderr
exit 255
fi
AVALANCHEGO_PATH="$(realpath "${AVALANCHEGO_PATH:-./build/avalanchego}")"
#################################
# download avalanchego
# https://github.com/ava-labs/avalanchego/releases
GOARCH=$(go env GOARCH)
GOOS=$(go env GOOS)
DOWNLOAD_URL=https://github.com/ava-labs/avalanchego/releases/download/v${VERSION}/avalanchego-linux-${GOARCH}-v${VERSION}.tar.gz
DOWNLOAD_PATH=/tmp/avalanchego.tar.gz
if [[ ${GOOS} == "darwin" ]]; then
DOWNLOAD_URL=https://github.com/ava-labs/avalanchego/releases/download/v${VERSION}/avalanchego-macos-v${VERSION}.zip
DOWNLOAD_PATH=/tmp/avalanchego.zip
fi
rm -f ${DOWNLOAD_PATH}
rm -rf "/tmp/avalanchego-v${VERSION}"
rm -rf /tmp/avalanchego-build
echo "downloading avalanchego ${VERSION} at ${DOWNLOAD_URL}"
curl -L "${DOWNLOAD_URL}" -o "${DOWNLOAD_PATH}"
echo "extracting downloaded avalanchego"
if [[ ${GOOS} == "linux" ]]; then
tar xzvf ${DOWNLOAD_PATH} -C /tmp
elif [[ ${GOOS} == "darwin" ]]; then
unzip ${DOWNLOAD_PATH} -d /tmp/avalanchego-build
mv /tmp/avalanchego-build/build "/tmp/avalanchego-v${VERSION}"
fi
find "/tmp/avalanchego-v${VERSION}"
# Sourcing constants.sh ensures that the necessary CGO flags are set to
# build the portable version of BLST. Without this, ginkgo may fail to
# build the test binary if run on a host (e.g. github worker) that lacks
# the instructions to build non-portable BLST.
source ./scripts/constants.sh
#################################
# By default, it runs all upgrade test cases!
echo "running upgrade tests against the local cluster with ${AVALANCHEGO_PATH}"
./bin/ginkgo -v ./tests/upgrade -- \
--avalanchego-path="/tmp/avalanchego-v${VERSION}/avalanchego" \
--avalanchego-path-to-upgrade-to="${AVALANCHEGO_PATH}"