solana/ci/testnet-deploy.sh

169 lines
3.8 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
set -e
2018-08-27 20:37:35 -07:00
cd "$(dirname "$0")"/..
2018-07-16 12:05:48 -07:00
zone=
leaderAddress=
leaderMachineType=
clientNodeCount=0
2018-09-07 08:05:52 -07:00
validatorNodeCount=10
publicNetwork=false
snapChannel=edge
2018-11-07 13:32:48 -08:00
tarChannelOrTag=edge
delete=false
2018-09-26 10:27:31 -07:00
enableGpu=false
2018-11-07 13:32:48 -08:00
useTarReleaseChannel=false
2018-08-27 20:37:35 -07:00
usage() {
exitcode=0
if [[ -n "$1" ]]; then
exitcode=1
echo "Error: $*"
fi
cat <<EOF
2018-11-06 19:23:20 -08:00
usage: $0 [name] [cloud] [zone] [options...]
Deploys a CD testnet
name - name of the network
2018-11-06 19:23:20 -08:00
cloud - cloud provider to use (gce, ec2)
zone - cloud provider zone to deploy the network into
options:
-s edge|beta|stable - Deploy the specified Snap release channel
(default: $snapChannel)
2018-11-07 10:33:20 -08:00
-t edge|beta|stable|vX.Y.Z - Deploy the latest tarball release for the
specified release channel (edge|beta|stable) or release tag
(vX.Y.Z)
2018-11-07 13:32:48 -08:00
(default: $tarChannelOrTag)
2018-09-07 08:05:52 -07:00
-n [number] - Number of validator nodes (default: $validatorNodeCount)
-c [number] - Number of client nodes (default: $clientNodeCount)
-P - Use public network IP addresses (default: $publicNetwork)
-G - Enable GPU, and set count/type of GPUs to use (e.g n1-standard-16 --accelerator count=4,type=nvidia-tesla-k80)
2018-09-26 10:27:31 -07:00
-g - Enable GPU (default: $enableGpu)
-a [address] - Set the leader node's external IP address to this GCE address
-d - Delete the network
Note: the SOLANA_METRICS_CONFIG environment variable is used to configure
metrics
EOF
exit $exitcode
}
netName=$1
2018-11-06 19:23:20 -08:00
cloudProvider=$2
zone=$3
[[ -n $netName ]] || usage
2018-11-06 19:23:20 -08:00
[[ -n $cloudProvider ]] || usage "Cloud provider not specified"
[[ -n $zone ]] || usage "Zone not specified"
2018-11-06 19:23:20 -08:00
shift 3
2018-07-12 19:47:07 -07:00
while getopts "h?p:Pn:c:s:t:gG:a:d" opt; do
case $opt in
h | \?)
usage
2018-07-20 08:50:08 -07:00
;;
P)
publicNetwork=true
;;
2018-09-07 08:05:52 -07:00
n)
validatorNodeCount=$OPTARG
;;
c)
clientNodeCount=$OPTARG
;;
s)
case $OPTARG in
edge|beta|stable)
snapChannel=$OPTARG
;;
*)
usage "Invalid snap channel: $OPTARG"
;;
esac
;;
t)
case $OPTARG in
2018-11-07 10:33:20 -08:00
edge|beta|stable|v*)
2018-11-07 13:32:48 -08:00
tarChannelOrTag=$OPTARG
useTarReleaseChannel=true
;;
*)
usage "Invalid release channel: $OPTARG"
;;
esac
;;
2018-09-26 10:27:31 -07:00
g)
enableGpu=true
;;
G)
enableGpu=true
leaderMachineType=$OPTARG
;;
a)
leaderAddress=$OPTARG
;;
d)
delete=true
2018-07-20 08:50:08 -07:00
;;
*)
usage "Error: unhandled option: $opt"
2018-07-20 08:50:08 -07:00
;;
esac
done
2018-11-06 19:23:20 -08:00
create_args=(
-a "$leaderAddress"
-c "$clientNodeCount"
2018-09-07 08:05:52 -07:00
-n "$validatorNodeCount"
-p "$netName"
-z "$zone"
)
2018-09-26 10:27:31 -07:00
if $enableGpu; then
if [[ -z $leaderMachineType ]]; then
2018-11-06 19:23:20 -08:00
create_args+=(-g)
else
2018-11-06 19:23:20 -08:00
create_args+=(-G "$leaderMachineType")
fi
2018-09-26 10:27:31 -07:00
fi
if $publicNetwork; then
2018-11-06 19:23:20 -08:00
create_args+=(-P)
fi
2018-07-12 19:47:07 -07:00
set -x
2018-11-06 19:23:20 -08:00
echo "--- $cloudProvider.sh delete"
time net/"$cloudProvider".sh delete -z "$zone" -p "$netName"
if $delete; then
exit 0
fi
2018-11-06 19:23:20 -08:00
echo "--- $cloudProvider.sh create"
time net/"$cloudProvider".sh create "${create_args[@]}"
net/init-metrics.sh -e
2018-09-06 20:38:11 -07:00
2018-09-06 21:07:11 -07:00
echo --- net.sh start
maybeRejectExtraNodes=
if ! $publicNetwork; then
maybeRejectExtraNodes="-o rejectExtraNodes"
fi
maybeNoValidatorSanity=
if [[ -n $NO_VALIDATOR_SANITY ]]; then
maybeNoValidatorSanity="-o noValidatorSanity"
fi
maybeNoLedgerVerify=
if [[ -n $NO_LEDGER_VERIFY ]]; then
maybeNoLedgerVerify="-o noLedgerVerify"
fi
# shellcheck disable=SC2086 # Don't want to double quote maybeRejectExtraNodes
2018-11-07 13:32:48 -08:00
if $useTarReleaseChannel; then
time net/net.sh start -t "$tarChannelOrTag" $maybeRejectExtraNodes $maybeNoValidatorSanity $maybeNoLedgerVerify
else
2018-11-07 13:32:48 -08:00
time net/net.sh start -s "$snapChannel" $maybeRejectExtraNodes $maybeNoValidatorSanity $maybeNoLedgerVerify
fi
2018-07-12 19:47:07 -07:00
exit 0