From d28b643c844ee812e940d63043bb63378cf146c5 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Sun, 13 Jan 2019 09:18:50 -0800 Subject: [PATCH] localnet-sanity.sh now supports iterations testing --- ci/localnet-sanity.sh | 145 ++++++++++++++++++++++++++++++------------ ci/test-stable.sh | 2 +- 2 files changed, 105 insertions(+), 42 deletions(-) diff --git a/ci/localnet-sanity.sh b/ci/localnet-sanity.sh index 4bdc68af5..f2528ba09 100755 --- a/ci/localnet-sanity.sh +++ b/ci/localnet-sanity.sh @@ -1,23 +1,80 @@ #!/usr/bin/env bash set -e -# -# Perform a quick sanity test on a leader, drone, validator and client running -# locally on the same machine -# + +iterations=1 +maybeNoLeaderRotation= +extraNodes=0 + +usage() { + exitcode=0 + if [[ -n "$1" ]]; then + exitcode=1 + echo "Error: $*" + fi + cat < log-"$cmd".txt 2>&1 & + baseCmd=$(basename "${cmd// */}" .sh) + declare log=log-$baseCmd.txt + rm -f "$log" + $cmd > "$log" 2>&1 & + logs+=("$log") declare pid=$! pids+=("$pid") echo "pid: $pid" @@ -43,10 +100,9 @@ shutdown() { set +e echo "--- Upload artifacts" - for cmd in $backgroundCommands; do - declare logfile=log-$cmd.txt - upload-ci-artifact "$logfile" - tail "$logfile" + for log in "${logs[@]}"; do + upload-ci-artifact "$log" + tail "$log" done exit $exitcode @@ -56,40 +112,46 @@ trap shutdown EXIT INT set -e +declare iteration=1 + flag_error() { - echo Failed + echo "Failed (iteration: $iteration/$iterations)" echo "^^^ +++" exit 1 } -echo "--- Node count" -( - 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 3 \ - --reject-extra-nodes \ - --converge-only || exit $? - rm -rf $client_id -) || flag_error +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 -echo "--- 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://localhost:8899 -) || flag_error + echo "--- RPC API: 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:8899 + ) || flag_error -echo "--- Wallet sanity" -( - set -x - timeout 60s scripts/wallet-sanity.sh -) || flag_error + echo "--- Wallet sanity ($iteration)" + ( + set -x + timeout 60s scripts/wallet-sanity.sh + ) || flag_error + + iteration=$((iteration + 1)) +done killBackgroundCommands @@ -103,5 +165,6 @@ echo "--- Ledger verification" ) || flag_error echo +++ -echo Ok +echo "Ok ($iterations iterations)" + exit 0 diff --git a/ci/test-stable.sh b/ci/test-stable.sh index 473b122a9..7a0681dee 100755 --- a/ci/test-stable.sh +++ b/ci/test-stable.sh @@ -39,5 +39,5 @@ echo --- ci/localnet-sanity.sh set -x # Assume |cargo build| has populated target/debug/ successfully. export PATH=$PWD/target/debug:$PATH - USE_INSTALL=1 ci/localnet-sanity.sh + USE_INSTALL=1 ci/localnet-sanity.sh -x )