github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/tests/integration_tests/_utils/ensure (about)

     1  #!/bin/bash
     2  # $1: max retries
     3  # $2: command to run
     4  
     5  total=$1
     6  shift
     7  for ((i = 1; i <= $total; i++)); do
     8  	# run the command
     9  	echo $*
    10  	bash -c "$*"
    11  	if [ $? == 0 ]; then
    12  		echo "run task successfully"
    13  		exit 0
    14  	fi
    15  	echo "run task failed $i-th time, retry later"
    16  	sleep $((2 * $i))
    17  done
    18  
    19  echo "run task failed"
    20  exit 1