Skip to content

Commit

Permalink
fix(e2e): upgrade tests (#2190)
Browse files Browse the repository at this point in the history
* fix(e2e): correct upgrade-host hostname

* fix light upgrade

* remove pointless tr

* add version change assertion

* formatting

* fix voting

* improve upgrade height check

* fix upgrade name

* refactor sleep logic

---------

Co-authored-by: Lucas Bertrand <[email protected]>
  • Loading branch information
gartnera and lumtis committed May 16, 2024
1 parent 52e016e commit c171e69
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 14 deletions.
4 changes: 2 additions & 2 deletions contrib/localnet/docker-compose-upgrade-light.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ services:
orchestrator:
entrypoint: ["/work/start-zetae2e.sh", "local", "upgrade", "90"]

upgradeorchestrator:
entrypoint: ["/root/start-upgradeorchestrator.sh", "90"]
upgrade-orchestrator:
entrypoint: ["/root/start-upgrade-orchestrator.sh", "90"]
37 changes: 33 additions & 4 deletions contrib/localnet/orchestrator/start-zetae2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@
ZETAE2E_CMD=$1
OPTION=$2

get_zetacored_version() {
retries=10
node_info=""
for ((attempt=1; attempt<=$retries; attempt++)); do
node_info=$(curl -s zetacore0:1317/cosmos/base/tendermint/v1beta1/node_info)
if [[ $? == 0 ]]; then
echo "$node_info" | jq -r '.application_version.version'
return
fi
sleep 1
done
echo "Unable to get zetacored version after ${retries} retries"
exit 1
}

# Wait for authorized_keys file to exist (generated by zetacore0)
while [ ! -f ~/.ssh/authorized_keys ]; do
echo "Waiting for authorized_keys file to exist..."
Expand Down Expand Up @@ -79,17 +94,31 @@ if [ "$OPTION" == "upgrade" ]; then

echo "E2E setup passed, waiting for upgrade height..."

OLD_VERSION=$(get_zetacored_version)

CURRENT_HEIGHT=0
WAIT_HEIGHT=$(( UPGRADE_HEIGHT - 1 ))
# wait for upgrade height
while [[ $CURRENT_HEIGHT -lt $UPGRADE_HEIGHT ]]
while [[ $CURRENT_HEIGHT -lt $WAIT_HEIGHT ]]
do
CURRENT_HEIGHT=$(curl -s zetacore0:26657/status | jq '.result.sync_info.latest_block_height' | tr -d '"')
echo current height is "$CURRENT_HEIGHT", waiting for "$UPGRADE_HEIGHT"
sleep 5
CURRENT_HEIGHT=$(curl -s zetacore0:26657/status | jq -r '.result.sync_info.latest_block_height')
echo current height is "$CURRENT_HEIGHT", waiting for "$WAIT_HEIGHT"
sleep 2
done

echo "waiting 10 seconds for node to restart..."
sleep 10

NEW_VERSION=$(get_zetacored_version)

if [[ "$OLD_VERSION" == "$NEW_VERSION" ]]; then
echo "version did not change after upgrade height, maybe the upgrade did not run?"
exit 2
fi

echo "upgrade complete: ${OLD_VERSION} -> ${NEW_VERSION}"

# wait for zevm endpoint to come up
sleep 10

echo "running E2E command to test the network after upgrade..."
Expand Down
14 changes: 7 additions & 7 deletions contrib/localnet/scripts/start-upgrade-orchestrator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ done
CURRENT_HEIGHT=0
while [[ $CURRENT_HEIGHT -lt 1 ]]
do
CURRENT_HEIGHT=$(curl -s zetacore0:26657/status | jq '.result.sync_info.latest_block_height' | tr -d '"')
CURRENT_HEIGHT=$(curl -s zetacore0:26657/status | jq -r '.result.sync_info.latest_block_height')
echo "current height is ${CURRENT_HEIGHT}, waiting for 1"
sleep 1
done
Expand All @@ -30,7 +30,7 @@ scp -r zetacore0:"~/.zetacored/config ~/.zetacored/os_info ~/.zetacored/config ~
sed -i 's|tcp://localhost:26657|tcp://zetacore0:26657|g' ~/.zetacored/config/client.toml

# get new zetacored version
curl -o /tmp/zetacored.new http://upgradehost:8000/zetacored
curl -o /tmp/zetacored.new http://upgrade-host:8000/zetacored
chmod +x /tmp/zetacored.new
UPGRADE_NAME=$(/tmp/zetacored.new version)

Expand All @@ -48,7 +48,7 @@ cat > upgrade.json <<EOF
"plan": {
"height": "${UPGRADE_HEIGHT}",
"info": "",
"name": "${UPGRADE_HEIGHT}",
"name": "${UPGRADE_NAME}",
"time": "0001-01-01T00:00:00Z",
"upgraded_client_state": null
},
Expand All @@ -75,8 +75,8 @@ esac
cat > upgrade_plan_info.json <<EOF
{
"binaries": {
"linux/${GOARCH}": "http://upgradehost:8000/zetacored",
"zetaclientd-linux/${GOARCH}": "http://upgradehost:8000/zetaclientd"
"linux/${GOARCH}": "http://upgrade-host:8000/zetacored",
"zetaclientd-linux/${GOARCH}": "http://upgrade-host:8000/zetaclientd"
}
}
EOF
Expand All @@ -89,7 +89,7 @@ zetacored tx gov submit-proposal upgrade.json --from operator --keyring-backend
PROPOSAL_TX_HASH=$(jq -r .txhash proposal.json)
PROPOSAL_ID=""
# WARN: this seems to be unstable
while [[ -z $proposal_id ]]; do
while [[ -z $PROPOSAL_ID ]]; do
echo "waiting to get proposal_id"
sleep 1
# v0.47 version
Expand All @@ -100,4 +100,4 @@ while [[ -z $proposal_id ]]; do
done
echo "proposal id is ${PROPOSAL_ID}"

zetacored tx gov vote "${PROPOSAL_ID}" yes --from operator --keyring-backend test --chain-id $CHAINID--yes --fees=2000000000000000azeta
zetacored tx gov vote "${PROPOSAL_ID}" yes --from operator --keyring-backend test --chain-id $CHAINID --yes --fees=2000000000000000azeta
2 changes: 1 addition & 1 deletion contrib/localnet/scripts/start-zetacored.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,4 @@ then
sed -i -e "/persistent_peers =/s/=.*/= \"$pps\"/" "$HOME"/.zetacored/config/config.toml
fi

exec cosmovisor run start --pruning=nothing --minimum-gas-prices=0.0001azeta --json-rpc.api eth,txpool,personal,net,debug,web3,miner --api.enable --home /root/.zetacored
cosmovisor run start --pruning=nothing --minimum-gas-prices=0.0001azeta --json-rpc.api eth,txpool,personal,net,debug,web3,miner --api.enable --home /root/.zetacored

0 comments on commit c171e69

Please sign in to comment.