github.com/aergoio/aergo@v1.3.1/consensus/impl/raftv2/test/test_join_backup.sh (about)

     1  #!/usr/bin/env bash
     2  echo "================= raft member join with backup test ===================="
     3  
     4  BP_NAME=""
     5  
     6  #rm BP*.toml
     7  #./aergoconf-gen.sh 10001 tmpl.toml 5
     8  #clean.sh
     9  #./inittest.sh
    10  source test_common.sh
    11  
    12  echo "clean all prev servers"
    13  echo "kill_svr & clean 11004~11007"
    14  kill_svr.sh
    15  for i in  11004 11005 11006 11007; do
    16  	echo "rm -rf $TEST_RAFT_INSTANCE/data/$i $TEST_RAFT_INSTANCE/BP$i.toml"
    17  	rm -rf $TEST_RAFT_INSTANCE/data/$i $TEST_RAFT_INSTANCE/BP$i.toml
    18  done
    19  
    20  TEST_SKIP_GENESIS=0 make_node.sh
    21  RUN_TEST_SCRIPT set_system_admin.sh
    22  
    23  sleep 2
    24  
    25  function backupJoin() {
    26  	if ! [ $1 -lt 6 ] || ! [ $2 -lt 6 ]; then
    27  		echo "Usage: $0 srcnodeNo(1<=no<=5) addnodeNo"
    28  		echo "exam) $0 3 4"
    29  		exit 100
    30  	fi
    31  
    32  	srcnodename=${nodenames[$1]}
    33  	srcsvrport=${svrports[$srcnodename]}
    34  	srcrpcport=${ports[$srcnodename]}
    35  
    36  	addnodename=${nodenames[$2]}
    37  	addsvrport=${svrports[$addnodename]}
    38  	addrpcport=${ports[$addnodename]}
    39  
    40  	echo "add $addsvrport with $srcsvrport data"
    41  	
    42  	echo ""
    43  	echo "========= shutdown srcsvrport $srcsvrport   ========="
    44  	kill_svr.sh $srcsvrport 
    45  
    46  	echo ""
    47  	echo "========= copy backup : cp -rf ./data/$srcsvrport ./data/$addsvrport ========="
    48  	cp -rf ./data/$srcsvrport ./data/$addsvrport 
    49  
    50  	run_svr.sh $srcsvrport
    51  
    52  	checkSync 10001 $srcrpcport 180
    53  
    54  	sleep 20
    55  
    56  	echo ""
    57  	echo "========= add $addnodename ========="
    58  	add_member.sh $addnodename usebackup
    59  	checkSyncWithLeader $addrpcport 60
    60  }
    61  
    62  backupJoin 3 4
    63  backupJoin 3 5
    64  
    65  echo "=========== rm member5 =========="
    66  rm_member.sh aergo5
    67  rm BP11005*
    68  
    69  echo "=========== rm member4 =========="
    70  rm_member.sh aergo4
    71  rm BP11004*
    72  
    73  echo ""
    74  echo "========= check if reorg occured ========"
    75  checkReorg