solana/net/remote/remote-sanity.sh

140 lines
2.8 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
set -e
2018-09-04 23:24:33 -07:00
#
# This script is to be run on the bootstrap validator
2018-09-04 23:24:33 -07:00
#
2018-09-03 22:33:40 -07:00
2018-09-04 09:21:03 -07:00
cd "$(dirname "$0")"/../..
2018-09-03 22:33:40 -07:00
sanityTargetIp="$1"
2019-06-05 12:06:54 -07:00
shift
2018-09-04 09:21:03 -07:00
deployMethod=
entrypointIp=
2018-09-04 09:21:03 -07:00
numNodes=
failOnValidatorBootupFailure=
airdropsEnabled=true
[[ -r deployConfig ]] || {
echo deployConfig missing
exit 1
}
# shellcheck source=/dev/null # deployConfig is written by remote-node.sh
2018-09-04 09:21:03 -07:00
source deployConfig
2018-09-03 22:33:40 -07:00
2018-09-07 08:46:20 -07:00
missing() {
echo "Error: $1 not specified"
2018-09-04 09:21:03 -07:00
exit 1
}
2018-09-03 22:33:40 -07:00
[[ -n $sanityTargetIp ]] || missing sanityTargetIp
2018-12-05 17:33:32 -08:00
[[ -n $deployMethod ]] || missing deployMethod
[[ -n $entrypointIp ]] || missing entrypointIp
[[ -n $numNodes ]] || missing numNodes
[[ -n $failOnValidatorBootupFailure ]] || missing failOnValidatorBootupFailure
2018-09-07 08:46:20 -07:00
installCheck=true
rejectExtraNodes=false
while [[ $1 = -o ]]; do
2018-09-03 22:33:40 -07:00
opt="$2"
shift 2
case $opt in
noInstallCheck)
installCheck=false
;;
rejectExtraNodes)
rejectExtraNodes=true
;;
2018-09-03 22:33:40 -07:00
*)
echo "Error: unknown option: $opt"
exit 1
;;
esac
done
if [[ -n $1 ]]; then
export RUST_LOG="$1"
fi
2018-09-03 22:33:40 -07:00
source net/common.sh
loadConfigFile
case $deployMethod in
local|tar|skip)
2018-09-03 22:33:40 -07:00
PATH="$HOME"/.cargo/bin:"$PATH"
export USE_INSTALL=1
2019-10-15 07:47:45 -07:00
solana_cli=solana
2019-04-01 16:43:07 -07:00
solana_gossip=solana-gossip
solana_install=solana-install
2018-09-03 22:33:40 -07:00
;;
*)
echo "Unknown deployment method: $deployMethod"
exit 1
esac
if $failOnValidatorBootupFailure; then
2019-04-30 08:56:53 -07:00
numSanityNodes="$numNodes"
else
numSanityNodes=1
if $rejectExtraNodes; then
echo "rejectExtraNodes cannot be used with failOnValidatorBootupFailure"
exit 1
fi
fi
echo "--- $sanityTargetIp: validators"
2019-10-08 17:46:25 -07:00
(
set -x
$solana_cli --url http://"$sanityTargetIp":8899 validators
2019-10-08 17:46:25 -07:00
)
echo "--- $sanityTargetIp: node count ($numSanityNodes expected)"
2018-09-03 22:33:40 -07:00
(
set -x
nodeArg="num-nodes"
if $rejectExtraNodes; then
nodeArg="num-nodes-exactly"
fi
$solana_gossip spy --entrypoint "$sanityTargetIp:8001" \
--$nodeArg "$numSanityNodes" --timeout 60 \
2018-09-03 22:33:40 -07:00
)
echo "--- $sanityTargetIp: RPC API: getTransactionCount"
(
set -x
curl --retry 5 --retry-delay 2 --retry-connrefused \
-X POST -H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1, "method":"getTransactionCount"}' \
http://"$sanityTargetIp":8899
)
if [[ "$airdropsEnabled" = true ]]; then
echo "--- $sanityTargetIp: wallet sanity"
(
set -x
scripts/wallet-sanity.sh --url http://"$sanityTargetIp":8899
)
else
echo "^^^ +++"
echo "Note: wallet sanity is disabled as airdrops are disabled"
fi
if $installCheck && [[ -r update_manifest_keypair.json ]]; then
echo "--- $sanityTargetIp: solana-install test"
(
set -x
rm -rf install-data-dir
$solana_install init \
--no-modify-path \
--data-dir install-data-dir \
--url http://"$sanityTargetIp":8899 \
$solana_install info
)
fi
2018-09-08 14:12:32 -07:00
echo --- Pass