solana/ci/testnet-deploy.sh

155 lines
3.1 KiB
Bash
Raw Normal View History

#!/bin/bash -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
releaseChannel=edge
delete=false
2018-09-26 10:27:31 -07:00
enableGpu=false
useReleaseChannel=false
2018-08-27 20:37:35 -07:00
usage() {
exitcode=0
if [[ -n "$1" ]]; then
exitcode=1
echo "Error: $*"
fi
cat <<EOF
usage: $0 [name] [zone] [options...]
Deploys a CD testnet
name - name of the network
2018-09-28 07:32:49 -07:00
zone - zone to deploy the network into
options:
-s edge|beta|stable - Deploy the specified Snap release channel
(default: $snapChannel)
-t edge|beta|stable - Deploy the specified prebuilt tar from channel
(default: $releaseChannel)
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
zone=$2
[[ -n $netName ]] || usage
[[ -n $zone ]] || usage "Zone not specified"
shift 2
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
edge|beta|stable)
releaseChannel=$OPTARG
useReleaseChannel=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
gce_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
gce_create_args+=(-g)
else
gce_create_args+=(-G "$leaderMachineType")
fi
2018-09-26 10:27:31 -07:00
fi
if $publicNetwork; then
gce_create_args+=(-P)
fi
2018-07-12 19:47:07 -07:00
set -x
2018-09-06 20:38:11 -07:00
echo --- gce.sh delete
2018-09-27 21:27:09 -07:00
time net/gce.sh delete -z "$zone" -p "$netName"
if $delete; then
exit 0
fi
2018-09-06 20:38:11 -07:00
echo --- gce.sh create
time net/gce.sh create "${gce_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
# shellcheck disable=SC2086 # Don't want to double quote maybeRejectExtraNodes
if ! $useReleaseChannel; then
time net/net.sh start -s "$snapChannel" $maybeRejectExtraNodes
else
time net/net.sh start -t "$releaseChannel" $maybeRejectExtraNodes
fi
2018-07-12 19:47:07 -07:00
exit 0