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

     1  #!/usr/bin/env bash
     2  echo "================= raft member join with backup : best entry 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 set_test_env.sh
    11  source test_common.sh
    12  
    13  # Test scenario
    14  # aergo3 : log 1 ~ 100 : X X X X (305:300) X X X X : 500(snap) 501  XXXX 0 0 0 0 XXXX  0000 0  0 0 0 XXX 0 0 0 0 
    15  #		   aergo4 backup(block 300: term/logno: 307)
    16  
    17  echo "clean all prev servers"
    18  echo "kill_svr & clean 11004~11007"
    19  kill_svr.sh
    20  for i in  11004 11005 11006 11007; do
    21  	echo "rm -rf $TEST_RAFT_INSTANCE/data/$i $TEST_RAFT_INSTANCE/BP$i.toml"
    22  	rm -rf $TEST_RAFT_INSTANCE/data/$i $TEST_RAFT_INSTANCE/BP$i.toml
    23  done
    24  
    25  TEST_SKIP_GENESIS=0 make_node.sh
    26  # make snap in aergo1
    27  sleep 20
    28  # aergo3 down
    29  kill_svr.sh 11003
    30  
    31  echo "========= after kill 10003 ========="
    32  sleep 100
    33  
    34  # copy aergo1 to backup for aergo4 
    35  echo ""
    36  echo "========= copy backup : cp -rf $TEST_RAFT_INSTANCE/data/11001 $TEST_RAFT_INSTANCE/data/11004 ========="
    37  cp -rf $TEST_RAFT_INSTANCE/data/11001 $TEST_RAFT_INSTANCE/data/11004
    38  
    39  echo "========= after backup for aergo4 ========="
    40  sleep 100
    41  
    42  # kill all
    43  kill_svr.sh 
    44  
    45  #aergo3 snapshot sync with aergo1
    46  run_svr.sh 
    47  checkSync 10001 10003 180 
    48  
    49  # remove aergo1, aergo2
    50  set_system_admin.sh
    51  echo "=========== rm member1 =========="
    52  rm_member.sh aergo1
    53  rm BP11001*
    54  
    55  echo "=========== rm member2 =========="
    56  rm_member.sh aergo2
    57  rm BP11002*
    58  
    59  # add aergo4 with backup
    60  echo ""
    61  echo "========= add aergo4 ========="
    62  add_member.sh aergo4 usebackup 10003
    63  checkSync 10003 10004 180
    64  #checkSyncWithLeader 10004 180
    65  # check log if "can't find raft entry for requested hash. so try to find closest raft entry." exists in aergo3
    66  
    67  egrep -q 'find closest raft entry' $TEST_RAFT_INSTANCE/server_BP11003.log
    68  if [ "$?" != "0" ]; then
    69  	echo "not occure log: find closest raft entry"
    70  	exit 100
    71  fi
    72  
    73  echo "succeed to sync"