github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/dm/tests/util.sh (about) 1 #!/bin/bash 2 3 wait_for_syncer_alive() { 4 i=0 5 while [ $i -lt 20 ]; do 6 check_syncer_alive 7 ret=$? 8 if [ "$ret" == 1 ]; then 9 echo "syncer is alive" 10 break 11 fi 12 ((i++)) 13 cat syncer_sharding_test.log 14 sleep 1 15 done 16 } 17 18 check_syncer_alive() { 19 pid=$(pgrep syncer) 20 if [ -n "$pid" ]; then 21 return 1 22 else 23 return 0 24 fi 25 } 26 27 check_db_status() { 28 while true; do 29 if mysqladmin -h "$1" -P "$2" -u root ping >/dev/null 2>&1; then 30 break 31 fi 32 echo "wait for ready: $1:$2" 33 sleep 1 34 done 35 echo "$3 is alive" 36 } 37 38 stop_syncer() { 39 killall -9 syncer || true 40 } 41 42 start_tidb() { 43 cd "${TIDB_DIR}" || exit 44 killall -9 tidb-server || true 45 bin/tidb-server >"$1" 2>&1 & 46 cd "${OLDPWD}" || exit 47 } 48 49 stop_tidb() { 50 killall -9 tidb-server || true 51 rm -r /tmp/tidb || true 52 } 53 54 check_previous_command_success_or_exit() { 55 if [ "$?" != 0 ]; then 56 exit 1 57 fi 58 }