Add ability to use the RPC endpoint from a node other than the bootstrap leader

This commit is contained in:
Michael Vines 2019-01-16 16:08:18 -08:00 committed by Grimes
parent da1201c552
commit 825d8ef6c9
2 changed files with 22 additions and 4 deletions

View File

@ -4,6 +4,7 @@ set -e
iterations=1 iterations=1
maybeNoLeaderRotation= maybeNoLeaderRotation=
extraNodes=0 extraNodes=0
walletRpcEndpoint=
usage() { usage() {
exitcode=0 exitcode=0
@ -20,6 +21,9 @@ Start a local cluster and run sanity on it
-i [number] - Number of times to run sanity (default: $iterations) -i [number] - Number of times to run sanity (default: $iterations)
-b - Disable leader rotation -b - Disable leader rotation
-x - Add an extra fullnode (may be supplied multiple times) -x - Add an extra fullnode (may be supplied multiple times)
-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.
EOF EOF
exit $exitcode exit $exitcode
@ -27,7 +31,7 @@ EOF
cd "$(dirname "$0")"/.. cd "$(dirname "$0")"/..
while getopts "h?i:bx" opt; do while getopts "h?i:brx" opt; do
case $opt in case $opt in
h | \?) h | \?)
usage usage
@ -41,6 +45,9 @@ while getopts "h?i:bx" opt; do
x) x)
extraNodes=$((extraNodes + 1)) extraNodes=$((extraNodes + 1))
;; ;;
r)
walletRpcEndpoint="--rpc-port 18899"
;;
*) *)
usage "Error: unhandled option: $opt" usage "Error: unhandled option: $opt"
;; ;;
@ -55,7 +62,7 @@ multinode-demo/setup.sh
backgroundCommands=( backgroundCommands=(
"multinode-demo/drone.sh" "multinode-demo/drone.sh"
"multinode-demo/bootstrap-leader.sh $maybeNoLeaderRotation" "multinode-demo/bootstrap-leader.sh $maybeNoLeaderRotation"
"multinode-demo/fullnode.sh $maybeNoLeaderRotation" "multinode-demo/fullnode.sh $maybeNoLeaderRotation --rpc-port 18899"
) )
for _ in $(seq 1 $extraNodes); do for _ in $(seq 1 $extraNodes); do
@ -135,7 +142,7 @@ while [[ $iteration -le $iterations ]]; do
rm -rf $client_id rm -rf $client_id
) || flag_error ) || flag_error
echo "--- RPC API: getTransactionCount ($iteration)" echo "--- RPC API: bootstrap-leader getTransactionCount ($iteration)"
( (
set -x set -x
curl --retry 5 --retry-delay 2 --retry-connrefused \ curl --retry 5 --retry-delay 2 --retry-connrefused \
@ -144,10 +151,20 @@ while [[ $iteration -le $iterations ]]; do
http://localhost:8899 http://localhost:8899
) || flag_error ) || flag_error
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
echo "--- Wallet sanity ($iteration)" echo "--- Wallet sanity ($iteration)"
( (
set -x set -x
timeout 60s scripts/wallet-sanity.sh # shellcheck disable=SC2086 # Don't want to double quote $walletRpcEndpoint
timeout 60s scripts/wallet-sanity.sh $walletRpcEndpoint
) || flag_error ) || flag_error
iteration=$((iteration + 1)) iteration=$((iteration + 1))

View File

@ -216,6 +216,7 @@ while true; do
done done
trap 'kill "$pid" && wait "$pid"' INT TERM trap 'kill "$pid" && wait "$pid"' INT TERM
# shellcheck disable=SC2086 # Don't want to double quote # maybe_rpc_port
$program \ $program \
$maybe_no_leader_rotation \ $maybe_no_leader_rotation \
$maybe_rpc_port \ $maybe_rpc_port \