From 57f35924118dd47807dac399c55e005533bcf479 Mon Sep 17 00:00:00 2001 From: Anton Kalyaev Date: Tue, 20 Dec 2016 21:16:39 +0400 Subject: [PATCH] fix 2 errors when running p2p tests more than once Error #1: ``` Error response from daemon: network with name local_testnet already exists ``` Fixed by stopping and removing local_testnet containers and removing the network Error #2: ``` docker: Error response from daemon: Conflict. The name "/test_container_basic" is already in use by container a7cd15d479a964675e7f259de4ed852e7dfef85b447514728f437cd0b980a709. You have to remove (or rename) that container to beable to reuse that name.. ``` Fixed by adding `--rm` flag. --- test/p2p/client.sh | 2 +- .../p2p/{local_testnet.sh => local_testnet_start.sh} | 0 test/p2p/local_testnet_stop.sh | 12 ++++++++++++ test/p2p/test.sh | 7 ++++++- 4 files changed, 19 insertions(+), 2 deletions(-) rename test/p2p/{local_testnet.sh => local_testnet_start.sh} (100%) create mode 100644 test/p2p/local_testnet_stop.sh 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