From 825d8ef6c9ebe5d33c6e2c7202c2ee463dfa5906 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Wed, 16 Jan 2019 16:08:18 -0800 Subject: [PATCH] Add ability to use the RPC endpoint from a node other than the bootstrap leader --- ci/localnet-sanity.sh | 25 +++++++++++++++++++++---- multinode-demo/fullnode.sh | 1 + 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ci/localnet-sanity.sh b/ci/localnet-sanity.sh index f2528ba09..d8b899000 100755 --- a/ci/localnet-sanity.sh +++ b/ci/localnet-sanity.sh @@ -4,6 +4,7 @@ set -e iterations=1 maybeNoLeaderRotation= extraNodes=0 +walletRpcEndpoint= usage() { 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) -b - Disable leader rotation -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 exit $exitcode @@ -27,7 +31,7 @@ EOF cd "$(dirname "$0")"/.. -while getopts "h?i:bx" opt; do +while getopts "h?i:brx" opt; do case $opt in h | \?) usage @@ -41,6 +45,9 @@ while getopts "h?i:bx" opt; do x) extraNodes=$((extraNodes + 1)) ;; + r) + walletRpcEndpoint="--rpc-port 18899" + ;; *) usage "Error: unhandled option: $opt" ;; @@ -55,7 +62,7 @@ multinode-demo/setup.sh backgroundCommands=( "multinode-demo/drone.sh" "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 @@ -135,7 +142,7 @@ while [[ $iteration -le $iterations ]]; do rm -rf $client_id ) || flag_error - echo "--- RPC API: getTransactionCount ($iteration)" + echo "--- RPC API: bootstrap-leader getTransactionCount ($iteration)" ( set -x curl --retry 5 --retry-delay 2 --retry-connrefused \ @@ -144,10 +151,20 @@ while [[ $iteration -le $iterations ]]; do http://localhost:8899 ) || 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)" ( 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 iteration=$((iteration + 1)) diff --git a/multinode-demo/fullnode.sh b/multinode-demo/fullnode.sh index 96184866f..de4e7d3d1 100755 --- a/multinode-demo/fullnode.sh +++ b/multinode-demo/fullnode.sh @@ -216,6 +216,7 @@ while true; do done trap 'kill "$pid" && wait "$pid"' INT TERM +# shellcheck disable=SC2086 # Don't want to double quote # maybe_rpc_port $program \ $maybe_no_leader_rotation \ $maybe_rpc_port \