2018-07-15 09:23:35 -07:00
|
|
|
#!/bin/bash -e
|
2018-08-27 20:37:35 -07:00
|
|
|
|
2018-09-06 10:34:24 -07:00
|
|
|
cd "$(dirname "$0")"/..
|
2018-07-16 12:05:48 -07:00
|
|
|
|
2018-09-06 10:34:24 -07:00
|
|
|
zone=
|
|
|
|
leaderAddress=
|
2018-09-27 13:42:24 -07:00
|
|
|
leaderMachineType=
|
2018-09-06 10:34:24 -07:00
|
|
|
clientNodeCount=0
|
2018-09-07 08:05:52 -07:00
|
|
|
validatorNodeCount=10
|
2018-09-06 10:34:24 -07:00
|
|
|
publicNetwork=false
|
|
|
|
snapChannel=edge
|
2018-10-30 18:05:38 -07:00
|
|
|
releaseChannel=edge
|
2018-09-06 10:34:24 -07:00
|
|
|
delete=false
|
2018-09-26 10:27:31 -07:00
|
|
|
enableGpu=false
|
2018-10-30 18:05:38 -07:00
|
|
|
useReleaseChannel=false
|
2018-08-27 20:37:35 -07:00
|
|
|
|
2018-09-06 10:34:24 -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
|
2018-09-06 10:34:24 -07:00
|
|
|
|
|
|
|
options:
|
|
|
|
-s edge|beta|stable - Deploy the specified Snap release channel
|
|
|
|
(default: $snapChannel)
|
2018-10-30 18:05:38 -07:00
|
|
|
-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)
|
2018-09-06 10:34:24 -07:00
|
|
|
-c [number] - Number of client nodes (default: $clientNodeCount)
|
|
|
|
-P - Use public network IP addresses (default: $publicNetwork)
|
2018-09-27 13:42:24 -07:00
|
|
|
-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)
|
2018-09-06 10:34:24 -07:00
|
|
|
-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
|
|
|
|
}
|
2018-09-06 08:29:43 -07:00
|
|
|
|
2018-09-06 10:34:24 -07:00
|
|
|
netName=$1
|
|
|
|
zone=$2
|
|
|
|
[[ -n $netName ]] || usage
|
|
|
|
[[ -n $zone ]] || usage "Zone not specified"
|
|
|
|
shift 2
|
2018-07-12 19:47:07 -07:00
|
|
|
|
2018-10-30 18:05:38 -07:00
|
|
|
while getopts "h?p:Pn:c:s:t:gG:a:d" opt; do
|
2018-09-06 10:34:24 -07:00
|
|
|
case $opt in
|
|
|
|
h | \?)
|
|
|
|
usage
|
2018-07-20 08:50:08 -07:00
|
|
|
;;
|
2018-09-06 10:34:24 -07:00
|
|
|
P)
|
|
|
|
publicNetwork=true
|
|
|
|
;;
|
2018-09-07 08:05:52 -07:00
|
|
|
n)
|
|
|
|
validatorNodeCount=$OPTARG
|
|
|
|
;;
|
2018-09-06 10:34:24 -07:00
|
|
|
c)
|
|
|
|
clientNodeCount=$OPTARG
|
|
|
|
;;
|
|
|
|
s)
|
|
|
|
case $OPTARG in
|
|
|
|
edge|beta|stable)
|
|
|
|
snapChannel=$OPTARG
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage "Invalid snap channel: $OPTARG"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
2018-10-30 18:05:38 -07:00
|
|
|
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
|
|
|
|
;;
|
2018-09-27 13:42:24 -07:00
|
|
|
G)
|
|
|
|
enableGpu=true
|
|
|
|
leaderMachineType=$OPTARG
|
|
|
|
;;
|
2018-09-06 10:34:24 -07:00
|
|
|
a)
|
|
|
|
leaderAddress=$OPTARG
|
|
|
|
;;
|
|
|
|
d)
|
|
|
|
delete=true
|
2018-07-20 08:50:08 -07:00
|
|
|
;;
|
|
|
|
*)
|
2018-09-06 10:34:24 -07:00
|
|
|
usage "Error: unhandled option: $opt"
|
2018-07-20 08:50:08 -07:00
|
|
|
;;
|
|
|
|
esac
|
2018-09-06 10:34:24 -07:00
|
|
|
done
|
2018-08-02 20:39:19 -07:00
|
|
|
|
|
|
|
|
2018-09-06 10:34:24 -07:00
|
|
|
gce_create_args=(
|
|
|
|
-a "$leaderAddress"
|
|
|
|
-c "$clientNodeCount"
|
2018-09-07 08:05:52 -07:00
|
|
|
-n "$validatorNodeCount"
|
2018-09-06 10:34:24 -07:00
|
|
|
-p "$netName"
|
|
|
|
-z "$zone"
|
|
|
|
)
|
2018-08-02 20:39:19 -07:00
|
|
|
|
2018-09-26 10:27:31 -07:00
|
|
|
if $enableGpu; then
|
2018-09-27 13:42:24 -07:00
|
|
|
if [[ -z $leaderMachineType ]]; then
|
|
|
|
gce_create_args+=(-g)
|
|
|
|
else
|
|
|
|
gce_create_args+=(-G "$leaderMachineType")
|
|
|
|
fi
|
2018-09-26 10:27:31 -07:00
|
|
|
fi
|
|
|
|
|
2018-09-06 10:34:24 -07:00
|
|
|
if $publicNetwork; then
|
|
|
|
gce_create_args+=(-P)
|
2018-07-28 12:16:28 -07:00
|
|
|
fi
|
2018-07-12 19:47:07 -07:00
|
|
|
|
2018-09-06 10:34:24 -07:00
|
|
|
set -x
|
2018-07-23 14:49:51 -07:00
|
|
|
|
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"
|
2018-09-06 10:34:24 -07:00
|
|
|
if $delete; then
|
|
|
|
exit 0
|
2018-07-23 14:49:51 -07:00
|
|
|
fi
|
|
|
|
|
2018-09-06 20:38:11 -07:00
|
|
|
echo --- gce.sh create
|
2018-09-06 10:34:24 -07:00
|
|
|
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
|
2018-09-11 20:00:49 -07:00
|
|
|
maybeRejectExtraNodes=
|
|
|
|
if ! $publicNetwork; then
|
|
|
|
maybeRejectExtraNodes="-o rejectExtraNodes"
|
|
|
|
fi
|
2018-10-31 12:30:33 -07:00
|
|
|
maybeNoValidatorSanity=
|
|
|
|
if [[ -n $NO_VALIDATOR_SANITY ]]; then
|
|
|
|
maybeNoValidatorSanity="-o noValidatorSanity"
|
|
|
|
fi
|
|
|
|
maybeNoLedgerVerify=
|
|
|
|
if [[ -n $NO_LEDGER_VERIFY ]]; then
|
|
|
|
maybeNoLedgerVerify="-o noLedgerVerify"
|
|
|
|
fi
|
2018-09-11 20:00:49 -07:00
|
|
|
# shellcheck disable=SC2086 # Don't want to double quote maybeRejectExtraNodes
|
2018-10-30 18:05:38 -07:00
|
|
|
if ! $useReleaseChannel; then
|
2018-10-31 12:30:33 -07:00
|
|
|
time net/net.sh start -s "$snapChannel" $maybeRejectExtraNodes $maybeNoValidatorSanity $maybeNoLedgerVerify
|
2018-10-30 18:05:38 -07:00
|
|
|
else
|
2018-10-31 12:30:33 -07:00
|
|
|
time net/net.sh start -t "$releaseChannel" $maybeRejectExtraNodes $maybeNoValidatorSanity $maybeNoLedgerVerify
|
2018-10-30 18:05:38 -07:00
|
|
|
fi
|
2018-07-12 19:47:07 -07:00
|
|
|
exit 0
|