Browse Source

test p2p pex reactor (Refs #335)

pull/426/head
Anton Kalyaev 8 years ago
committed by Ethan Buchman
parent
commit
163fe1731b
6 changed files with 59 additions and 9 deletions
  1. +1
    -1
      test/p2p/fast_sync/test_peer.sh
  2. +1
    -1
      test/p2p/local_testnet_start.sh
  3. +3
    -6
      test/p2p/peer.sh
  4. +17
    -0
      test/p2p/pex/check_peer.sh
  5. +33
    -0
      test/p2p/pex/test.sh
  6. +4
    -1
      test/p2p/test.sh

+ 1
- 1
test/p2p/fast_sync/test_peer.sh View File

@ -27,7 +27,7 @@ SEEDS="$(test/p2p/ip.sh 1):46656"
for j in `seq 2 $N`; do
SEEDS="$SEEDS,$(test/p2p/ip.sh $j):46656"
done
bash test/p2p/peer.sh $DOCKER_IMAGE $NETWORK_NAME $ID $PROXY_APP $SEEDS
bash test/p2p/peer.sh $DOCKER_IMAGE $NETWORK_NAME $ID $PROXY_APP "--seeds $SEEDS"
# 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"


+ 1
- 1
test/p2p/local_testnet_start.sh View File

@ -18,5 +18,5 @@ done
echo "Seeds: $seeds"
for i in `seq 1 $N`; do
bash test/p2p/peer.sh $DOCKER_IMAGE $NETWORK_NAME $i $APP_PROXY $seeds
bash test/p2p/peer.sh $DOCKER_IMAGE $NETWORK_NAME $i $APP_PROXY "--seeds $seeds --pex"
done

+ 3
- 6
test/p2p/peer.sh View File

@ -7,11 +7,8 @@ ID=$3
APP_PROXY=$4
set +u
SEEDS=$5
NODE_FLAGS=$5
set -u
if [[ "$SEEDS" != "" ]]; then
SEEDS=" --seeds $SEEDS "
fi
set +eu
@ -29,7 +26,7 @@ if [[ "$CIRCLECI" == true ]]; then
--log-opt syslog-address=udp://127.0.0.1:5514 \
--log-opt syslog-facility=daemon \
--log-opt tag="{{.Name}}" \
$DOCKER_IMAGE node $SEEDS --log_level=debug --proxy_app=$APP_PROXY
$DOCKER_IMAGE node $NODE_FLAGS --log_level=debug --proxy_app=$APP_PROXY
else
set -u
docker run -d \
@ -38,5 +35,5 @@ else
--name local_testnet_$ID \
--entrypoint tendermint \
-e TMROOT=/go/src/github.com/tendermint/tendermint/test/p2p/data/mach$ID/core \
$DOCKER_IMAGE node $SEEDS --log_level=info --proxy_app=$APP_PROXY
$DOCKER_IMAGE node $NODE_FLAGS --log_level=info --proxy_app=$APP_PROXY
fi

+ 17
- 0
test/p2p/pex/check_peer.sh View File

@ -0,0 +1,17 @@
#! /bin/bash
set -u
ID=$1
N=$2
addr=$(test/p2p/ip.sh "$ID"):46657
echo "2. wait until peer $ID connects to other nodes using pex reactor"
peers_count="0"
while [[ "$peers_count" -lt "$((N-1))" ]]; do
sleep 1
peers_count=$(curl -s "$addr/net_info" | jq ".result[1].peers | length")
echo "... peers count = $peers_count, expected = $((N-1))"
done
echo "... successful"

+ 33
- 0
test/p2p/pex/test.sh View File

@ -0,0 +1,33 @@
#! /bin/bash
set -eu
DOCKER_IMAGE=$1
NETWORK_NAME=$2
N=$3
PROXY_APP=$4
ID=1
echo "----------------------------------------------------------------------"
echo "Testing pex creates the addrbook and uses it if seeds are not provided"
echo "(assuming peers are started with pex enabled)"
echo "1. restart peer $ID"
docker stop "local_testnet_$ID"
# preserce addrbook.json
docker cp "local_testnet_$ID:/go/src/github.com/tendermint/tendermint/test/p2p/data/mach1/core/addrbook.json" "/tmp/addrbook.json"
docker rm -vf "local_testnet_$ID"
# NOTE that we do not provide seeds this time
bash test/p2p/peer.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "$ID" "$PROXY_APP" "--pex"
docker cp "/tmp/addrbook.json" "local_testnet_$ID:/go/src/github.com/tendermint/tendermint/test/p2p/data/mach1/core/addrbook.json"
echo "with the following addrbook:"
docker exec "local_testnet_$ID" cat "/go/src/github.com/tendermint/tendermint/test/p2p/data/mach1/core/addrbook.json"
echo ""
# if the client runs forever, it means addrbook wasn't saved or was empty
bash test/p2p/client.sh "$DOCKER_IMAGE" "$NETWORK_NAME" "pex_$ID" "test/p2p/pex/check_peer.sh $ID $N"
echo ""
echo "PASS"
echo ""

+ 4
- 1
test/p2p/test.sh View File

@ -29,5 +29,8 @@ bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME ab "test/p2p/atomic_broadcas
# for each node, kill it and readd via fast sync
bash test/p2p/fast_sync/test.sh $DOCKER_IMAGE $NETWORK_NAME $N $PROXY_APP
# test killing all peers
# test killing all peers 3 times
bash test/p2p/kill_all/test.sh $DOCKER_IMAGE $NETWORK_NAME $N 3
# test pex
bash test/p2p/pex/test.sh $DOCKER_IMAGE $NETWORK_NAME $N $PROXY_APP

Loading…
Cancel
Save