github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/tests/bank/run.sh (about)

     1  #!/bin/bash
     2  
     3  set -e
     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      if [ "$SINK_TYPE" == "kafka" ]; then
    13        return
    14      fi
    15  
    16      rm -rf $WORK_DIR && mkdir -p $WORK_DIR
    17  
    18      start_tidb_cluster --workdir $WORK_DIR
    19  
    20      cd $WORK_DIR
    21  
    22      # create table to upstream.
    23      run_sql "CREATE DATABASE bank" ${UP_TIDB_HOST} ${UP_TIDB_PORT}
    24      run_sql "CREATE DATABASE bank" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
    25  
    26      run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY
    27  
    28      run_cdc_cli changefeed create --sink-uri="mysql://root@${DOWN_TIDB_HOST}:${DOWN_TIDB_PORT}/"
    29  }
    30  
    31  trap stop_tidb_cluster EXIT
    32  # kafka is not supported yet.
    33  if [ "$SINK_TYPE" != "kafka" ]; then
    34      prepare $*
    35  
    36      cd "$(dirname "$0")"
    37      set -euxo pipefail
    38  
    39      GO111MODULE=on go run bank.go case.go -u "root@tcp(${UP_TIDB_HOST}:${UP_TIDB_PORT})/bank" \
    40          -d "root@tcp(${DOWN_TIDB_HOST}:${DOWN_TIDB_PORT})/bank" --test-round=20000
    41  
    42      cleanup_process $CDC_BINARY
    43      echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>"
    44  fi
    45  
    46  
    47  
    48