github.com/MetalBlockchain/metalgo@v1.11.9/scripts/tests.upgrade.sh (about) 1 #!/usr/bin/env bash 2 3 set -euo pipefail 4 5 # e.g., 6 # ./scripts/tests.upgrade.sh # Use default version 7 # ./scripts/tests.upgrade.sh 1.10.18 # Specify a version 8 # METALGO_PATH=./path/to/avalanchego ./scripts/tests.upgrade.sh 1.10.18 # Customization of avalanchego path 9 if ! [[ "$0" =~ scripts/tests.upgrade.sh ]]; then 10 echo "must be run from repository root" 11 exit 255 12 fi 13 14 # The AvalancheGo local network does not support long-lived 15 # backwards-compatible networks. When a breaking change is made to the 16 # local network, this flag must be updated to the last compatible 17 # version with the latest code. 18 # 19 # v1.11.0 activates Durango. 20 DEFAULT_VERSION="1.11.0" 21 22 VERSION="${1:-${DEFAULT_VERSION}}" 23 if [[ -z "${VERSION}" ]]; then 24 echo "Missing version argument!" 25 echo "Usage: ${0} [VERSION]" >>/dev/stderr 26 exit 255 27 fi 28 29 METALGO_PATH="$(realpath "${METALGO_PATH:-./build/metalgo}")" 30 31 ################################# 32 # download avalanchego 33 # https://github.com/ava-labs/avalanchego/releases 34 GOARCH=$(go env GOARCH) 35 GOOS=$(go env GOOS) 36 DOWNLOAD_URL=https://github.com/ava-labs/avalanchego/releases/download/v${VERSION}/avalanchego-linux-${GOARCH}-v${VERSION}.tar.gz 37 DOWNLOAD_PATH=/tmp/avalanchego.tar.gz 38 if [[ ${GOOS} == "darwin" ]]; then 39 DOWNLOAD_URL=https://github.com/ava-labs/avalanchego/releases/download/v${VERSION}/avalanchego-macos-v${VERSION}.zip 40 DOWNLOAD_PATH=/tmp/avalanchego.zip 41 fi 42 43 rm -f ${DOWNLOAD_PATH} 44 rm -rf "/tmp/avalanchego-v${VERSION}" 45 rm -rf /tmp/avalanchego-build 46 47 echo "downloading avalanchego ${VERSION} at ${DOWNLOAD_URL}" 48 curl -L "${DOWNLOAD_URL}" -o "${DOWNLOAD_PATH}" 49 50 echo "extracting downloaded avalanchego" 51 if [[ ${GOOS} == "linux" ]]; then 52 tar xzvf ${DOWNLOAD_PATH} -C /tmp 53 elif [[ ${GOOS} == "darwin" ]]; then 54 unzip ${DOWNLOAD_PATH} -d /tmp/avalanchego-build 55 mv /tmp/avalanchego-build/build "/tmp/avalanchego-v${VERSION}" 56 fi 57 find "/tmp/avalanchego-v${VERSION}" 58 59 # Sourcing constants.sh ensures that the necessary CGO flags are set to 60 # build the portable version of BLST. Without this, ginkgo may fail to 61 # build the test binary if run on a host (e.g. github worker) that lacks 62 # the instructions to build non-portable BLST. 63 source ./scripts/constants.sh 64 65 ################################# 66 echo "building upgrade.test" 67 # to install the ginkgo binary (required for test build and run) 68 go install -v github.com/onsi/ginkgo/v2/ginkgo@v2.13.1 69 ACK_GINKGO_RC=true ginkgo build ./tests/upgrade 70 ./tests/upgrade/upgrade.test --help 71 72 ################################# 73 # By default, it runs all upgrade test cases! 74 echo "running upgrade tests against the local cluster with ${AVALANCHEGO_PATH}" 75 ./tests/upgrade/upgrade.test \ 76 --ginkgo.v \ 77 --avalanchego-path="/tmp/avalanchego-v${VERSION}/avalanchego" \ 78 --avalanchego-path-to-upgrade-to="${AVALANCHEGO_PATH}"