From d754d210cda3505ef5db23f93901b091c2692254 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Tue, 21 Feb 2017 01:28:58 -0500 Subject: [PATCH 1/3] test: only use syslog on circle --- test/p2p/peer.sh | 36 +++++++++++++++++++--------- test/persist/test_failure_indices.sh | 25 +------------------ test/test.sh | 12 ++++++---- test/utils/txs.sh | 23 ++++++++++++++++++ 4 files changed, 57 insertions(+), 39 deletions(-) create mode 100644 test/utils/txs.sh diff --git a/test/p2p/peer.sh b/test/p2p/peer.sh index 19586b124..7ee942bb5 100644 --- a/test/p2p/peer.sh +++ b/test/p2p/peer.sh @@ -13,16 +13,30 @@ if [[ "$SEEDS" != "" ]]; then SEEDS=" --seeds $SEEDS " fi +set +eu + echo "starting tendermint peer ID=$ID" # start tendermint container on the network -docker run -d \ - --net=$NETWORK_NAME \ - --ip=$(test/p2p/ip.sh $ID) \ - --name local_testnet_$ID \ - --entrypoint tendermint \ - -e TMROOT=/go/src/github.com/tendermint/tendermint/test/p2p/data/mach$ID/core \ - --log-driver=syslog \ - --log-opt syslog-address=udp://127.0.0.1:5514 \ - --log-opt syslog-facility=daemon \ - --log-opt tag="{{.Name}}" \ - $DOCKER_IMAGE node $SEEDS --proxy_app=$APP_PROXY +if [[ "$CIRCLECI" == true ]]; then + set -u + docker run -d \ + --net=$NETWORK_NAME \ + --ip=$(test/p2p/ip.sh $ID) \ + --name local_testnet_$ID \ + --entrypoint tendermint \ + -e TMROOT=/go/src/github.com/tendermint/tendermint/test/p2p/data/mach$ID/core \ + --log-driver=syslog \ + --log-opt syslog-address=udp://127.0.0.1:5514 \ + --log-opt syslog-facility=daemon \ + --log-opt tag="{{.Name}}" \ + $DOCKER_IMAGE node $SEEDS --proxy_app=$APP_PROXY +else + set -u + docker run -d \ + --net=$NETWORK_NAME \ + --ip=$(test/p2p/ip.sh $ID) \ + --name local_testnet_$ID \ + --entrypoint tendermint \ + -e TMROOT=/go/src/github.com/tendermint/tendermint/test/p2p/data/mach$ID/core \ + $DOCKER_IMAGE node $SEEDS --proxy_app=$APP_PROXY +fi diff --git a/test/persist/test_failure_indices.sh b/test/persist/test_failure_indices.sh index 8feb0005c..af29f637c 100644 --- a/test/persist/test_failure_indices.sh +++ b/test/persist/test_failure_indices.sh @@ -46,29 +46,6 @@ function kill_procs(){ } -# wait till node is up, send txs -function send_txs(){ - addr="127.0.0.1:46657" - curl -s $addr/status > /dev/null - ERR=$? - while [ "$ERR" != 0 ]; do - sleep 1 - curl -s $addr/status > /dev/null - ERR=$? - done - - # send a bunch of txs over a few blocks - echo "Node is up, sending txs" - for i in $(seq 1 5); do - for _ in $(seq 1 100); do - tx=$(head -c 8 /dev/urandom | hexdump -ve '1/1 "%.2X"') - curl -s "$addr/broadcast_tx_async?tx=0x$tx" &> /dev/null - done - sleep 1 - done -} - - failsStart=0 fails=$(grep -r "fail.Fail" --include \*.go . | wc -l) failsEnd=$((fails-1)) @@ -78,7 +55,7 @@ for failIndex in $(seq $failsStart $failsEnd); do echo "* Test FailIndex $failIndex" # test failure at failIndex - send_txs & + bash ./test/utils/txs.sh "localhost:46657" & start_procs 1 "$failIndex" # tendermint should fail when it hits the fail index diff --git a/test/test.sh b/test/test.sh index 69c4199dc..1c1faca20 100644 --- a/test/test.sh +++ b/test/test.sh @@ -12,10 +12,14 @@ echo "* [$(date +"%T")] cleaning up $LOGS_DIR" rm -rf "$LOGS_DIR" mkdir -p "$LOGS_DIR" -echo -echo "* [$(date +"%T")] starting rsyslog container" -docker rm -f rsyslog || true -docker run -d -v "$LOGS_DIR:/var/log/" -p 127.0.0.1:5514:514/udp --name rsyslog voxxit/rsyslog +set +u +if [[ "$CIRCLECI" == true ]]; then + set -u + echo + echo "* [$(date +"%T")] starting rsyslog container" + docker rm -f rsyslog || true + docker run -d -v "$LOGS_DIR:/var/log/" -p 127.0.0.1:5514:514/udp --name rsyslog voxxit/rsyslog +fi echo echo "* [$(date +"%T")] building docker image" diff --git a/test/utils/txs.sh b/test/utils/txs.sh new file mode 100644 index 000000000..c49d12c0c --- /dev/null +++ b/test/utils/txs.sh @@ -0,0 +1,23 @@ +#! /bin/bash +set -u + +# wait till node is up, send txs +ADDR=$1 #="127.0.0.1:46657" +curl -s $ADDR/status > /dev/null +ERR=$? +while [ "$ERR" != 0 ]; do + sleep 1 + curl -s $ADDR/status > /dev/null + ERR=$? +done + +# send a bunch of txs over a few blocks +echo "Node is up, sending txs" +for i in $(seq 1 5); do + for _ in $(seq 1 100); do + tx=$(head -c 8 /dev/urandom | hexdump -ve '1/1 "%.2X"') + curl -s "$ADDR/broadcast_tx_async?tx=0x$tx" &> /dev/null + done + echo "sent 100" + sleep 1 +done From 7fab31fbe3e0a3f835d5216f44c96b26f1918da5 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Tue, 21 Feb 2017 11:18:40 -0500 Subject: [PATCH 2/3] test: more logging --- test/p2p/kill_all/check_peers.sh | 1 + test/p2p/peer.sh | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/test/p2p/kill_all/check_peers.sh b/test/p2p/kill_all/check_peers.sh index 3c9250790..d085a025c 100644 --- a/test/p2p/kill_all/check_peers.sh +++ b/test/p2p/kill_all/check_peers.sh @@ -40,6 +40,7 @@ for i in $(seq 2 "$NUM_OF_PEERS"); do ((attempt++)) if [ "$attempt" -ge $MAX_ATTEMPTS_TO_CATCH_UP ] ; then echo "$attempt unsuccessful attempts were made to catch up" + curl -s "$addr/dump_consensus_state" | jq .result[1] exit 1 fi diff --git a/test/p2p/peer.sh b/test/p2p/peer.sh index 7ee942bb5..611f5ac24 100644 --- a/test/p2p/peer.sh +++ b/test/p2p/peer.sh @@ -29,7 +29,7 @@ if [[ "$CIRCLECI" == true ]]; then --log-opt syslog-address=udp://127.0.0.1:5514 \ --log-opt syslog-facility=daemon \ --log-opt tag="{{.Name}}" \ - $DOCKER_IMAGE node $SEEDS --proxy_app=$APP_PROXY + $DOCKER_IMAGE node $SEEDS --log_level=debug --proxy_app=$APP_PROXY else set -u docker run -d \ @@ -38,5 +38,5 @@ else --name local_testnet_$ID \ --entrypoint tendermint \ -e TMROOT=/go/src/github.com/tendermint/tendermint/test/p2p/data/mach$ID/core \ - $DOCKER_IMAGE node $SEEDS --proxy_app=$APP_PROXY + $DOCKER_IMAGE node $SEEDS --log_level=info --proxy_app=$APP_PROXY fi From 7c1e79cbc54fd02fe0db51f38b49ae7924a88342 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Tue, 21 Feb 2017 14:14:08 -0500 Subject: [PATCH 3/3] test/persists: wait for tendermint proc --- test/persist/test_failure_indices.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/persist/test_failure_indices.sh b/test/persist/test_failure_indices.sh index af29f637c..81721e65e 100644 --- a/test/persist/test_failure_indices.sh +++ b/test/persist/test_failure_indices.sh @@ -61,6 +61,7 @@ for failIndex in $(seq $failsStart $failsEnd); do # tendermint should fail when it hits the fail index kill -9 "$PID_DUMMY" wait "$PID_DUMMY" + wait "$PID_TENDERMINT" start_procs 2