github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/tests/many_pk_or_uk/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      rm -rf $WORK_DIR && mkdir -p $WORK_DIR
    13      stop_tidb_cluster
    14  
    15      start_tidb_cluster --workdir $WORK_DIR
    16  
    17      cd $WORK_DIR
    18  
    19      # record tso before we create tables to skip the system table DDLs
    20      start_ts=$(run_cdc_cli tso query --pd=http://$UP_PD_HOST_1:$UP_PD_PORT_1)
    21  
    22      run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY
    23  
    24      TOPIC_NAME="ticdc-many-pk-or-uk-test-$RANDOM"
    25      case $SINK_TYPE in
    26          kafka) SINK_URI="kafka://127.0.0.1:9092/$TOPIC_NAME?partition-num=4&kafka-version=${KAFKA_VERSION}";;
    27          *) SINK_URI="mysql://normal:123456@127.0.0.1:3306/";;
    28      esac
    29      run_cdc_cli changefeed create --start-ts=$start_ts --sink-uri="$SINK_URI"
    30      if [ "$SINK_TYPE" == "kafka" ]; then
    31          run_kafka_consumer $WORK_DIR "kafka://127.0.0.1:9092/$TOPIC_NAME?partition-num=4&version=${KAFKA_VERSION}"
    32      fi
    33  }
    34  
    35  trap stop_tidb_cluster EXIT
    36  prepare $*
    37  
    38  cd "$(dirname "$0")"
    39  set -o pipefail
    40  GO111MODULE=on go run main.go -config ./config.toml 2>&1 | tee $WORK_DIR/tester.log
    41  check_table_exists test.finish_mark ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
    42  check_sync_diff $WORK_DIR $CUR/diff_config.toml
    43  cleanup_process $CDC_BINARY
    44  check_logs $WORK_DIR
    45  echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>"