github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/tests/processor_panic/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  
    14      start_tidb_cluster --workdir $WORK_DIR
    15  
    16      cd $WORK_DIR
    17  
    18      # record tso before we create tables to skip the system table DDLs
    19      start_ts=$(run_cdc_cli tso query --pd=http://$UP_PD_HOST_1:$UP_PD_PORT_1)
    20  
    21      run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY --logsuffix 1 --addr 127.0.0.1:8300 --restart true \
    22                    --failpoint 'github.com/pingcap/ticdc/cdc/ProcessorSyncResolvedPreEmit=return(true)' # old processor
    23  
    24      # run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY --logsuffix 1 --addr 127.0.0.1:8300 --restart true \
    25      #                --failpoint 'github.com/pingcap/ticdc/cdc/processor/pipeline/ProcessorSyncResolvedPreEmit=return(true)' # new processor
    26  
    27      run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY --logsuffix 2 --addr 127.0.0.1:8301
    28  
    29      TOPIC_NAME="ticdc-processor-panic-test-$RANDOM"
    30      case $SINK_TYPE in
    31          kafka) SINK_URI="kafka://127.0.0.1:9092/$TOPIC_NAME?partition-num=4&kafka-client-id=cdc_test_processor_panic&kafka-version=${KAFKA_VERSION}";;
    32          *) SINK_URI="mysql://normal:123456@127.0.0.1:3306/";;
    33      esac
    34      run_cdc_cli changefeed create --start-ts=$start_ts --sink-uri="$SINK_URI"
    35      if [ "$SINK_TYPE" == "kafka" ]; then
    36        run_kafka_consumer $WORK_DIR "kafka://127.0.0.1:9092/$TOPIC_NAME?partition-num=4&version=${KAFKA_VERSION}"
    37      fi
    38  }
    39  
    40  
    41  trap stop_tidb_cluster EXIT
    42  prepare $*
    43  
    44  cd "$(dirname "$0")"
    45  set -o pipefail
    46  GO111MODULE=on go run main.go -config ./config.toml 2>&1 | tee $WORK_DIR/tester.log
    47  check_table_exists test.end_mark_table ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 90
    48  check_sync_diff $WORK_DIR $CUR/diff_config.toml
    49  cleanup_process $CDC_BINARY
    50  check_logs $WORK_DIR
    51  echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>"