[localnet] Reformat run.sh and use min of 8 threads for tests

pull/1/head
Daniel Van Der Maden 4 years ago
parent 304b6330e8
commit e1434401d5
  1. 22
      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"
exit "$error"

Loading…
Cancel
Save