From caaafa192bfe41f7c45929d626b53e5599d2c720 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Mon, 6 Mar 2017 02:42:00 -0500 Subject: [PATCH] test/persist: use unix socket for rpc --- test/docker/Dockerfile | 5 ++++- test/persist/test_failure_indices.sh | 25 +++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/test/docker/Dockerfile b/test/docker/Dockerfile index 829f5e456..7c322976d 100644 --- a/test/docker/Dockerfile +++ b/test/docker/Dockerfile @@ -1,10 +1,13 @@ # Pull base image. FROM golang:1.7.4 +# Add testing deps for curl +RUN echo 'deb http://httpredir.debian.org/debian testing main non-free contrib' >> /etc/apt/sources.list + # Grab deps (jq, hexdump, xxd, killall) RUN apt-get update && \ apt-get install -y --no-install-recommends \ - jq bsdmainutils vim-common psmisc netcat + jq bsdmainutils vim-common psmisc netcat curl # Setup tendermint repo ENV REPO $GOPATH/src/github.com/tendermint/tendermint diff --git a/test/persist/test_failure_indices.sh b/test/persist/test_failure_indices.sh index cb78297e2..f47ab3729 100644 --- a/test/persist/test_failure_indices.sh +++ b/test/persist/test_failure_indices.sh @@ -1,12 +1,14 @@ #! /bin/bash - export TMROOT=$HOME/.tendermint_persist rm -rf "$TMROOT" tendermint init -TM_CMD="tendermint node --log_level=debug" # &> tendermint_${name}.log" +# use a unix socket so we can remove it +RPC_ADDR="$(pwd)/rpc.sock" + +TM_CMD="tendermint node --log_level=debug --rpc_laddr=unix://$RPC_ADDR" # &> tendermint_${name}.log" DUMMY_CMD="dummy --persist $TMROOT/dummy" # &> dummy_${name}.log" @@ -20,6 +22,9 @@ function start_procs(){ $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 @@ -43,13 +48,6 @@ function kill_procs(){ kill -9 "$PID_DUMMY" "$PID_TENDERMINT" wait "$PID_DUMMY" wait "$PID_TENDERMINT" - - # wait for the ports to be released - wait_for_port 46656 - wait_for_port 46657 - - # XXX: sometimes the port is still bound :( - sleep 5 } # wait for port to be available @@ -93,13 +91,12 @@ for failIndex in $(seq $failsStart $failsEnd); do start_procs 2 # wait for node to handshake and make a new block - addr="localhost:46657" - curl -s "$addr/status" > /dev/null + curl -s --unix-socket "$RPC_ADDR" http://localhost/status > /dev/null ERR=$? i=0 while [ "$ERR" != 0 ]; do sleep 1 - curl -s "$addr/status" > /dev/null + curl -s --unix-socket "$RPC_ADDR" http://localhost/status > /dev/null ERR=$? i=$((i + 1)) if [[ $i == 20 ]]; then @@ -109,11 +106,11 @@ for failIndex in $(seq $failsStart $failsEnd); do done # wait for a new block - h1=$(curl -s $addr/status | jq .result[1].latest_block_height) + h1=$(curl -s --unix-socket "$RPC_ADDR" http://localhost/status | jq .result[1].latest_block_height) h2=$h1 while [ "$h2" == "$h1" ]; do sleep 1 - h2=$(curl -s $addr/status | jq .result[1].latest_block_height) + h2=$(curl -s --unix-socket "$RPC_ADDR" http://localhost/status | jq .result[1].latest_block_height) done kill_procs