From e1434401d582d684685f1162e359e0f1ddc43f4a Mon Sep 17 00:00:00 2001 From: Daniel Van Der Maden Date: Wed, 15 Jul 2020 07:43:18 -0700 Subject: [PATCH] [localnet] Reformat run.sh and use min of 8 threads for tests --- localnet/scripts/run.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/localnet/scripts/run.sh b/localnet/scripts/run.sh index b306b6d..3536a88 100644 --- a/localnet/scripts/run.sh +++ b/localnet/scripts/run.sh @@ -5,7 +5,7 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" harmony_dir="$(go env GOPATH)/src/github.com/harmony-one/harmony" localnet_config=$(realpath "$DIR/../configs/localnet_deploy.config") -function kill_localnet(){ +function kill_localnet() { pushd "$(pwd)" cd "$harmony_dir" && bash ./test/kill_node.sh killall -9 harmony || true @@ -36,7 +36,7 @@ function build_and_start_localnet() { # Dynamic for faster build iterations bash ./scripts/go_executable_build.sh -S fi - bash ./test/deploy.sh -B -D 60000 "$localnet_config" 2>&1 | tee "$localnet_log" + bash ./test/deploy.sh -B -D 60000 "$localnet_config" 2>&1 | tee "$localnet_log" popd } @@ -50,7 +50,7 @@ function wait_for_localnet_boot() { --header "Content-Type: application/json" \ --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":1}' >/dev/null; do echo "Trying to connect to localnet..." - if ((i > timeout )); then + if ((i > timeout)); then echo "TIMEOUT REACHED" exit 1 fi @@ -65,7 +65,7 @@ function wait_for_localnet_boot() { --data '{"jsonrpc":"2.0","method":"hmy_blockNumber","params":[],"id":1}' | jq '.result') if [ "$result" = "\"0x0\"" ]; then echo "Waiting for localnet to boot..." - if ((i > timeout )); then + if ((i > timeout)); then echo "TIMEOUT REACHED" exit 1 fi @@ -85,30 +85,30 @@ BUILD=true KEEP=false while getopts "Bk" option; do case ${option} in - B) BUILD=false;; - k) KEEP=true;; + B) BUILD=false ;; + k) KEEP=true ;; *) echo " Integration tester for localnet Option: Help: -B Do NOT build binray before testing -k Keep localnet running after tests are finished -" +" ;; esac done - setup build_and_start_localnet || exit 1 & sleep 20 -wait_for_localnet_boot 100 # Timeout at ~300 seconds +wait_for_localnet_boot 100 # Timeout at ~300 seconds echo -e "\n=== \e[38;5;0;48;5;255mSTARTING TESTS\e[0m ===\n" sleep 5 +proc_count=$(nproc) error=0 -cd "$DIR/../" && python3 -u -m py.test -v -r s -s tests -n auto || error=1 +cd "$DIR/../" && python3 -u -m py.test -v -r s -s tests -n $((proc_count < 8 ? 8 : proc_count)) || error=1 if [ "$KEEP" == "true" ]; then tail -f /dev/null fi -exit "$error" \ No newline at end of file +exit "$error"