github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/tests/integration_tests/_utils/random_kill_process (about) 1 #!/bin/bash 2 # parameter 1: process name 3 4 process=$1 5 retry_count=20 6 pids=($(pidof $process)) 7 echo "list pids " ${pids[@]} 8 9 if [ ${#pids[@]} == 0 ]; then 10 exit 0 11 fi 12 13 pid=${pids[$RANDOM % ${#pids[@]}]} 14 15 echo "kill pid $pid" 16 kill $pid 17 18 counter=0 19 while [ $counter -lt $retry_count ]; do 20 ps -p $pid >/dev/null 2>&1 21 ret=$? 22 if [ "$ret" != "0" ]; then 23 echo "process $pid already exit" 24 exit 0 25 fi 26 ((counter += 1)) 27 sleep 0.5 28 echo "wait process $pid exit for $counter-th time..." 29 done 30 31 echo "wait process $pid exit timeout" 32 exit 1