github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/tests/integration_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  tikv_config=
    13  retry_times=3
    14  multiple_upstream_pd="false"
    15  
    16  while [[ ${1} ]]; do
    17  	case "${1}" in
    18  	--workdir)
    19  		OUT_DIR=${2}
    20  		shift
    21  		;;
    22  	--tidb-config)
    23  		tidb_config=${2}
    24  		shift
    25  		;;
    26  	--pd-config)
    27  		pd_config=${2}
    28  		shift
    29  		;;
    30  	--tikv-config)
    31  		tikv_config=${2}
    32  		shift
    33  		;;
    34  	--retry)
    35  		retry_times=${2}
    36  		shift
    37  		;;
    38  	--multiple-upstream-pd)
    39  		multiple_upstream_pd=${2}
    40  		shift
    41  		;;
    42  	*)
    43  		echo "Unknown parameter: ${1}" >&2
    44  		exit 1
    45  		;;
    46  	esac
    47  
    48  	if ! shift; then
    49  		echo 'Missing parameter argument.' >&2
    50  		exit 1
    51  	fi
    52  done
    53  
    54  CUR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
    55  source $CUR/../_utils/test_prepare
    56  
    57  set +e
    58  i=1
    59  while [ $i -le $retry_times ]; do
    60  	echo "The ${i} times to try to start tidb cluster..."
    61  
    62  	if [[ "$tidb_config" != "" ]]; then
    63  		start_tidb_cluster_impl --workdir ${OUT_DIR} --multiple-upstream-pd ${multiple_upstream_pd} --tidb-config ${tidb_config}
    64  	elif [[ "$pd_config" != "" ]]; then
    65  		start_tidb_cluster_impl --workdir ${OUT_DIR} --multiple-upstream-pd ${multiple_upstream_pd} --pd-config ${pd_config}
    66  	elif [[ "$tikv_config" != "" ]]; then
    67  		start_tidb_cluster_impl --workdir ${OUT_DIR} --multiple-upstream-pd ${multiple_upstream_pd} --tikv-config ${tikv_config}
    68  	else
    69  		start_tidb_cluster_impl --workdir ${OUT_DIR} --multiple-upstream-pd ${multiple_upstream_pd}
    70  	fi
    71  
    72  	if [ $? -eq 0 ]; then
    73  		break
    74  	fi
    75  	let i++
    76  	echo "start tidb cluster failed"
    77  done