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

     1  #!/bin/bash
     2  
     3  # --workdir: work directory
     4  # --tidb-config: path to tidb config file
     5  # --retry: retry times
     6  
     7  set -e
     8  
     9  OUT_DIR=
    10  tidb_config=
    11  pd_config=
    12  retry_times=3
    13  multiple_upstream_pd="false"
    14  
    15  while [[ ${1} ]]; do
    16      case "${1}" in
    17          --workdir)
    18              OUT_DIR=${2}
    19              shift
    20              ;;
    21          --tidb-config)
    22              tidb_config=${2}
    23              shift
    24              ;;
    25          --pd-config)
    26              pd_config=${2}
    27              shift
    28              ;;
    29          --retry)
    30              retry_times=${2}
    31              shift
    32              ;;
    33          --multiple-upstream-pd)
    34              multiple_upstream_pd=${2}
    35              shift
    36              ;;
    37          *)
    38              echo "Unknown parameter: ${1}" >&2
    39              exit 1
    40      esac
    41  
    42      if ! shift; then
    43          echo 'Missing parameter argument.' >&2
    44          exit 1
    45      fi
    46  done
    47  
    48  CUR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
    49  source $CUR/../_utils/test_prepare
    50  
    51  set +e
    52  i=1
    53  while [ $i -le $retry_times ]
    54  do
    55      echo "The ${i} times to try to start tidb cluster..."
    56  
    57      if [[ "$tidb_config" != "" ]]; then
    58          start_tidb_cluster_impl --workdir ${OUT_DIR} --multiple-upstream-pd ${multiple_upstream_pd} --tidb-config ${tidb_config}
    59      elif [[ "$pd_config" != "" ]]; then
    60          start_tidb_cluster_impl --workdir ${OUT_DIR} --multiple-upstream-pd ${multiple_upstream_pd} --pd-config ${pd_config}
    61      else
    62          start_tidb_cluster_impl --workdir ${OUT_DIR} --multiple-upstream-pd ${multiple_upstream_pd}
    63      fi
    64  
    65      if [ $? -eq 0 ]; then
    66          break
    67      fi
    68      let i++
    69      echo "start tidb cluster failed"
    70  done