github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/tests/_utils/check_table_exists (about)

     1  #!/bin/bash
     2  # parameter 1: schema.table
     3  # parameter 2: database host
     4  # parameter 3: database port
     5  # parameter 4: max check times
     6  
     7  if [ $# -ge 4 ]; then
     8      check_time=$4
     9  else
    10      check_time=60
    11  fi
    12  
    13  i=0
    14  while [ $i -lt $check_time ]
    15  do
    16      mysql -h$2 -P$3 -uroot -e "show create table $1" >/dev/null 2>&1
    17      ret=$?
    18      if [ "$ret" == 0 ]; then
    19          echo "table $1 exists"
    20          break
    21      fi
    22      ((i++))
    23      echo "table $1 not exists for $i-th check, retry later"
    24      sleep 2
    25  done
    26  
    27  if [ $i -ge $check_time ]; then
    28      echo "table $1 not exists at last check"
    29      exit 1
    30  fi