2018-11-11 08:19:04 -08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
2019-01-13 09:18:50 -08:00
|
|
|
|
|
|
|
iterations=1
|
|
|
|
maybeNoLeaderRotation=
|
|
|
|
extraNodes=0
|
2019-01-16 16:08:18 -08:00
|
|
|
walletRpcEndpoint=
|
2019-01-13 09:18:50 -08:00
|
|
|
|
|
|
|
usage() {
|
|
|
|
exitcode=0
|
|
|
|
if [[ -n "$1" ]]; then
|
|
|
|
exitcode=1
|
|
|
|
echo "Error: $*"
|
|
|
|
fi
|
|
|
|
cat <<EOF
|
|
|
|
usage: $0 [options...]
|
|
|
|
|
|
|
|
Start a local cluster and run sanity on it
|
|
|
|
|
|
|
|
options:
|
|
|
|
-i [number] - Number of times to run sanity (default: $iterations)
|
|
|
|
-b - Disable leader rotation
|
|
|
|
-x - Add an extra fullnode (may be supplied multiple times)
|
2019-01-16 16:08:18 -08:00
|
|
|
-r - Select the RPC endpoint hosted by a node that starts as
|
|
|
|
a validator node. If unspecified the RPC endpoint hosted by
|
|
|
|
the bootstrap leader will be used.
|
2019-01-13 09:18:50 -08:00
|
|
|
|
|
|
|
EOF
|
|
|
|
exit $exitcode
|
|
|
|
}
|
2018-07-30 12:51:35 -07:00
|
|
|
|
|
|
|
cd "$(dirname "$0")"/..
|
2019-01-13 09:18:50 -08:00
|
|
|
|
2019-01-16 16:08:18 -08:00
|
|
|
while getopts "h?i:brx" opt; do
|
2019-01-13 09:18:50 -08:00
|
|
|
case $opt in
|
|
|
|
h | \?)
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
i)
|
|
|
|
iterations=$OPTARG
|
|
|
|
;;
|
|
|
|
b)
|
|
|
|
maybeNoLeaderRotation="--no-leader-rotation"
|
|
|
|
;;
|
|
|
|
x)
|
|
|
|
extraNodes=$((extraNodes + 1))
|
|
|
|
;;
|
2019-01-16 16:08:18 -08:00
|
|
|
r)
|
|
|
|
walletRpcEndpoint="--rpc-port 18899"
|
|
|
|
;;
|
2019-01-13 09:18:50 -08:00
|
|
|
*)
|
|
|
|
usage "Error: unhandled option: $opt"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2018-12-13 21:44:50 -08:00
|
|
|
source ci/upload-ci-artifact.sh
|
2018-08-27 10:23:22 -07:00
|
|
|
source scripts/configure-metrics.sh
|
2018-07-30 12:51:35 -07:00
|
|
|
|
2018-08-27 10:23:22 -07:00
|
|
|
multinode-demo/setup.sh
|
2018-07-30 12:51:35 -07:00
|
|
|
|
2019-01-13 09:18:50 -08:00
|
|
|
backgroundCommands=(
|
|
|
|
"multinode-demo/drone.sh"
|
|
|
|
"multinode-demo/bootstrap-leader.sh $maybeNoLeaderRotation"
|
2019-01-16 16:08:18 -08:00
|
|
|
"multinode-demo/fullnode.sh $maybeNoLeaderRotation --rpc-port 18899"
|
2019-01-13 09:18:50 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
for _ in $(seq 1 $extraNodes); do
|
|
|
|
backgroundCommands+=(
|
|
|
|
"multinode-demo/fullnode-x.sh $maybeNoLeaderRotation"
|
|
|
|
)
|
|
|
|
done
|
|
|
|
numNodes=$((2 + extraNodes))
|
|
|
|
|
2018-07-30 12:51:35 -07:00
|
|
|
pids=()
|
2019-01-13 09:18:50 -08:00
|
|
|
logs=()
|
2018-07-30 12:51:35 -07:00
|
|
|
|
2019-01-13 09:18:50 -08:00
|
|
|
for cmd in "${backgroundCommands[@]}"; do
|
2018-07-30 12:51:35 -07:00
|
|
|
echo "--- Start $cmd"
|
2019-01-13 09:18:50 -08:00
|
|
|
baseCmd=$(basename "${cmd// */}" .sh)
|
|
|
|
declare log=log-$baseCmd.txt
|
|
|
|
rm -f "$log"
|
|
|
|
$cmd > "$log" 2>&1 &
|
|
|
|
logs+=("$log")
|
2018-07-30 12:51:35 -07:00
|
|
|
declare pid=$!
|
|
|
|
pids+=("$pid")
|
|
|
|
echo "pid: $pid"
|
|
|
|
done
|
|
|
|
|
2018-08-07 09:29:58 -07:00
|
|
|
killBackgroundCommands() {
|
2018-07-30 12:51:35 -07:00
|
|
|
set +e
|
|
|
|
for pid in "${pids[@]}"; do
|
|
|
|
if kill "$pid"; then
|
|
|
|
wait "$pid"
|
|
|
|
else
|
|
|
|
echo -e "^^^ +++\\nWarning: unable to kill $pid"
|
|
|
|
fi
|
|
|
|
done
|
2018-08-07 09:29:58 -07:00
|
|
|
set -e
|
|
|
|
pids=()
|
|
|
|
}
|
|
|
|
|
|
|
|
shutdown() {
|
|
|
|
exitcode=$?
|
|
|
|
killBackgroundCommands
|
|
|
|
|
|
|
|
set +e
|
2018-07-30 12:51:35 -07:00
|
|
|
|
2018-08-07 09:29:58 -07:00
|
|
|
echo "--- Upload artifacts"
|
2019-01-13 09:18:50 -08:00
|
|
|
for log in "${logs[@]}"; do
|
|
|
|
upload-ci-artifact "$log"
|
|
|
|
tail "$log"
|
2018-07-30 12:51:35 -07:00
|
|
|
done
|
2018-07-30 17:09:05 -07:00
|
|
|
|
|
|
|
exit $exitcode
|
2018-07-30 12:51:35 -07:00
|
|
|
}
|
|
|
|
|
2018-07-30 17:09:05 -07:00
|
|
|
trap shutdown EXIT INT
|
2018-07-30 12:51:35 -07:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2019-01-13 09:18:50 -08:00
|
|
|
declare iteration=1
|
|
|
|
|
2018-08-14 11:31:52 -07:00
|
|
|
flag_error() {
|
2019-01-13 09:18:50 -08:00
|
|
|
echo "Failed (iteration: $iteration/$iterations)"
|
2018-08-14 11:31:52 -07:00
|
|
|
echo "^^^ +++"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2019-01-13 09:18:50 -08:00
|
|
|
while [[ $iteration -le $iterations ]]; do
|
|
|
|
echo "--- Node count ($iteration)"
|
|
|
|
(
|
|
|
|
source multinode-demo/common.sh
|
|
|
|
set -x
|
|
|
|
client_id=/tmp/client-id.json-$$
|
|
|
|
$solana_keygen -o $client_id || exit $?
|
|
|
|
$solana_bench_tps \
|
|
|
|
--identity $client_id \
|
|
|
|
--num-nodes $numNodes \
|
|
|
|
--reject-extra-nodes \
|
|
|
|
--converge-only || exit $?
|
|
|
|
rm -rf $client_id
|
|
|
|
) || flag_error
|
|
|
|
|
2019-01-16 16:08:18 -08:00
|
|
|
echo "--- RPC API: bootstrap-leader getTransactionCount ($iteration)"
|
2019-01-13 09:18:50 -08:00
|
|
|
(
|
|
|
|
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://localhost:8899
|
|
|
|
) || flag_error
|
|
|
|
|
2019-01-16 16:08:18 -08:00
|
|
|
echo "--- RPC API: fullnode getTransactionCount ($iteration)"
|
|
|
|
(
|
|
|
|
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://localhost:18899
|
|
|
|
) || flag_error
|
|
|
|
|
2019-01-13 09:18:50 -08:00
|
|
|
echo "--- Wallet sanity ($iteration)"
|
|
|
|
(
|
|
|
|
set -x
|
2019-01-16 16:08:18 -08:00
|
|
|
# shellcheck disable=SC2086 # Don't want to double quote $walletRpcEndpoint
|
|
|
|
timeout 60s scripts/wallet-sanity.sh $walletRpcEndpoint
|
2019-01-13 09:18:50 -08:00
|
|
|
) || flag_error
|
|
|
|
|
|
|
|
iteration=$((iteration + 1))
|
|
|
|
done
|
2019-01-09 11:39:27 -08:00
|
|
|
|
2018-08-07 09:29:58 -07:00
|
|
|
killBackgroundCommands
|
2018-08-14 11:31:52 -07:00
|
|
|
|
|
|
|
echo "--- Ledger verification"
|
|
|
|
(
|
2018-08-27 10:23:22 -07:00
|
|
|
source multinode-demo/common.sh
|
2018-09-08 12:50:43 -07:00
|
|
|
set -x
|
2018-12-06 13:38:45 -08:00
|
|
|
cp -R "$SOLANA_CONFIG_DIR"/bootstrap-leader-ledger /tmp/ledger-$$
|
2018-12-04 21:30:08 -08:00
|
|
|
$solana_ledger_tool --ledger /tmp/ledger-$$ verify || exit $?
|
2018-08-27 17:57:04 -07:00
|
|
|
rm -rf /tmp/ledger-$$
|
2018-08-14 11:31:52 -07:00
|
|
|
) || flag_error
|
2018-07-30 12:51:35 -07:00
|
|
|
|
|
|
|
echo +++
|
2019-01-13 09:18:50 -08:00
|
|
|
echo "Ok ($iterations iterations)"
|
|
|
|
|
2018-07-30 12:51:35 -07:00
|
|
|
exit 0
|