mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-13 13:21:20 +00:00
test: more cleanup on p2p
This commit is contained in:
@ -1,52 +1,21 @@
|
|||||||
#! /bin/bash
|
#! /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:
|
# for each peer:
|
||||||
# wait to have 3 peers
|
|
||||||
# wait to be at height > 1
|
|
||||||
# send a tx, wait for commit
|
# send a tx, wait for commit
|
||||||
# assert app hash on every peer reflects the post tx state
|
# 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 ""
|
echo ""
|
||||||
# run the test on each of them
|
# run the test on each of them
|
||||||
for i in `seq 1 $N`; do
|
for i in `seq 1 $N`; do
|
||||||
addr=$(test/p2p/ip.sh $i):46657
|
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
|
# current state
|
||||||
HASH1=`curl -s $addr/status | jq .result[1].latest_app_hash`
|
HASH1=`curl -s $addr/status | jq .result[1].latest_app_hash`
|
||||||
|
|
||||||
|
53
test/p2p/basic/test.sh
Normal file
53
test/p2p/basic/test.sh
Normal 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 ""
|
@ -2,15 +2,14 @@
|
|||||||
set -eu
|
set -eu
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
###############################################################
|
|
||||||
# for each peer:
|
|
||||||
# kill peer
|
|
||||||
# bring it back online via fast sync
|
|
||||||
# check app hash
|
|
||||||
###############################################################
|
|
||||||
|
|
||||||
ID=$1
|
ID=$1
|
||||||
|
|
||||||
|
###########################################
|
||||||
|
#
|
||||||
|
# Wait for peer to catchup to other peers
|
||||||
|
#
|
||||||
|
###########################################
|
||||||
|
|
||||||
addr=$(test/p2p/ip.sh $ID):46657
|
addr=$(test/p2p/ip.sh $ID):46657
|
||||||
peerID=$(( $(($ID % 4)) + 1 )) # 1->2 ... 3->4 ... 4->1
|
peerID=$(( $(($ID % 4)) + 1 )) # 1->2 ... 3->4 ... 4->1
|
||||||
peer_addr=$(test/p2p/ip.sh $peerID):46657
|
peer_addr=$(test/p2p/ip.sh $peerID):46657
|
@ -3,26 +3,13 @@ set -eu
|
|||||||
|
|
||||||
DOCKER_IMAGE=$1
|
DOCKER_IMAGE=$1
|
||||||
NETWORK_NAME=$2
|
NETWORK_NAME=$2
|
||||||
COUNT=$3
|
N=$3
|
||||||
N=$4
|
|
||||||
|
|
||||||
echo "Testing fasysync on node $COUNT"
|
cd $GOPATH/src/github.com/tendermint/tendermint
|
||||||
|
|
||||||
# kill peer
|
# run it on each of them
|
||||||
set +e # circle sigh :(
|
for i in `seq 1 $N`; do
|
||||||
docker rm -vf local_testnet_$COUNT
|
bash test/p2p/fast_sync/test_peer.sh $DOCKER_IMAGE $NETWORK_NAME $i $N
|
||||||
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
|
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
test/p2p/fast_sync/test_peer.sh
Normal file
37
test/p2p/fast_sync/test_peer.sh
Normal 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 ""
|
||||||
|
|
@ -3,13 +3,13 @@ set -eu
|
|||||||
|
|
||||||
DOCKER_IMAGE=$1
|
DOCKER_IMAGE=$1
|
||||||
NETWORK_NAME=$2
|
NETWORK_NAME=$2
|
||||||
|
N=$3
|
||||||
|
|
||||||
cd $GOPATH/src/github.com/tendermint/tendermint
|
cd $GOPATH/src/github.com/tendermint/tendermint
|
||||||
|
|
||||||
# create docker network
|
# create docker network
|
||||||
docker network create --driver bridge --subnet 172.57.0.0/16 $NETWORK_NAME
|
docker network create --driver bridge --subnet 172.57.0.0/16 $NETWORK_NAME
|
||||||
|
|
||||||
N=4
|
|
||||||
seeds="$(test/p2p/ip.sh 1):46656"
|
seeds="$(test/p2p/ip.sh 1):46656"
|
||||||
for i in `seq 2 $N`; do
|
for i in `seq 2 $N`; do
|
||||||
seeds="$seeds,$(test/p2p/ip.sh $i):46656"
|
seeds="$seeds,$(test/p2p/ip.sh $i):46656"
|
||||||
|
@ -3,18 +3,21 @@ set -eu
|
|||||||
|
|
||||||
DOCKER_IMAGE=$1
|
DOCKER_IMAGE=$1
|
||||||
NETWORK_NAME=local_testnet
|
NETWORK_NAME=local_testnet
|
||||||
|
N=4
|
||||||
|
|
||||||
cd $GOPATH/src/github.com/tendermint/tendermint
|
cd $GOPATH/src/github.com/tendermint/tendermint
|
||||||
|
|
||||||
# start the testnet on a local network
|
# 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
|
# test basic connectivity and consensus
|
||||||
bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME ab test/p2p/atomic_broadcast/test.sh
|
# 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)
|
# test atomic broadcast:
|
||||||
# run it on each of them
|
# start client container and test sending a tx to each node
|
||||||
N=4
|
bash test/p2p/client.sh $DOCKER_IMAGE $NETWORK_NAME ab "test/p2p/atomic_broadcast/test.sh $N"
|
||||||
for i in `seq 1 $N`; do
|
|
||||||
bash test/p2p/fast_sync/test.sh $DOCKER_IMAGE $NETWORK_NAME $i $N
|
# test fast sync (from current state of network):
|
||||||
done
|
# for each node, kill it and readd via fast sync
|
||||||
|
bash test/p2p/fast_sync/test.sh $DOCKER_IMAGE $NETWORK_NAME $N
|
||||||
|
Reference in New Issue
Block a user