From a1cdc2b68a38c0fa458cc05a07cfdc463a3e7174 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Thu, 9 Nov 2017 14:57:40 -0500 Subject: [PATCH 1/3] set logger for peer's MConnection --- consensus/reactor.go | 1 - p2p/peer.go | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/consensus/reactor.go b/consensus/reactor.go index 050fdfa40..06af50557 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -390,7 +390,6 @@ func (conR *ConsensusReactor) broadcastProposalHeartbeatMessage(heartbeat types. } func (conR *ConsensusReactor) broadcastNewRoundStep(rs *cstypes.RoundState) { - nrsMsg, csMsg := makeRoundStepMessages(rs) if nrsMsg != nil { conR.Switch.Broadcast(StateChannel, struct{ ConsensusMessage }{nrsMsg}) diff --git a/p2p/peer.go b/p2p/peer.go index 2efe55d26..9ee1c0e32 100644 --- a/p2p/peer.go +++ b/p2p/peer.go @@ -11,6 +11,7 @@ import ( crypto "github.com/tendermint/go-crypto" wire "github.com/tendermint/go-wire" cmn "github.com/tendermint/tmlibs/common" + "github.com/tendermint/tmlibs/log" ) // Peer is an interface representing a peer connected on a reactor. @@ -136,6 +137,11 @@ func newPeerFromConnAndConfig(rawConn net.Conn, outbound bool, reactorsByCh map[ return p, nil } +func (p *peer) SetLogger(l log.Logger) { + p.Logger = l + p.mconn.SetLogger(l) +} + // CloseConn should be used when the peer was created, but never started. func (p *peer) CloseConn() { p.conn.Close() From 533f7c45ebf3936e7da2f49113e82ad72618f334 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Thu, 9 Nov 2017 14:58:16 -0500 Subject: [PATCH 2/3] fix bash linter warnings for atomic_broadcast integration test --- test/p2p/atomic_broadcast/test.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/test/p2p/atomic_broadcast/test.sh b/test/p2p/atomic_broadcast/test.sh index 00b339631..534b9a77b 100644 --- a/test/p2p/atomic_broadcast/test.sh +++ b/test/p2p/atomic_broadcast/test.sh @@ -13,39 +13,39 @@ N=$1 echo "" # run the test on each of them -for i in `seq 1 $N`; do - addr=$(test/p2p/ip.sh $i):46657 +for i in $(seq 1 "$N"); do + addr=$(test/p2p/ip.sh "$i"):46657 # current state - HASH1=`curl -s $addr/status | jq .result.latest_app_hash` - + HASH1=$(curl -s "$addr/status" | jq .result.latest_app_hash) + # - send a tx TX=aadeadbeefbeefbeef0$i echo "Broadcast Tx $TX" - curl -s $addr/broadcast_tx_commit?tx=0x$TX + curl -s "$addr/broadcast_tx_commit?tx=0x$TX" echo "" # we need to wait another block to get the new app_hash - h1=`curl -s $addr/status | jq .result.latest_block_height` + 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` + h2=$(curl -s "$addr/status" | jq .result.latest_block_height) done # check that hash was updated - HASH2=`curl -s $addr/status | jq .result.latest_app_hash` + HASH2=$(curl -s "$addr/status" | jq .result.latest_app_hash) if [[ "$HASH1" == "$HASH2" ]]; then echo "Expected state hash to update from $HASH1. Got $HASH2" exit 1 fi # check we get the same new hash on all other nodes - for j in `seq 1 $N`; do + for j in $(seq 1 "$N"); do if [[ "$i" != "$j" ]]; then - addrJ=$(test/p2p/ip.sh $j):46657 - HASH3=`curl -s $addrJ/status | jq .result.latest_app_hash` - + addrJ=$(test/p2p/ip.sh "$j"):46657 + HASH3=$(curl -s "$addrJ/status" | jq .result.latest_app_hash) + if [[ "$HASH2" != "$HASH3" ]]; then echo "App hash for node $j doesn't match. Got $HASH3, expected $HASH2" exit 1 From 432a7276e24afd0620d76d43110d35d0604802b9 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Thu, 9 Nov 2017 15:06:43 -0500 Subject: [PATCH 3/3] [test_integrations] enable logs from peers by default (Refs #829) --- test/p2p/peer.sh | 36 ++++++++++++------------------------ test/test.sh | 12 +++++------- 2 files changed, 17 insertions(+), 31 deletions(-) diff --git a/test/p2p/peer.sh b/test/p2p/peer.sh index 283228f76..3b8322b65 100644 --- a/test/p2p/peer.sh +++ b/test/p2p/peer.sh @@ -14,27 +14,15 @@ set +eu echo "starting tendermint peer ID=$ID" # start tendermint container on the network -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 TMHOME="/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 $NODE_FLAGS --log_level=debug --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 TMHOME="/go/src/github.com/tendermint/tendermint/test/p2p/data/mach$ID/core" \ - "$DOCKER_IMAGE" node $NODE_FLAGS --log_level=info --proxy_app="$APP_PROXY" -fi - +set -u +docker run -d \ + --net="$NETWORK_NAME" \ + --ip=$(test/p2p/ip.sh "$ID") \ + --name "local_testnet_$ID" \ + --entrypoint tendermint \ + -e TMHOME="/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 "$NODE_FLAGS" --log_level=debug --proxy_app="$APP_PROXY" diff --git a/test/test.sh b/test/test.sh index 2e164fb3e..64d7bfc71 100755 --- a/test/test.sh +++ b/test/test.sh @@ -18,14 +18,12 @@ echo "* [$(date +"%T")] removing run_test container" docker rm -vf run_test set -e -set +u -if [[ "$CIRCLECI" == true ]]; then - 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")] 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 [[ "$SKIP_BUILD" == "" ]]; then echo echo "* [$(date +"%T")] building docker image"