Generalize testnet deployment scripts

This commit is contained in:
Michael Vines
2018-07-20 08:50:08 -07:00
parent 686e61d50c
commit 68ca9b2cb8
2 changed files with 64 additions and 35 deletions

View File

@ -22,35 +22,48 @@ if [[ -z $SOLANA_SNAP_CHANNEL ]]; then
SOLANA_SNAP_CHANNEL=edge SOLANA_SNAP_CHANNEL=edge
fi fi
case $SOLANA_SNAP_CHANNEL in # Select default network URL based on SOLANA_SNAP_CHANNEL if SOLANA_NET_URL is
edge) # unspecified
publicUrl=master.testnet.solana.com if [[ -z $SOLANA_NET_URL ]]; then
publicIp=$(dig +short $publicUrl | head -n1) case $SOLANA_SNAP_CHANNEL in
;; edge)
beta) SOLANA_NET_URL=master.testnet.solana.com
publicUrl=testnet.solana.com ;;
beta)
SOLANA_NET_URL=testnet.solana.com
;;
*)
echo Error: Unknown SOLANA_SNAP_CHANNEL=$SOLANA_SNAP_CHANNEL
exit 1
;;
esac
fi
echo "+++ Configuration"
publicUrl="$SOLANA_NET_URL"
if [[ $publicUrl = testnet.solana.com ]]; then
publicIp="" # Use default value publicIp="" # Use default value
;; else
*) publicIp=$(dig +short $publicUrl | head -n1)
echo Error: Unknown SOLANA_SNAP_CHANNEL=$SOLANA_SNAP_CHANNEL fi
exit 1
;;
esac
resourcePrefix=${publicUrl//./-} echo "Network entrypoint URL: $publicUrl ($publicIp)"
vmlist=("$resourcePrefix":us-west1-b) # Leader is hard coded as the first entry echo "Snap channel: $SOLANA_SNAP_CHANNEL"
validatorNamePrefix=$resourcePrefix-validator-
echo "--- Available validators for $publicUrl" leaderName=${publicUrl//./-}
filter="name~^$validatorNamePrefix" vmlist=()
gcloud compute instances list --filter="$filter"
while read -r vmName vmZone status; do findVms() {
if [[ $status != RUNNING ]]; then declare filter="$1"
echo "Warning: $vmName is not RUNNING, ignoring it." gcloud compute instances list --filter="$filter"
continue while read -r vmName vmZone status; do
fi if [[ $status != RUNNING ]]; then
vmlist+=("$vmName:$vmZone") echo "Warning: $vmName is not RUNNING, ignoring it."
done < <(gcloud compute instances list --filter="$filter" --format 'value(name,zone,status)') continue
fi
vmlist+=("$vmName:$vmZone")
done < <(gcloud compute instances list --filter="$filter" --format 'value(name,zone,status)')
}
wait_for_node() { wait_for_node() {
declare pid=$1 declare pid=$1
@ -64,6 +77,16 @@ wait_for_node() {
fi fi
} }
echo "Leader node:"
findVms "name=$leaderName"
[[ ${#vmlist[@]} = 1 ]] || {
echo "Unable to find $leaderName"
exit 1
}
echo "Validator nodes:"
findVms "name~^$leaderName-validator-"
if ! $ROLLING_UPDATE; then if ! $ROLLING_UPDATE; then
count=1 count=1
for info in "${vmlist[@]}"; do for info in "${vmlist[@]}"; do
@ -87,7 +110,7 @@ if ! $ROLLING_UPDATE; then
wait wait
fi fi
echo "--- Refreshing leader for $publicUrl" echo "--- Refreshing leader"
leader=true leader=true
pids=() pids=()
count=1 count=1

View File

@ -6,19 +6,25 @@
cd "$(dirname "$0")/.." cd "$(dirname "$0")/.."
source multinode-demo/common.sh source multinode-demo/common.sh
TESTNET=$1 NET_URL=$1
if [[ -z $TESTNET ]]; then if [[ -z $NET_URL ]]; then
TESTNET=testnet.solana.com NET_URL=testnet.solana.com
fi fi
echo "--- $TESTNET: wallet sanity" EXPECTED_NODE_COUNT=$2
multinode-demo/test/wallet-sanity.sh $TESTNET if [[ -z $EXPECTED_NODE_COUNT ]]; then
EXPECTED_NODE_COUNT=50
fi
echo "--- $TESTNET: node count"
if [[ $TESTNET = testnet.solana.com ]]; then echo "--- $NET_URL: wallet sanity"
multinode-demo/test/wallet-sanity.sh $NET_URL
echo "--- $NET_URL: node count"
if [[ $NET_URL = testnet.solana.com ]]; then
echo "TODO: Remove this block when a release > 0.7.0 is deployed" echo "TODO: Remove this block when a release > 0.7.0 is deployed"
else else
$solana_client_demo $TESTNET 50 -c # <-- Expect to see at least 50 nodes $solana_client_demo $NET_URL $EXPECTED_NODE_COUNT -c
fi fi
exit 0 exit 0