diff --git a/test/app/counter_test.sh b/test/app/counter_test.sh index a4f7c83b9..3af2b885f 100755 --- a/test/app/counter_test.sh +++ b/test/app/counter_test.sh @@ -36,11 +36,11 @@ function getCode() { # build grpc client if needed if [[ "$GRPC_BROADCAST_TX" != "" ]]; then - if [ -f grpc_client ]; then - rm grpc_client + if [ -f test/app/grpc_client ]; then + rm test/app/grpc_client fi echo "... building grpc_client" - go build -mod=readonly -o grpc_client grpc_client.go + go build -mod=readonly -o test/app/grpc_client test/app/grpc_client.go fi function sendTx() { @@ -59,7 +59,7 @@ function sendTx() { RESPONSE=$(echo "$RESPONSE" | jq '.result') else - RESPONSE=$(./grpc_client "$TX") + RESPONSE=$(./test/app/grpc_client "$TX") IS_ERR=false ERROR="" fi diff --git a/test/app/test.sh b/test/app/test.sh index 0f77da04e..dc60bfc1f 100755 --- a/test/app/test.sh +++ b/test/app/test.sh @@ -22,7 +22,7 @@ function kvstore_over_socket(){ sleep 5 echo "running test" - bash kvstore_test.sh "KVStore over Socket" + bash test/app/kvstore_test.sh "KVStore over Socket" kill -9 $pid_kvstore $pid_tendermint } @@ -40,7 +40,7 @@ function kvstore_over_socket_reorder(){ sleep 5 echo "running test" - bash kvstore_test.sh "KVStore over Socket" + bash test/app/kvstore_test.sh "KVStore over Socket" kill -9 $pid_kvstore $pid_tendermint } @@ -57,7 +57,7 @@ function counter_over_socket() { sleep 5 echo "running test" - bash counter_test.sh "Counter over Socket" + bash test/app/counter_test.sh "Counter over Socket" kill -9 $pid_counter $pid_tendermint } @@ -73,7 +73,7 @@ function counter_over_grpc() { sleep 5 echo "running test" - bash counter_test.sh "Counter over GRPC" + bash test/app/counter_test.sh "Counter over GRPC" kill -9 $pid_counter $pid_tendermint } @@ -91,13 +91,11 @@ function counter_over_grpc_grpc() { sleep 5 echo "running test" - GRPC_BROADCAST_TX=true bash counter_test.sh "Counter over GRPC via GRPC BroadcastTx" + GRPC_BROADCAST_TX=true bash test/app/counter_test.sh "Counter over GRPC via GRPC BroadcastTx" kill -9 $pid_counter $pid_tendermint } -cd $GOPATH/src/github.com/tendermint/tendermint/test/app - case "$1" in "kvstore_over_socket") kvstore_over_socket diff --git a/test/p2p/README.md b/test/p2p/README.md index 956ce906c..1ebf4c17f 100644 --- a/test/p2p/README.md +++ b/test/p2p/README.md @@ -4,7 +4,7 @@ These scripts facilitate setting up and testing a local testnet using docker con Setup your own local testnet as follows. -For consistency, we assume all commands are run from the Tendermint repository root (ie. $GOPATH/src/github.com/tendermint/tendermint). +For consistency, we assume all commands are run from the Tendermint repository root. First, build the docker image: @@ -49,3 +49,18 @@ We can confirm they are making blocks by checking the `/status` message using `c ``` curl 172.57.0.101:26657/status | jq . ``` + +## IPv6 tests + +IPv6 tests require a Docker daemon with IPv6 enabled, by setting the following in `daemon.json`: + +```json +{ + "ipv6": true, + "fixed-cidr-v6": "2001:db8:1::/64" +} +``` + +In Docker for Mac, this is done via Preferences → Docker Engine. + +Once set, run IPv6 tests via `make test_p2p_ipv6`. \ No newline at end of file diff --git a/test/p2p/address.sh b/test/p2p/address.sh new file mode 100755 index 000000000..0b0248db2 --- /dev/null +++ b/test/p2p/address.sh @@ -0,0 +1,28 @@ +#! /bin/bash +set -eu + +IPV=$1 +ID=$2 +PORT=${3:-} +DOCKER_IMAGE=${4:-} + +if [[ "$IPV" == 6 ]]; then + ADDRESS="fd80:b10c::" +else + ADDRESS="172.57.0." +fi +ADDRESS="$ADDRESS$((100+$ID))" + +if [[ -n "$PORT" ]]; then + if [[ "$IPV" == 6 ]]; then + ADDRESS="[$ADDRESS]" + fi + ADDRESS="$ADDRESS:$PORT" +fi + +if [[ -n "$DOCKER_IMAGE" ]]; then + NODEID="$(docker run --rm -e TMHOME=/go/src/github.com/tendermint/tendermint/test/p2p/data/mach$((ID-1)) $DOCKER_IMAGE tendermint show_node_id)" + ADDRESS="$NODEID@$ADDRESS" +fi + +echo $ADDRESS \ No newline at end of file diff --git a/test/p2p/atomic_broadcast/test.sh b/test/p2p/atomic_broadcast/test.sh index f066707d3..a93067c3d 100644 --- a/test/p2p/atomic_broadcast/test.sh +++ b/test/p2p/atomic_broadcast/test.sh @@ -1,7 +1,8 @@ #! /bin/bash set -u -N=$1 +IPV=$1 +N=$2 ################################################################### # assumes peers are already synced up @@ -14,7 +15,7 @@ N=$1 echo "" # run the test on each of them for i in $(seq 1 "$N"); do - addr=$(test/p2p/ip.sh "$i"):26657 + addr=$(test/p2p/address.sh $IPV $i 26657) # current state HASH1=$(curl -s "$addr/status" | jq .result.sync_info.latest_app_hash) @@ -37,7 +38,7 @@ for i in $(seq 1 "$N"); do minHeight=$h2 for j in $(seq 1 "$N"); do if [[ "$i" != "$j" ]]; then - addrJ=$(test/p2p/ip.sh "$j"):26657 + addrJ=$(test/p2p/address.sh $IPV $j 26657) h=$(curl -s "$addrJ/status" | jq .result.sync_info.latest_block_height | jq fromjson) while [ "$h" -lt "$minHeight" ]; do @@ -57,7 +58,7 @@ for i in $(seq 1 "$N"); do # check we get the same new hash on all other nodes for j in $(seq 1 "$N"); do if [[ "$i" != "$j" ]]; then - addrJ=$(test/p2p/ip.sh "$j"):26657 + addrJ=$(test/p2p/address.sh $IPV $j 26657) HASH3=$(curl -s "$addrJ/status" | jq .result.sync_info.latest_app_hash) if [[ "$HASH2" != "$HASH3" ]]; then diff --git a/test/p2p/basic/test.sh b/test/p2p/basic/test.sh index 423b5b017..676b5cbe6 100755 --- a/test/p2p/basic/test.sh +++ b/test/p2p/basic/test.sh @@ -1,7 +1,8 @@ #! /bin/bash set -u -N=$1 +IPV=$1 +N=$2 ################################################################### # wait for all peers to come online @@ -16,7 +17,7 @@ MAX_SLEEP=60 # wait for everyone to come online echo "Waiting for nodes to come online" for i in `seq 1 $N`; do - addr=$(test/p2p/ip.sh $i):26657 + addr=$(test/p2p/address.sh $IPV $i 26657) curl -s $addr/status > /dev/null ERR=$? COUNT=0 @@ -36,7 +37,7 @@ done echo "" # wait for each of them to sync up for i in `seq 1 $N`; do - addr=$(test/p2p/ip.sh $i):26657 + addr=$(test/p2p/address.sh $IPV $i 26657) N_1=$(($N - 1)) # - assert everyone has N-1 other peers diff --git a/test/p2p/circleci.sh b/test/p2p/circleci.sh index c548d5752..92869ff45 100644 --- a/test/p2p/circleci.sh +++ b/test/p2p/circleci.sh @@ -6,6 +6,17 @@ SOURCE="${BASH_SOURCE[0]}" while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +# Enable IPv6 support in Docker daemon +echo +echo "* [$(date +"%T")] enabling IPv6 stack in Docker daemon" +cat <<'EOF' | sudo tee /etc/docker/daemon.json +{ + "ipv6": true, + "fixed-cidr-v6": "2001:db8:1::/64" +} +EOF +sudo service docker restart + LOGS_DIR="$DIR/logs" echo echo "* [$(date +"%T")] cleaning up $LOGS_DIR" @@ -34,6 +45,10 @@ echo echo "* [$(date +"%T")] running p2p tests on a local docker network" bash "$DIR/../p2p/test.sh" tester +echo +echo "* [$(date +"%T")] running IPv6 p2p tests on a local docker network" +bash "$DIR/../p2p/test.sh" tester 6 + echo echo "* [$(date +"%T")] copying log files out of docker container into $LOGS_DIR" docker cp rsyslog:/var/log $LOGS_DIR diff --git a/test/p2p/client.sh b/test/p2p/client.sh index fa11ce870..b3c907fba 100644 --- a/test/p2p/client.sh +++ b/test/p2p/client.sh @@ -3,17 +3,24 @@ set -eu DOCKER_IMAGE=$1 NETWORK_NAME=$2 -ID=$3 -CMD=$4 +IPV=$3 +ID=$4 +CMD=$5 NAME=test_container_$ID +if [[ "$IPV" == 6 ]]; then + IP_SWITCH="--ip6" +else + IP_SWITCH="--ip" +fi + echo "starting test client container with CMD=$CMD" # run the test container on the local network docker run -t --rm \ - -v "$GOPATH/src/github.com/tendermint/tendermint/test/p2p/:/go/src/github.com/tendermint/tendermint/test/p2p" \ + -v "$PWD/test/p2p/:/go/src/github.com/tendermint/tendermint/test/p2p" \ --net="$NETWORK_NAME" \ - --ip=$(test/p2p/ip.sh "-1") \ + $IP_SWITCH=$(test/p2p/address.sh $IPV -1) \ --name "$NAME" \ --entrypoint bash \ "$DOCKER_IMAGE" $CMD diff --git a/test/p2p/fast_sync/check_peer.sh b/test/p2p/fast_sync/check_peer.sh index d5d3fc2b5..798b508fa 100644 --- a/test/p2p/fast_sync/check_peer.sh +++ b/test/p2p/fast_sync/check_peer.sh @@ -2,7 +2,8 @@ set -eu set -o pipefail -ID=$1 +IPV=$1 +ID=$2 ########################################### # @@ -10,9 +11,9 @@ ID=$1 # ########################################### -addr=$(test/p2p/ip.sh $ID):26657 +addr=$(test/p2p/address.sh $IPV $ID 26657) peerID=$(( $(($ID % 4)) + 1 )) # 1->2 ... 3->4 ... 4->1 -peer_addr=$(test/p2p/ip.sh $peerID):26657 +peer_addr=$(test/p2p/address.sh $IPV $peerID 26657) # get another peer's height h1=`curl -s $peer_addr/status | jq .result.sync_info.latest_block_height | jq fromjson` diff --git a/test/p2p/fast_sync/test.sh b/test/p2p/fast_sync/test.sh index 8820d199c..79655232f 100644 --- a/test/p2p/fast_sync/test.sh +++ b/test/p2p/fast_sync/test.sh @@ -3,14 +3,13 @@ set -eu DOCKER_IMAGE=$1 NETWORK_NAME=$2 -N=$3 -PROXY_APP=$4 - -cd $GOPATH/src/github.com/tendermint/tendermint +IPV=$3 +N=$4 +PROXY_APP=$5 # run it on each of them for i in `seq 1 $N`; do - bash test/p2p/fast_sync/test_peer.sh $DOCKER_IMAGE $NETWORK_NAME $i $N $PROXY_APP + bash test/p2p/fast_sync/test_peer.sh $DOCKER_IMAGE $NETWORK_NAME $IPV $i $N $PROXY_APP done diff --git a/test/p2p/fast_sync/test_peer.sh b/test/p2p/fast_sync/test_peer.sh index 08ea9deb1..b4c34336f 100644 --- a/test/p2p/fast_sync/test_peer.sh +++ b/test/p2p/fast_sync/test_peer.sh @@ -3,9 +3,10 @@ set -eu DOCKER_IMAGE=$1 NETWORK_NAME=$2 -ID=$3 -N=$4 -PROXY_APP=$5 +IPV=$3 +ID=$4 +N=$5 +PROXY_APP=$6 ############################################################### # this runs on each peer: @@ -23,14 +24,14 @@ set +e # circle sigh :( set -e # restart peer - should have an empty blockchain - PERSISTENT_PEERS="$(test/p2p/ip_plus_id.sh 1 $DOCKER_IMAGE):26656" + PERSISTENT_PEERS="$(test/p2p/address.sh $IPV 1 26656 $DOCKER_IMAGE)" for j in `seq 2 $N`; do - PERSISTENT_PEERS="$PERSISTENT_PEERS,$(test/p2p/ip_plus_id.sh $j $DOCKER_IMAGE):26656" + PERSISTENT_PEERS="$PERSISTENT_PEERS,$(test/p2p/address.sh $IPV $j 26656 $DOCKER_IMAGE)" done - bash test/p2p/peer.sh $DOCKER_IMAGE $NETWORK_NAME $ID $PROXY_APP "--p2p.persistent_peers $PERSISTENT_PEERS --p2p.pex --rpc.unsafe" + bash test/p2p/peer.sh $DOCKER_IMAGE $NETWORK_NAME $IPV $ID $PROXY_APP "--p2p.persistent_peers $PERSISTENT_PEERS --p2p.pex --rpc.unsafe" # wait for peer to sync and check the app hash - bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME fs_$ID "test/p2p/fast_sync/check_peer.sh $ID" + bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME $IPV fs_$ID "test/p2p/fast_sync/check_peer.sh $IPV $ID" echo "" echo "PASS" diff --git a/test/p2p/ip.sh b/test/p2p/ip.sh deleted file mode 100755 index 77753f541..000000000 --- a/test/p2p/ip.sh +++ /dev/null @@ -1,5 +0,0 @@ -#! /bin/bash -set -eu - -ID=$1 -echo "172.57.0.$((100+$ID))" diff --git a/test/p2p/ip_plus_id.sh b/test/p2p/ip_plus_id.sh deleted file mode 100755 index 95871d3f1..000000000 --- a/test/p2p/ip_plus_id.sh +++ /dev/null @@ -1,7 +0,0 @@ -#! /bin/bash -set -eu - -ID=$1 -DOCKER_IMAGE=$2 -NODEID="$(docker run --rm -e TMHOME=/go/src/github.com/tendermint/tendermint/test/p2p/data/mach$((ID-1)) $DOCKER_IMAGE tendermint show_node_id)" -echo "$NODEID@172.57.0.$((100+$ID))" diff --git a/test/p2p/kill_all/check_peers.sh b/test/p2p/kill_all/check_peers.sh index 95da7484e..504cdeddd 100644 --- a/test/p2p/kill_all/check_peers.sh +++ b/test/p2p/kill_all/check_peers.sh @@ -1,7 +1,8 @@ #! /bin/bash set -eu -NUM_OF_PEERS=$1 +IPV=$1 +NUM_OF_PEERS=$2 # how many attempts for each peer to catch up by height MAX_ATTEMPTS_TO_CATCH_UP=120 @@ -9,7 +10,7 @@ MAX_ATTEMPTS_TO_CATCH_UP=120 echo "Waiting for nodes to come online" set +e for i in $(seq 1 "$NUM_OF_PEERS"); do - addr=$(test/p2p/ip.sh "$i"):26657 + addr=$(test/p2p/address.sh $IPV $i 26657) curl -s "$addr/status" > /dev/null ERR=$? while [ "$ERR" != 0 ]; do @@ -22,7 +23,7 @@ done set -e # get the first peer's height -addr=$(test/p2p/ip.sh 1):26657 +addr=$(test/p2p/address.sh $IPV 1 26657) h1=$(curl -s "$addr/status" | jq .result.sync_info.latest_block_height | sed -e "s/^\"\(.*\)\"$/\1/g") echo "1st peer is on height $h1" @@ -32,7 +33,7 @@ for i in $(seq 2 "$NUM_OF_PEERS"); do hi=0 while [[ $hi -le $h1 ]] ; do - addr=$(test/p2p/ip.sh "$i"):26657 + addr=$(test/p2p/address.sh $IPV $i 26657) hi=$(curl -s "$addr/status" | jq .result.sync_info.latest_block_height | sed -e "s/^\"\(.*\)\"$/\1/g") echo "... peer $i is on height $hi" diff --git a/test/p2p/kill_all/test.sh b/test/p2p/kill_all/test.sh index 318a1fe47..755612130 100644 --- a/test/p2p/kill_all/test.sh +++ b/test/p2p/kill_all/test.sh @@ -3,10 +3,9 @@ set -eu DOCKER_IMAGE=$1 NETWORK_NAME=$2 -NUM_OF_PEERS=$3 -NUM_OF_CRASHES=$4 - -cd "$GOPATH/src/github.com/tendermint/tendermint" +IPV=$3 +NUM_OF_PEERS=$4 +NUM_OF_CRASHES=$5 ############################################################### # NUM_OF_CRASHES times: @@ -24,7 +23,7 @@ for i in $(seq 1 "$NUM_OF_CRASHES"); do docker start "local_testnet_$j" done - bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" kill_all_$i "test/p2p/kill_all/check_peers.sh $NUM_OF_PEERS" + bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" kill_all_$i "test/p2p/kill_all/check_peers.sh $IPV $NUM_OF_PEERS" done echo "" diff --git a/test/p2p/local_testnet_start.sh b/test/p2p/local_testnet_start.sh index 25b3c6d3e..8da6be4bb 100644 --- a/test/p2p/local_testnet_start.sh +++ b/test/p2p/local_testnet_start.sh @@ -3,22 +3,25 @@ set -eu DOCKER_IMAGE=$1 NETWORK_NAME=$2 -N=$3 -APP_PROXY=$4 +IPV=$3 +N=$4 +APP_PROXY=$5 set +u -PERSISTENT_PEERS=$5 +PERSISTENT_PEERS=$6 if [[ "$PERSISTENT_PEERS" != "" ]]; then echo "PersistentPeers: $PERSISTENT_PEERS" PERSISTENT_PEERS="--p2p.persistent_peers $PERSISTENT_PEERS" fi set -u -cd "$GOPATH/src/github.com/tendermint/tendermint" - # create docker network -docker network create --driver bridge --subnet 172.57.0.0/16 "$NETWORK_NAME" +if [[ $IPV == 6 ]]; then + docker network create --driver bridge --ipv6 --subnet fd80:b10c::/48 "$NETWORK_NAME" +else + docker network create --driver bridge --subnet 172.57.0.0/16 "$NETWORK_NAME" +fi for i in $(seq 1 "$N"); do - bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$i" "$APP_PROXY" "$PERSISTENT_PEERS --p2p.pex --rpc.unsafe" + bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" $IPV "$i" "$APP_PROXY" "$PERSISTENT_PEERS --p2p.pex --rpc.unsafe" done diff --git a/test/p2p/peer.sh b/test/p2p/peer.sh index 63d46f8d5..bf146ca1b 100644 --- a/test/p2p/peer.sh +++ b/test/p2p/peer.sh @@ -3,13 +3,20 @@ set -eu DOCKER_IMAGE=$1 NETWORK_NAME=$2 -ID=$3 -APP_PROXY=$4 +IPV=$3 +ID=$4 +APP_PROXY=$5 set +u -NODE_FLAGS=$5 +NODE_FLAGS=$6 set -u +if [[ "$IPV" == 6 ]]; then + IP_SWITCH="--ip6" +else + IP_SWITCH="--ip" +fi + echo "starting tendermint peer ID=$ID" # start tendermint container on the network # NOTE: $NODE_FLAGS should be unescaped (no quotes). otherwise it will be @@ -20,7 +27,7 @@ echo "starting tendermint peer ID=$ID" if [[ "$ID" == "x" ]]; then # Set "x" to "1" to print to console. docker run \ --net="$NETWORK_NAME" \ - --ip=$(test/p2p/ip.sh "$ID") \ + $IP_SWITCH=$(test/p2p/address.sh $IPV $ID) \ --name "local_testnet_$ID" \ --entrypoint tendermint \ -e TMHOME="/go/src/github.com/tendermint/tendermint/test/p2p/data/mach$((ID-1))" \ @@ -33,7 +40,7 @@ if [[ "$ID" == "x" ]]; then # Set "x" to "1" to print to console. else docker run -d \ --net="$NETWORK_NAME" \ - --ip=$(test/p2p/ip.sh "$ID") \ + $IP_SWITCH=$(test/p2p/address.sh $IPV $ID) \ --name "local_testnet_$ID" \ --entrypoint tendermint \ -e TMHOME="/go/src/github.com/tendermint/tendermint/test/p2p/data/mach$((ID-1))" \ diff --git a/test/p2p/persistent_peers.sh b/test/p2p/persistent_peers.sh index 6d3e1ed66..a1e76991a 100644 --- a/test/p2p/persistent_peers.sh +++ b/test/p2p/persistent_peers.sh @@ -1,13 +1,12 @@ #! /bin/bash set -eu -N=$1 -DOCKER_IMAGE=$2 +IPV=$1 +N=$2 +DOCKER_IMAGE=$3 -cd "$GOPATH/src/github.com/tendermint/tendermint" - -persistent_peers="$(test/p2p/ip_plus_id.sh 1 $DOCKER_IMAGE):26656" +persistent_peers="$(test/p2p/address.sh $IPV 1 26656 $DOCKER_IMAGE)" for i in $(seq 2 $N); do - persistent_peers="$persistent_peers,$(test/p2p/ip_plus_id.sh $i $DOCKER_IMAGE):26656" + persistent_peers="$persistent_peers,$(test/p2p/address.sh $IPV $i 26656 $DOCKER_IMAGE)" done echo "$persistent_peers" diff --git a/test/p2p/pex/check_peer.sh b/test/p2p/pex/check_peer.sh index 7ae42e9b6..93499d9f9 100644 --- a/test/p2p/pex/check_peer.sh +++ b/test/p2p/pex/check_peer.sh @@ -1,10 +1,11 @@ #! /bin/bash set -u -ID=$1 -N=$2 +IPV=$1 +ID=$2 +N=$3 -addr=$(test/p2p/ip.sh "$ID"):26657 +addr=$(test/p2p/address.sh $IPV "$ID" 26657) echo "2. wait until peer $ID connects to other nodes using pex reactor" peers_count="0" diff --git a/test/p2p/pex/dial_peers.sh b/test/p2p/pex/dial_peers.sh index 43bde48b5..8c4d40f44 100644 --- a/test/p2p/pex/dial_peers.sh +++ b/test/p2p/pex/dial_peers.sh @@ -1,14 +1,13 @@ #! /bin/bash set -u -N=$1 -PEERS=$2 - -cd "$GOPATH/src/github.com/tendermint/tendermint" +IPV=$1 +N=$2 +PEERS=$3 echo "Waiting for nodes to come online" for i in $(seq 1 "$N"); do - addr=$(test/p2p/ip.sh "$i"):26657 + addr=$(test/p2p/address.sh $IPV $i 26657) curl -s "$addr/status" > /dev/null ERR=$? while [ "$ERR" != 0 ]; do @@ -19,5 +18,5 @@ for i in $(seq 1 "$N"); do echo "... node $i is up" done -IP=$(test/p2p/ip.sh 1) -curl "$IP:26657/dial_peers?persistent=true&peers=\\[$PEERS\\]" +ADDR=$(test/p2p/address.sh $IPV 1 26657) +curl "$ADDR/dial_peers?persistent=true&peers=\\[$PEERS\\]" diff --git a/test/p2p/pex/test.sh b/test/p2p/pex/test.sh index ffecd6510..1e87a9fa5 100644 --- a/test/p2p/pex/test.sh +++ b/test/p2p/pex/test.sh @@ -3,13 +3,12 @@ set -eu DOCKER_IMAGE=$1 NETWORK_NAME=$2 -N=$3 -PROXY_APP=$4 - -cd "$GOPATH/src/github.com/tendermint/tendermint" +IPV=$3 +N=$4 +PROXY_APP=$5 echo "Test reconnecting from the address book" -bash test/p2p/pex/test_addrbook.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$N" "$PROXY_APP" +bash test/p2p/pex/test_addrbook.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" "$N" "$PROXY_APP" echo "Test connecting via /dial_peers" -bash test/p2p/pex/test_dial_peers.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$N" "$PROXY_APP" +bash test/p2p/pex/test_dial_peers.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" "$N" "$PROXY_APP" diff --git a/test/p2p/pex/test_addrbook.sh b/test/p2p/pex/test_addrbook.sh index 06f9212fd..06fc4215f 100644 --- a/test/p2p/pex/test_addrbook.sh +++ b/test/p2p/pex/test_addrbook.sh @@ -3,8 +3,9 @@ set -eu DOCKER_IMAGE=$1 NETWORK_NAME=$2 -N=$3 -PROXY_APP=$4 +IPV=$3 +N=$4 +PROXY_APP=$5 ID=1 @@ -24,11 +25,11 @@ docker rm -vf "local_testnet_$ID" set -e # NOTE that we do not provide persistent_peers -bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$ID" "$PROXY_APP" "--p2p.pex --rpc.unsafe" +bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" $IPV "$ID" "$PROXY_APP" "--p2p.pex --rpc.unsafe" echo "started local_testnet_$ID" # if the client runs forever, it means addrbook wasn't saved or was empty -bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$CLIENT_NAME" "test/p2p/pex/check_peer.sh $ID $N" +bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" "$CLIENT_NAME" "test/p2p/pex/check_peer.sh $IPV $ID $N" # Now we know that the node is up. @@ -53,11 +54,11 @@ docker rm -vf "local_testnet_$ID" set -e # NOTE that we do not provide persistent_peers -bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$ID" "$PROXY_APP" "--p2p.pex --rpc.unsafe" +bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" $IPV "$ID" "$PROXY_APP" "--p2p.pex --rpc.unsafe" echo "started local_testnet_$ID" # if the client runs forever, it means other peers have removed us from their books (which should not happen) -bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$CLIENT_NAME" "test/p2p/pex/check_peer.sh $ID $N" +bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" "$CLIENT_NAME" "test/p2p/pex/check_peer.sh $IPV $ID $N" # Now we know that the node is up. diff --git a/test/p2p/pex/test_dial_peers.sh b/test/p2p/pex/test_dial_peers.sh index cb6e7e182..af76a5699 100644 --- a/test/p2p/pex/test_dial_peers.sh +++ b/test/p2p/pex/test_dial_peers.sh @@ -3,13 +3,12 @@ set -eu DOCKER_IMAGE=$1 NETWORK_NAME=$2 -N=$3 -PROXY_APP=$4 +IPV=$3 +N=$4 +PROXY_APP=$5 ID=1 -cd $GOPATH/src/github.com/tendermint/tendermint - echo "----------------------------------------------------------------------" echo "Testing full network connection using one /dial_peers call" echo "(assuming peers are started with pex enabled)" @@ -21,19 +20,19 @@ set -e # start the testnet on a local network # NOTE we re-use the same network for all tests -bash test/p2p/local_testnet_start.sh $DOCKER_IMAGE $NETWORK_NAME $N $PROXY_APP "" +bash test/p2p/local_testnet_start.sh $DOCKER_IMAGE $NETWORK_NAME $IPV $N $PROXY_APP "" -PERSISTENT_PEERS="\"$(test/p2p/ip_plus_id.sh 1 $DOCKER_IMAGE):26656\"" +PERSISTENT_PEERS="\"$(test/p2p/address.sh $IPV 1 26656 $DOCKER_IMAGE)\"" for i in $(seq 2 $N); do - PERSISTENT_PEERS="$PERSISTENT_PEERS,\"$(test/p2p/ip_plus_id.sh $i $DOCKER_IMAGE):26656\"" + PERSISTENT_PEERS="$PERSISTENT_PEERS,\"$(test/p2p/address.sh $IPV $i 26656 $DOCKER_IMAGE)\"" done echo "$PERSISTENT_PEERS" # dial peers from one node CLIENT_NAME="dial_peers" -bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME $CLIENT_NAME "test/p2p/pex/dial_peers.sh $N $PERSISTENT_PEERS" +bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME $IPV $CLIENT_NAME "test/p2p/pex/dial_peers.sh $IPV $N $PERSISTENT_PEERS" # test basic connectivity and consensus # start client container and check the num peers and height for all nodes CLIENT_NAME="dial_peers_basic" -bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME $CLIENT_NAME "test/p2p/basic/test.sh $N" +bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME $IPV $CLIENT_NAME "test/p2p/basic/test.sh $IPV $N" diff --git a/test/p2p/test.sh b/test/p2p/test.sh index abcf2ca07..fe28f02a9 100644 --- a/test/p2p/test.sh +++ b/test/p2p/test.sh @@ -5,34 +5,38 @@ DOCKER_IMAGE=$1 NETWORK_NAME=local_testnet N=4 PROXY_APP=persistent_kvstore +IPV=${2:-4} # Default to IPv4 -cd "$GOPATH/src/github.com/tendermint/tendermint" +if [[ "$IPV" != "4" && "$IPV" != "6" ]]; then + echo "IP version must be 4 or 6" >&2 + exit 1 +fi # stop the existing testnet and remove local network set +e bash test/p2p/local_testnet_stop.sh "$NETWORK_NAME" "$N" set -e -PERSISTENT_PEERS=$(bash test/p2p/persistent_peers.sh $N $DOCKER_IMAGE) +PERSISTENT_PEERS=$(bash test/p2p/persistent_peers.sh $IPV $N $DOCKER_IMAGE) # start the testnet on a local network # NOTE we re-use the same network for all tests -bash test/p2p/local_testnet_start.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$N" "$PROXY_APP" "$PERSISTENT_PEERS" +bash test/p2p/local_testnet_start.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" "$N" "$PROXY_APP" "$PERSISTENT_PEERS" # test basic connectivity and consensus # start client container and check the num peers and height for all nodes -bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" basic "test/p2p/basic/test.sh $N" +bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" basic "test/p2p/basic/test.sh $IPV $N" # test atomic broadcast: # start client container and test sending a tx to each node -bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" ab "test/p2p/atomic_broadcast/test.sh $N" +bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" ab "test/p2p/atomic_broadcast/test.sh $IPV $N" # test fast sync (from current state of network): # for each node, kill it and readd via fast sync -bash test/p2p/fast_sync/test.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$N" "$PROXY_APP" +bash test/p2p/fast_sync/test.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" "$N" "$PROXY_APP" # test killing all peers 3 times -bash test/p2p/kill_all/test.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$N" 3 +bash test/p2p/kill_all/test.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" "$N" 3 # test pex -bash test/p2p/pex/test.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$N" "$PROXY_APP" +bash test/p2p/pex/test.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$IPV" "$N" "$PROXY_APP" diff --git a/tests.mk b/tests.mk index 18caef496..72bba47e4 100644 --- a/tests.mk +++ b/tests.mk @@ -38,17 +38,32 @@ test_persistence: test_p2p: docker rm -f rsyslog || true - rm -rf test/logs || true - mkdir test/logs - cd test/ - docker run -d -v "logs:/var/log/" -p 127.0.0.1:5514:514/udp --name rsyslog voxxit/rsyslog - cd .. + rm -rf test/logs && mkdir -p test/logs + docker run -d -v "$(CURDIR)/test/logs:/var/log/" -p 127.0.0.1:5514:514/udp --name rsyslog voxxit/rsyslog # requires 'tester' the image from above bash test/p2p/test.sh tester # the `docker cp` takes a really long time; uncomment for debugging # # mkdir -p test/p2p/logs && docker cp rsyslog:/var/log test/p2p/logs +test_p2p_ipv6: + # IPv6 tests require Docker daemon with IPv6 enabled, e.g. in daemon.json: + # + # { + # "ipv6": true, + # "fixed-cidr-v6": "2001:db8:1::/64" + # } + # + # Docker for Mac can set this via Preferences -> Docker Engine. + docker rm -f rsyslog || true + rm -rf test/logs && mkdir -p test/logs + docker run -d -v "$(CURDIR)/test/logs:/var/log/" -p 127.0.0.1:5514:514/udp --name rsyslog voxxit/rsyslog + # requires 'tester' the image from above + bash test/p2p/test.sh tester 6 + # the `docker cp` takes a really long time; uncomment for debugging + # + # mkdir -p test/p2p/logs && docker cp rsyslog:/var/log test/p2p/logs + test_integrations: make build_docker_test_image make tools @@ -60,6 +75,8 @@ test_integrations: make test_libs make test_persistence make test_p2p + # Disabled by default since it requires Docker daemon with IPv6 enabled + #make test_p2p_ipv6 test_release: @go test -tags release $(PACKAGES)