Browse Source

test: more cleanup on p2p

pull/330/head
Ethan Buchman 8 years ago
parent
commit
bcd8712ec3
7 changed files with 119 additions and 71 deletions
  1. +5
    -36
      test/p2p/atomic_broadcast/test.sh
  2. +53
    -0
      test/p2p/basic/test.sh
  3. +6
    -7
      test/p2p/fast_sync/check_peer.sh
  4. +5
    -18
      test/p2p/fast_sync/test.sh
  5. +37
    -0
      test/p2p/fast_sync/test_peer.sh
  6. +1
    -1
      test/p2p/local_testnet.sh
  7. +12
    -9
      test/p2p/test.sh

+ 5
- 36
test/p2p/atomic_broadcast/test.sh View File

@ -1,52 +1,21 @@
#! /bin/bash
set -u
N=$1
###################################################################
# wait for all peers to come online
# assumes peers are already synced up
# test sending txs
# for each peer:
# wait to have 3 peers
# wait to be at height > 1
# send a tx, wait for commit
# assert app hash on every peer reflects the post tx state
###################################################################
N=4
# 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):46657
curl -s $addr/status > /dev/null
ERR=$?
while [ "$ERR" != 0 ]; do
sleep 1
curl -s $addr/status > /dev/null
ERR=$?
done
echo "... node $i is up"
done
echo ""
# run the test on each of them
for i in `seq 1 $N`; do
addr=$(test/p2p/ip.sh $i):46657
# - assert everyone has 3 other peers
N_PEERS=`curl -s $addr/net_info | jq '.result[1].peers | length'`
while [ "$N_PEERS" != 3 ]; do
echo "Waiting for node $i to connect to all peers ..."
sleep 1
N_PEERS=`curl -s $addr/net_info | jq '.result[1].peers | length'`
done
# - assert block height is greater than 1
BLOCK_HEIGHT=`curl -s $addr/status | jq .result[1].latest_block_height`
while [ "$BLOCK_HEIGHT" -le 1 ]; do
echo "Waiting for node $i to commit a block ..."
sleep 1
BLOCK_HEIGHT=`curl -s $addr/status | jq .result[1].latest_block_height`
done
echo "Node $i is connected to all peers and at block $BLOCK_HEIGHT"
# current state
HASH1=`curl -s $addr/status | jq .result[1].latest_app_hash`


+ 53
- 0
test/p2p/basic/test.sh View File

@ -0,0 +1,53 @@
#! /bin/bash
set -u
N=$1
###################################################################
# wait for all peers to come online
# for each peer:
# wait to have N-1 peers
# wait to be at height > 1
###################################################################
# 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):46657
curl -s $addr/status > /dev/null
ERR=$?
while [ "$ERR" != 0 ]; do
sleep 1
curl -s $addr/status > /dev/null
ERR=$?
done
echo "... node $i is up"
done
echo ""
# wait for each of them to sync up
for i in `seq 1 $N`; do
addr=$(test/p2p/ip.sh $i):46657
N_1=$(($N - 1))
# - assert everyone has N-1 other peers
N_PEERS=`curl -s $addr/net_info | jq '.result[1].peers | length'`
while [ "$N_PEERS" != $N_1 ]; do
echo "Waiting for node $i to connect to all peers ..."
sleep 1
N_PEERS=`curl -s $addr/net_info | jq '.result[1].peers | length'`
done
# - assert block height is greater than 1
BLOCK_HEIGHT=`curl -s $addr/status | jq .result[1].latest_block_height`
while [ "$BLOCK_HEIGHT" -le 1 ]; do
echo "Waiting for node $i to commit a block ..."
sleep 1
BLOCK_HEIGHT=`curl -s $addr/status | jq .result[1].latest_block_height`
done
echo "Node $i is connected to all peers and at block $BLOCK_HEIGHT"
done
echo ""
echo "PASS"
echo ""

test/p2p/fast_sync/restart_peer.sh → test/p2p/fast_sync/check_peer.sh View File


+ 5
- 18
test/p2p/fast_sync/test.sh View File

@ -3,26 +3,13 @@ set -eu
DOCKER_IMAGE=$1
NETWORK_NAME=$2
COUNT=$3
N=$4
N=$3
echo "Testing fasysync on node $COUNT"
cd $GOPATH/src/github.com/tendermint/tendermint
# kill peer
set +e # circle sigh :(
docker rm -vf local_testnet_$COUNT
set -e
# restart peer - should have an empty blockchain
SEEDS="$(test/p2p/ip.sh 1):46656"
for j in `seq 2 $N`; do
SEEDS="$SEEDS,$(test/p2p/ip.sh $j):46656"
# 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
done
bash test/p2p/peer.sh $DOCKER_IMAGE $NETWORK_NAME $COUNT $SEEDS
bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME fs_$COUNT "test/p2p/fast_sync/restart_peer.sh $COUNT"
echo ""
echo "PASS"
echo ""

+ 37
- 0
test/p2p/fast_sync/test_peer.sh View File

@ -0,0 +1,37 @@
#! /bin/bash
set -eu
DOCKER_IMAGE=$1
NETWORK_NAME=$2
COUNT=$3
N=$4
###############################################################
# this runs on each peer:
# kill peer
# bring it back online via fast sync
# wait for it to sync and check the app hash
###############################################################
echo "Testing fasysync on node $COUNT"
# kill peer
set +e # circle sigh :(
docker rm -vf local_testnet_$COUNT
set -e
# restart peer - should have an empty blockchain
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 $COUNT $SEEDS
# wait for peer to sync and check the app hash
bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME fs_$COUNT "test/p2p/fast_sync/check_peer.sh $COUNT"
echo ""
echo "PASS"
echo ""

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

@ -3,13 +3,13 @@ set -eu
DOCKER_IMAGE=$1
NETWORK_NAME=$2
N=$3
cd $GOPATH/src/github.com/tendermint/tendermint
# create docker network
docker network create --driver bridge --subnet 172.57.0.0/16 $NETWORK_NAME
N=4
seeds="$(test/p2p/ip.sh 1):46656"
for i in `seq 2 $N`; do
seeds="$seeds,$(test/p2p/ip.sh $i):46656"


+ 12
- 9
test/p2p/test.sh View File

@ -3,18 +3,21 @@ set -eu
DOCKER_IMAGE=$1
NETWORK_NAME=local_testnet
N=4
cd $GOPATH/src/github.com/tendermint/tendermint
# start the testnet on a local network
bash test/p2p/local_testnet.sh $DOCKER_IMAGE $NETWORK_NAME
bash test/p2p/local_testnet.sh $DOCKER_IMAGE $NETWORK_NAME $N
# test atomic broadcast
bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME ab test/p2p/atomic_broadcast/test.sh
# 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"
# test fast sync (from current state of network)
# run it on each of them
N=4
for i in `seq 1 $N`; do
bash test/p2p/fast_sync/test.sh $DOCKER_IMAGE $NETWORK_NAME $i $N
done
# 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"
# 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

Loading…
Cancel
Save