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

     1  #!/usr/bin/env bash
     2  echo "============================== raft syncer crash test (crash=$method)============================"
     3  source test_common.sh
     4  
     5  
     6  if [ $# != 1 ];then
     7  	echo "Usage: $0 crashno(0=fatal, 1=error)"
     8  fi
     9  
    10  CRASH_NO=$1
    11  method=""
    12  if [ "$CRASH_NO" = "1" ]; then
    13  	method="FATAL"
    14  else 
    15  	method="ERROR"
    16  fi
    17  
    18  
    19  BP_NAME=""
    20  
    21  #rm BP*.toml
    22  #./aergoconf-gen.sh 10001 tmpl.toml 5
    23  #clean.sh
    24  #./inittest.sh
    25  
    26  echo ""
    27  echo "======== make initial server ========="
    28  make_node.sh 
    29  
    30  checkSync 10001 10002 10
    31  checkSync 10001 10003 10
    32  
    33  echo "kill for delaying 11003"
    34  kill_svr.sh 11003
    35  
    36  sleep 30
    37  DEBUG_SYNCER_CRASH=$CRASH_NO run_svr.sh 11003
    38  # aergo3 (11003)은 crash(CRASH_NO=1) or syncer 에러후(CRASH_NO=0) 정상 상태
    39  sleep 10
    40  
    41  # leader에서 aergo3의 raftstate가 Snapshot이 아니어야 한다. 
    42  # get leaderport
    43  getLeaderPort leaderport
    44  echo "leaderport=$leaderport"
    45  
    46  # get raftid for aergo3
    47  name="aergo3"
    48  raftState=
    49  getRaftState $name raftState
    50  echo "state of aergo3 = $raftState"
    51  
    52  if [ "$CRASH_NO" = 1 -a "$raftState" != "ProgressStateProbe" ]; then
    53  	echo "=========== fail : state must be probe(unknown) =========="
    54  	exit 100
    55  fi
    56  
    57  echo "============== success to catch crash of aergo3 =========="
    58  
    59  # restart aergo3
    60  kill_svr.sh 11003
    61  run_svr.sh 11003
    62  checkSync 10001 10003 20
    63