github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/tests/multi_source/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-multi-source-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 mark.finish_mark_0 ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 300
    42  check_table_exists mark.finish_mark_1 ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 300
    43  check_table_exists mark.finish_mark_2 ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 300
    44  check_table_exists mark.finish_mark_3 ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 300
    45  check_table_exists mark.finish_mark_4 ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 300
    46  check_table_exists mark.finish_mark ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 300
    47  check_sync_diff $WORK_DIR $CUR/diff_config.toml
    48  cleanup_process $CDC_BINARY
    49  check_logs $WORK_DIR
    50  echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>"