Skip to content

Commit

Permalink
testnet-autmation: Add rolling software upgrade script
Browse files Browse the repository at this point in the history
  • Loading branch information
t-nelson committed Sep 11, 2020
1 parent 28e7dec commit bf3db06
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions system-test/rolling-upgrade/rolling_upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
REPO_ROOT=${DIR}/../..

# shellcheck source=/dev/null # Ignore generated source target
source "${REPO_ROOT}/net/config/config"
# shellcheck source=system-test/automation_utils.sh
source "${REPO_ROOT}/system-test/automation_utils.sh"

NET_SH="${REPO_ROOT}/net/net.sh"

set -x

: "${UPGRADE_INITIAL_DELAY:=0}" # Time to wait before starting rolling upgrade
: "${UPGRADE_INTERVALIDATOR_DELAY:?}" # Time to wait between validators during upgrade
: "${UPGRADE_POST_TEST_DELAY:=0}" #Time to wait after upgrade

sleep_if_positive() {
declare delay=$1
if [[ "$delay" -gt 0 ]]; then
sleep "$delay"
fi
}

# Fetch new software and upload it to the bootstrap validator
declare -g sw_version_args
get_net_launch_software_version_launch_args "$UPGRADE_CHANNEL" "upgrade-release" sw_version_args
# shellcheck disable=2086 # $sw_version_args holds two args. Don't quote!
"$NET_SH" upgrade $sw_version_args

# Wait initial delay, if any
sleep_if_positive "$UPGRADE_INITIAL_DELAY"

if [[ "$UPGRADE_INITIAL_DELAY" -gt 0 ]]; then
"$NET_SH" sanity
fi

# Restart validators one by one
# shellcheck disable=SC2154 # sourced from config above
for i in "${!validatorIpList[@]}"; do
if [[ "$i" -eq 0 ]]; then
# net.sh doesn't support restarting the bootstrap validator yet
continue
fi

declare ipAddress="${validatorIpList[$i]}"

"$NET_SH" stopnode -i "$ipAddress"
"$NET_SH" startnode -r -i "$ipAddress"

# This could be replaced with something based on `solana catchup`
sleep_if_positive "$UPGRADE_INTERVALIDATOR_DELAY"

"$NET_SH" sanity
done

sleep_if_positive "$UPGRADE_POST_TEST_DELAY"

if [[ "$UPGRADE_POST_TEST_DELAY" -gt 0 ]]; then
"$NET_SH" sanity
fi

0 comments on commit bf3db06

Please sign in to comment.