diff --git a/test/app/clean.sh b/test/app/clean.sh index 8c5562239..22814f015 100644 --- a/test/app/clean.sh +++ b/test/app/clean.sh @@ -1,4 +1,3 @@ killall tendermint -killall dummy -killall counter +killall abci-cli rm -rf ~/.tendermint_app diff --git a/test/app/dummy_test.sh b/test/app/dummy_test.sh index 1a117c634..b3db0b86b 100644 --- a/test/app/dummy_test.sh +++ b/test/app/dummy_test.sh @@ -2,7 +2,7 @@ set -e function toHex() { - echo -n $1 | hexdump -ve '1/1 "%.2X"' | awk '{print "0x" $0}' + echo -n $1 | hexdump -ve '1/1 "%.2X"' | awk '{print "0x" $0}' } @@ -32,9 +32,9 @@ RESPONSE=`abci-cli query \"$KEY\"` set +e A=`echo $RESPONSE | grep "$VALUE"` if [[ $? != 0 ]]; then - echo "Failed to find $VALUE for $KEY. Response:" - echo "$RESPONSE" - exit 1 + echo "Failed to find $VALUE for $KEY. Response:" + echo "$RESPONSE" + exit 1 fi set -e @@ -43,9 +43,9 @@ RESPONSE=`abci-cli query \"$VALUE\"` set +e A=`echo $RESPONSE | grep $VALUE` if [[ $? == 0 ]]; then - echo "Found '$VALUE' for $VALUE when we should not have. Response:" - echo "$RESPONSE" - exit 1 + echo "Found '$VALUE' for $VALUE when we should not have. Response:" + echo "$RESPONSE" + exit 1 fi set -e @@ -62,9 +62,9 @@ RESPONSE=`echo $RESPONSE | jq .result.response.log` set +e A=`echo $RESPONSE | grep 'exists'` if [[ $? != 0 ]]; then - echo "Failed to find 'exists' for $KEY. Response:" - echo "$RESPONSE" - exit 1 + echo "Failed to find 'exists' for $KEY. Response:" + echo "$RESPONSE" + exit 1 fi set -e @@ -74,9 +74,9 @@ RESPONSE=`echo $RESPONSE | jq .result.response.log` set +e A=`echo $RESPONSE | grep 'exists'` if [[ $? == 0 ]]; then - echo "Found 'exists' for $VALUE when we should not have. Response:" - echo "$RESPONSE" - exit 1 + echo "Found 'exists' for $VALUE when we should not have. Response:" + echo "$RESPONSE" + exit 1 fi set -e diff --git a/test/app/test.sh b/test/app/test.sh index cd312b68a..355fab45e 100644 --- a/test/app/test.sh +++ b/test/app/test.sh @@ -11,118 +11,118 @@ set -e export TMHOME=$HOME/.tendermint_app function dummy_over_socket(){ - rm -rf $TMHOME - tendermint init - echo "Starting dummy_over_socket" - dummy > /dev/null & - pid_dummy=$! - tendermint node > tendermint.log & - pid_tendermint=$! - sleep 5 - - echo "running test" - bash dummy_test.sh "Dummy over Socket" - - kill -9 $pid_dummy $pid_tendermint + rm -rf $TMHOME + tendermint init + echo "Starting dummy_over_socket" + abci-cli dummy > /dev/null & + pid_dummy=$! + tendermint node > tendermint.log & + pid_tendermint=$! + sleep 5 + + echo "running test" + bash dummy_test.sh "Dummy over Socket" + + kill -9 $pid_dummy $pid_tendermint } # start tendermint first function dummy_over_socket_reorder(){ - rm -rf $TMHOME - tendermint init - echo "Starting dummy_over_socket_reorder (ie. start tendermint first)" - tendermint node > tendermint.log & - pid_tendermint=$! - sleep 2 - dummy > /dev/null & - pid_dummy=$! - sleep 5 - - echo "running test" - bash dummy_test.sh "Dummy over Socket" - - kill -9 $pid_dummy $pid_tendermint + rm -rf $TMHOME + tendermint init + echo "Starting dummy_over_socket_reorder (ie. start tendermint first)" + tendermint node > tendermint.log & + pid_tendermint=$! + sleep 2 + abci-cli dummy > /dev/null & + pid_dummy=$! + sleep 5 + + echo "running test" + bash dummy_test.sh "Dummy over Socket" + + kill -9 $pid_dummy $pid_tendermint } function counter_over_socket() { - rm -rf $TMHOME - tendermint init - echo "Starting counter_over_socket" - counter --serial > /dev/null & - pid_counter=$! - tendermint node > tendermint.log & - pid_tendermint=$! - sleep 5 - - echo "running test" - bash counter_test.sh "Counter over Socket" - - kill -9 $pid_counter $pid_tendermint + rm -rf $TMHOME + tendermint init + echo "Starting counter_over_socket" + abci-cli counter --serial > /dev/null & + pid_counter=$! + tendermint node > tendermint.log & + pid_tendermint=$! + sleep 5 + + echo "running test" + bash counter_test.sh "Counter over Socket" + + kill -9 $pid_counter $pid_tendermint } function counter_over_grpc() { - rm -rf $TMHOME - tendermint init - echo "Starting counter_over_grpc" - counter --serial --abci grpc > /dev/null & - pid_counter=$! - tendermint node --abci grpc > tendermint.log & - pid_tendermint=$! - sleep 5 - - echo "running test" - bash counter_test.sh "Counter over GRPC" - - kill -9 $pid_counter $pid_tendermint + rm -rf $TMHOME + tendermint init + echo "Starting counter_over_grpc" + abci-cli counter --serial --abci grpc > /dev/null & + pid_counter=$! + tendermint node --abci grpc > tendermint.log & + pid_tendermint=$! + sleep 5 + + echo "running test" + bash counter_test.sh "Counter over GRPC" + + kill -9 $pid_counter $pid_tendermint } function counter_over_grpc_grpc() { - rm -rf $TMHOME - tendermint init - echo "Starting counter_over_grpc_grpc (ie. with grpc broadcast_tx)" - counter --serial --abci grpc > /dev/null & - pid_counter=$! - sleep 1 - GRPC_PORT=36656 - tendermint node --abci grpc --rpc.grpc_laddr tcp://localhost:$GRPC_PORT > tendermint.log & - pid_tendermint=$! - sleep 5 - - echo "running test" - GRPC_BROADCAST_TX=true bash counter_test.sh "Counter over GRPC via GRPC BroadcastTx" - - kill -9 $pid_counter $pid_tendermint + rm -rf $TMHOME + tendermint init + echo "Starting counter_over_grpc_grpc (ie. with grpc broadcast_tx)" + abci-cli counter --serial --abci grpc > /dev/null & + pid_counter=$! + sleep 1 + GRPC_PORT=36656 + tendermint node --abci grpc --rpc.grpc_laddr tcp://localhost:$GRPC_PORT > tendermint.log & + pid_tendermint=$! + sleep 5 + + echo "running test" + GRPC_BROADCAST_TX=true bash counter_test.sh "Counter over GRPC via GRPC BroadcastTx" + + kill -9 $pid_counter $pid_tendermint } cd $GOPATH/src/github.com/tendermint/tendermint/test/app case "$1" in - "dummy_over_socket") - dummy_over_socket - ;; - "dummy_over_socket_reorder") - dummy_over_socket_reorder - ;; - "counter_over_socket") - counter_over_socket - ;; - "counter_over_grpc") - counter_over_grpc - ;; - "counter_over_grpc_grpc") - counter_over_grpc_grpc - ;; - *) - echo "Running all" - dummy_over_socket - echo "" - dummy_over_socket_reorder - echo "" - counter_over_socket - echo "" - counter_over_grpc - echo "" - counter_over_grpc_grpc + "dummy_over_socket") + dummy_over_socket + ;; +"dummy_over_socket_reorder") + dummy_over_socket_reorder + ;; + "counter_over_socket") + counter_over_socket + ;; +"counter_over_grpc") + counter_over_grpc + ;; + "counter_over_grpc_grpc") + counter_over_grpc_grpc + ;; +*) + echo "Running all" + dummy_over_socket + echo "" + dummy_over_socket_reorder + echo "" + counter_over_socket + echo "" + counter_over_grpc + echo "" + counter_over_grpc_grpc esac diff --git a/test/persist/test_failure_indices.sh b/test/persist/test_failure_indices.sh index 41c17a094..6c40786d9 100644 --- a/test/persist/test_failure_indices.sh +++ b/test/persist/test_failure_indices.sh @@ -9,66 +9,66 @@ tendermint init RPC_ADDR="$(pwd)/rpc.sock" TM_CMD="tendermint node --log_level=debug --rpc.laddr=unix://$RPC_ADDR" # &> tendermint_${name}.log" -DUMMY_CMD="dummy --persist $TMHOME/dummy" # &> dummy_${name}.log" +DUMMY_CMD="abci-cli dummy --persist $TMHOME/dummy" # &> dummy_${name}.log" function start_procs(){ - name=$1 - indexToFail=$2 - echo "Starting persistent dummy and tendermint" - if [[ "$CIRCLECI" == true ]]; then - $DUMMY_CMD & - else - $DUMMY_CMD &> "dummy_${name}.log" & - fi - PID_DUMMY=$! - - # before starting tendermint, remove the rpc socket - rm $RPC_ADDR - if [[ "$indexToFail" == "" ]]; then - # run in background, dont fail - if [[ "$CIRCLECI" == true ]]; then - $TM_CMD & - else - $TM_CMD &> "tendermint_${name}.log" & - fi - PID_TENDERMINT=$! - else - # run in foreground, fail - if [[ "$CIRCLECI" == true ]]; then - FAIL_TEST_INDEX=$indexToFail $TM_CMD - else - FAIL_TEST_INDEX=$indexToFail $TM_CMD &> "tendermint_${name}.log" - fi - PID_TENDERMINT=$! - fi + name=$1 + indexToFail=$2 + echo "Starting persistent dummy and tendermint" + if [[ "$CIRCLECI" == true ]]; then + $DUMMY_CMD & + else + $DUMMY_CMD &> "dummy_${name}.log" & + fi + PID_DUMMY=$! + + # before starting tendermint, remove the rpc socket + rm $RPC_ADDR + if [[ "$indexToFail" == "" ]]; then + # run in background, dont fail + if [[ "$CIRCLECI" == true ]]; then + $TM_CMD & + else + $TM_CMD &> "tendermint_${name}.log" & + fi + PID_TENDERMINT=$! + else + # run in foreground, fail + if [[ "$CIRCLECI" == true ]]; then + FAIL_TEST_INDEX=$indexToFail $TM_CMD + else + FAIL_TEST_INDEX=$indexToFail $TM_CMD &> "tendermint_${name}.log" + fi + PID_TENDERMINT=$! + fi } function kill_procs(){ - kill -9 "$PID_DUMMY" "$PID_TENDERMINT" - wait "$PID_DUMMY" - wait "$PID_TENDERMINT" + kill -9 "$PID_DUMMY" "$PID_TENDERMINT" + wait "$PID_DUMMY" + wait "$PID_TENDERMINT" } # wait for port to be available function wait_for_port() { - port=$1 - # this will succeed while port is bound - nc -z 127.0.0.1 $port - ERR=$? - i=0 - while [ "$ERR" == 0 ]; do - echo "... port $port is still bound. waiting ..." - sleep 1 - nc -z 127.0.0.1 $port - ERR=$? - i=$((i + 1)) - if [[ $i == 10 ]]; then - echo "Timed out waiting for port to be released" - exit 1 - fi - done - echo "... port $port is free!" + port=$1 + # this will succeed while port is bound + nc -z 127.0.0.1 $port + ERR=$? + i=0 + while [ "$ERR" == 0 ]; do + echo "... port $port is still bound. waiting ..." + sleep 1 + nc -z 127.0.0.1 $port + ERR=$? + i=$((i + 1)) + if [[ $i == 10 ]]; then + echo "Timed out waiting for port to be released" + exit 1 + fi + done + echo "... port $port is free!" } @@ -77,47 +77,47 @@ fails=$(grep -r "fail.Fail" --include \*.go . | wc -l) failsEnd=$((fails-1)) for failIndex in $(seq $failsStart $failsEnd); do - echo "" - echo "* Test FailIndex $failIndex" - # test failure at failIndex - - bash ./test/utils/txs.sh "localhost:46657" & - start_procs 1 "$failIndex" - - # tendermint should already have exited when it hits the fail index - # but kill -9 for good measure - kill_procs - - start_procs 2 - - # wait for node to handshake and make a new block - # NOTE: --unix-socket is only available in curl v7.40+ - curl -s --unix-socket "$RPC_ADDR" http://localhost/status > /dev/null - ERR=$? - i=0 - while [ "$ERR" != 0 ]; do - sleep 1 - curl -s --unix-socket "$RPC_ADDR" http://localhost/status > /dev/null - ERR=$? - i=$((i + 1)) - if [[ $i == 20 ]]; then - echo "Timed out waiting for tendermint to start" - exit 1 - fi - done - - # wait for a new block - h1=$(curl -s --unix-socket "$RPC_ADDR" http://localhost/status | jq .result.latest_block_height) - h2=$h1 - while [ "$h2" == "$h1" ]; do - sleep 1 - h2=$(curl -s --unix-socket "$RPC_ADDR" http://localhost/status | jq .result.latest_block_height) - done - - kill_procs - - echo "* Passed Test for FailIndex $failIndex" - echo "" + echo "" + echo "* Test FailIndex $failIndex" + # test failure at failIndex + + bash ./test/utils/txs.sh "localhost:46657" & + start_procs 1 "$failIndex" + + # tendermint should already have exited when it hits the fail index + # but kill -9 for good measure + kill_procs + + start_procs 2 + + # wait for node to handshake and make a new block + # NOTE: --unix-socket is only available in curl v7.40+ + curl -s --unix-socket "$RPC_ADDR" http://localhost/status > /dev/null + ERR=$? + i=0 + while [ "$ERR" != 0 ]; do + sleep 1 + curl -s --unix-socket "$RPC_ADDR" http://localhost/status > /dev/null + ERR=$? + i=$((i + 1)) + if [[ $i == 20 ]]; then + echo "Timed out waiting for tendermint to start" + exit 1 + fi + done + + # wait for a new block + h1=$(curl -s --unix-socket "$RPC_ADDR" http://localhost/status | jq .result.latest_block_height) + h2=$h1 + while [ "$h2" == "$h1" ]; do + sleep 1 + h2=$(curl -s --unix-socket "$RPC_ADDR" http://localhost/status | jq .result.latest_block_height) + done + + kill_procs + + echo "* Passed Test for FailIndex $failIndex" + echo "" done echo "Passed Test: Persistence" diff --git a/test/persist/test_simple.sh b/test/persist/test_simple.sh index 273c714ca..964862c44 100644 --- a/test/persist/test_simple.sh +++ b/test/persist/test_simple.sh @@ -7,30 +7,30 @@ rm -rf $TMHOME tendermint init function start_procs(){ - name=$1 - echo "Starting persistent dummy and tendermint" - dummy --persist $TMHOME/dummy &> "dummy_${name}.log" & - PID_DUMMY=$! - tendermint node &> tendermint_${name}.log & - PID_TENDERMINT=$! - sleep 5 + name=$1 + echo "Starting persistent dummy and tendermint" + abci-cli dummy --persist $TMHOME/dummy &> "dummy_${name}.log" & + PID_DUMMY=$! + tendermint node &> tendermint_${name}.log & + PID_TENDERMINT=$! + sleep 5 } function kill_procs(){ - kill -9 $PID_DUMMY $PID_TENDERMINT + kill -9 $PID_DUMMY $PID_TENDERMINT } function send_txs(){ - # send a bunch of txs over a few blocks - echo "Sending txs" - for i in `seq 1 5`; do - for j in `seq 1 100`; do - tx=`head -c 8 /dev/urandom | hexdump -ve '1/1 "%.2X"'` - curl -s 127.0.0.1:46657/broadcast_tx_async?tx=0x$tx &> /dev/null - done - sleep 1 - done + # send a bunch of txs over a few blocks + echo "Sending txs" + for i in `seq 1 5`; do + for j in `seq 1 100`; do + tx=`head -c 8 /dev/urandom | hexdump -ve '1/1 "%.2X"'` + curl -s 127.0.0.1:46657/broadcast_tx_async?tx=0x$tx &> /dev/null + done + sleep 1 + done } @@ -46,22 +46,22 @@ curl -s $addr/status > /dev/null ERR=$? i=0 while [ "$ERR" != 0 ]; do - sleep 1 - curl -s $addr/status > /dev/null - ERR=$? - i=$(($i + 1)) - if [[ $i == 10 ]]; then - echo "Timed out waiting for tendermint to start" - exit 1 - fi + sleep 1 + curl -s $addr/status > /dev/null + ERR=$? + i=$(($i + 1)) + if [[ $i == 10 ]]; then + echo "Timed out waiting for tendermint to start" + exit 1 + fi done # wait for a new block h1=`curl -s $addr/status | jq .result.latest_block_height` h2=$h1 while [ "$h2" == "$h1" ]; do - sleep 1 - h2=`curl -s $addr/status | jq .result.latest_block_height` + sleep 1 + h2=`curl -s $addr/status | jq .result.latest_block_height` done kill_procs diff --git a/test/run_test.sh b/test/run_test.sh index b505126ea..6e4823f10 100644 --- a/test/run_test.sh +++ b/test/run_test.sh @@ -16,8 +16,8 @@ bash test/app/test.sh bash test/persist/test.sh if [[ "$BRANCH" == "master" || $(echo "$BRANCH" | grep "release-") != "" ]]; then - echo "" - echo "* branch $BRANCH; testing libs" - # checkout every github.com/tendermint dir and run its tests - bash test/test_libs.sh + echo "" + echo "* branch $BRANCH; testing libs" + # checkout every github.com/tendermint dir and run its tests + bash test/test_libs.sh fi