diff --git a/deployments/scripts/k8s-e2e-upgrade-test b/deployments/scripts/k8s-e2e-upgrade-test new file mode 100755 index 0000000000..a82c7eb84a --- /dev/null +++ b/deployments/scripts/k8s-e2e-upgrade-test @@ -0,0 +1,66 @@ +#!/usr/bin/env bash +# Dev script to run a full chain upgrade test, to validate migrations, +# on a cluster-hosted devnet. Designed to be run from a developer +# workstation. Later it can be ported to CI contexts. + +set -euo pipefail + + +PCLI_HOME="${HOME:?}/.local/share/pcli-devnet/" +if [[ ! -d "$PCLI_HOME" ]] ; then + >&2 echo "ERROR: pcli home does not exist: $PCLI_HOME" + exit 1 +fi + +FROM_VERSION="${FROM_VERSION:-}" +if [[ -z "$FROM_VERSION" ]] ; then + >&2 echo "ERROR: set env var 'FROM_VERSION' to the pre-upgrade Penumbra version" + exit 1 +fi + +# script expects to be in deployments/ dir +if [[ ! -e ci.sh ]] ; then + >&2 echo "ERROR: script should be run from inside 'deployments/' dir" + exit 1 +fi + + +# Create a clean network config in the cluster. +# This is a destructive action! Will destroy any previously existing devnet. +function deploy_fresh_devnet() { + >&2 echo "Creating fresh devnet..." + PENUMBRA_VERSION="$FROM_VERSION" ./ci.sh + >&2 echo "Devnet deployment complete, waiting a bit for nodes to start..." + sleep 30 +} + + +# Confirm we can view balances on the remote network. +# Otherwise, rest of interactive tests won't work. +function check_pcli_balance() { + >&2 echo "Checking balance via pcli..." + # assumes that the `pcli` on path is a stable version + pcli --home "$PCLI_HOME" view reset || true + pcli --home "$PCLI_HOME" view balance +} + +function delegate_to_genesis_validators() { + # Default genesis allo is 25k penumbra, and there are two validators, + # so let's delegate twice that. + test_delegation="75000penumbra" + + >&2 echo "Delegating ${test_delegation} to genesis validators..." + # using OLD pcli here + pcli --home "$PCLI_HOME" query validator list \ + | perl -nE '/(penumbravalid\w+)/ and say $1' \ + | xargs -r -n1 pcli --home "$PCLI_HOME" \ + tx delegate "$test_delegation" --to +} + +function main() { + deploy_fresh_devnet + check_pcli_balance + delegate_to_genesis_validators +} + +main