github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/tests/integration_tests/bank/run.sh (about)

     1  #!/bin/bash
     2  
     3  set -eu
     4  
     5  CUR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
     6  source $CUR/../_utils/test_prepare
     7  WORK_DIR=$OUT_DIR/$TEST_NAME
     8  CDC_BINARY=cdc.test
     9  SINK_TYPE=$1
    10  
    11  function prepare() {
    12  	rm -rf $WORK_DIR && mkdir -p $WORK_DIR
    13  
    14  	start_tidb_cluster --workdir $WORK_DIR
    15  
    16  	cd $WORK_DIR
    17  
    18  	# create table to upstream.
    19  	run_sql "CREATE DATABASE bank" ${UP_TIDB_HOST} ${UP_TIDB_PORT}
    20  	run_sql "CREATE DATABASE bank" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
    21  
    22  	run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY
    23  
    24  	run_cdc_cli changefeed create --sink-uri="mysql://root@${DOWN_TIDB_HOST}:${DOWN_TIDB_PORT}/"
    25  }
    26  
    27  trap stop_tidb_cluster EXIT
    28  # No need to support kafka and storage sink.
    29  if [ "$SINK_TYPE" == "mysql" ]; then
    30  	prepare $*
    31  
    32  	cd "$(dirname "$0")"
    33  	set -euxo pipefail
    34  
    35  	GO111MODULE=on go run bank.go case.go -u "root@tcp(${UP_TIDB_HOST}:${UP_TIDB_PORT})/bank" \
    36  		-d "root@tcp(${DOWN_TIDB_HOST}:${DOWN_TIDB_PORT})/bank" --test-round=20000 \
    37  		-a "${DOWN_TIDB_HOST}:${DOWN_TIDB_STATUS}"
    38  
    39  	cleanup_process $CDC_BINARY
    40  	echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>"
    41  fi