Skip to content

Commit

Permalink
ci: begin e2e migration upgrade script
Browse files Browse the repository at this point in the history
This script duplicates a lot of the logic in the `migration-testing`
branch, but it's targeting the online cluster rather than a local
devnet. This is quite important to do, to ensure we exercise
functionality like the auto-restart of the statefulsets, and also the
multi-validator setup, which has surfaced bugs easily overlooked in a
simple devnet migration.
  • Loading branch information
conorsch committed May 24, 2024
1 parent 335d9e9 commit 318b577
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions deployments/scripts/k8s-e2e-upgrade-test
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 318b577

Please sign in to comment.