github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/engine/test/utils/check_sync_diff (about) 1 #!/bin/bash 2 # parameter 1: work directory 3 # parameter 2: config file for sync_diff_inspector 4 # parameter 3: max check times 5 # parameter 4: check diff should fail or not 6 7 workdir=$1 8 conf=$2 9 if [ $# -ge 3 ]; then 10 check_time=$3 11 else 12 check_time=20 13 fi 14 15 PWD=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) 16 binary=$PWD/../../../bin/sync_diff_inspector 17 OUTPUT_DIR=/tmp/engine_test/output/ 18 STDOUT=$workdir/sync_diff_stdout.log 19 20 mkdir -p /tmp/engine_test 21 22 cd $workdir 23 i=0 24 while [ $i -lt $check_time ]; do 25 rm -rf $OUTPUT_DIR 26 $binary --config=$conf -L=debug >$STDOUT 2>&1 27 ret=$? 28 if [ "$ret" == 0 ]; then 29 echo "check diff successfully" 30 if [[ $4 = "fail" ]]; then 31 exit 1 32 fi 33 break 34 fi 35 ((i++)) 36 echo "check diff failed $i-th time, retry later" 37 sleep 2 38 done 39 40 if [ $i -ge $check_time ]; then 41 echo "check diff failed at last" 42 if [[ $4 != "fail" ]]; then 43 # show \n and other blanks 44 printf "$STDOUT\n" 45 cat $STDOUT 46 printf "$OUTPUT_DIR/sync_diff.log\n" 47 cat $OUTPUT_DIR/sync_diff.log 48 printf "\n" 49 exit 1 50 fi 51 fi 52 cd $PWD