diff --git a/test/p2p/client.sh b/test/p2p/client.sh index efc5096ef..b1ac64e7c 100644 --- a/test/p2p/client.sh +++ b/test/p2p/client.sh @@ -8,7 +8,7 @@ CMD=$4 echo "starting test client container with CMD=$CMD" # run the test container on the local network -docker run -t \ +docker run -t --rm \ -v $GOPATH/src/github.com/tendermint/tendermint/test/p2p/:/go/src/github.com/tendermint/tendermint/test/p2p \ --net=$NETWORK_NAME \ --ip=$(test/p2p/ip.sh "-1") \ diff --git a/test/p2p/local_testnet.sh b/test/p2p/local_testnet_start.sh similarity index 100% rename from test/p2p/local_testnet.sh rename to test/p2p/local_testnet_start.sh diff --git a/test/p2p/local_testnet_stop.sh b/test/p2p/local_testnet_stop.sh new file mode 100644 index 000000000..6fe23ab2f --- /dev/null +++ b/test/p2p/local_testnet_stop.sh @@ -0,0 +1,12 @@ +#! /bin/bash +set -u + +NETWORK_NAME=$1 +N=$2 + +for i in `seq 1 $N`; do + docker stop local_testnet_$i + docker rm local_testnet_$i +done + +docker network rm $NETWORK_NAME diff --git a/test/p2p/test.sh b/test/p2p/test.sh index 7a64d464a..58beb9a4a 100644 --- a/test/p2p/test.sh +++ b/test/p2p/test.sh @@ -7,8 +7,13 @@ N=4 cd $GOPATH/src/github.com/tendermint/tendermint +# stop the existing testnet and remove local network +set +e +bash test/p2p/local_testnet_stop.sh $NETWORK_NAME $N +set -e + # start the testnet on a local network -bash test/p2p/local_testnet.sh $DOCKER_IMAGE $NETWORK_NAME $N +bash test/p2p/local_testnet_start.sh $DOCKER_IMAGE $NETWORK_NAME $N # test basic connectivity and consensus # start client container and check the num peers and height for all nodes