github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/tests/processor_resolved_ts_fallback/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  
    12  function run() {
    13      # TODO: kafka sink has bug with this case, remove this after bug is fixed
    14      if [ "$SINK_TYPE" == "kafka" ]; then
    15        return
    16      fi
    17  
    18      rm -rf $WORK_DIR && mkdir -p $WORK_DIR
    19      start_tidb_cluster --workdir $WORK_DIR
    20      cd $WORK_DIR
    21  
    22      TOPIC_NAME="ticdc-processor-resolved-ts-fallback-test-$RANDOM"
    23      case $SINK_TYPE in
    24          kafka) SINK_URI="kafka://kafka01:9092/$TOPIC_NAME?partition-num=4&kafka-version=${KAFKA_VERSION}";;
    25          *) SINK_URI="mysql://normal:123456@127.0.0.1:3306/";;
    26      esac
    27      run_cdc_cli changefeed create --sink-uri="$SINK_URI"
    28      if [ "$SINK_TYPE" == "kafka" ]; then
    29        run_kafka_consumer $WORK_DIR "kafka://127.0.0.1:9092/$TOPIC_NAME?partition-num=4&version=${KAFKA_VERSION}"
    30      fi
    31  
    32      export GO_FAILPOINTS='github.com/pingcap/ticdc/cdc/sink/SinkFlushDMLPanic=return(true);github.com/pingcap/ticdc/cdc/sink/producer/kafka/SinkFlushDMLPanic=return(true)'
    33      run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY --logsuffix "1" --addr "127.0.0.1:8301" --pd "http://${UP_PD_HOST_1}:${UP_PD_PORT_1}"
    34      run_sql "CREATE database processor_resolved_ts_fallback;" ${UP_TIDB_HOST} ${UP_TIDB_PORT}
    35      run_sql "CREATE table processor_resolved_ts_fallback.t1(id int primary key auto_increment, val int);" ${UP_TIDB_HOST} ${UP_TIDB_PORT}
    36      # wait table t1 is processed by cdc server
    37      ensure 10 "cdc cli processor list|jq '.|length'|grep -E '^1$'"
    38      export GO_FAILPOINTS=''
    39      run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY --logsuffix "2" --addr "127.0.0.1:8302" --pd "http://${UP_PD_HOST_1}:${UP_PD_PORT_1}"
    40      run_sql "CREATE table processor_resolved_ts_fallback.t2(id int primary key auto_increment, val int);" ${UP_TIDB_HOST} ${UP_TIDB_PORT}
    41      run_sql "CREATE table processor_resolved_ts_fallback.t3(id int primary key auto_increment, val int);" ${UP_TIDB_HOST} ${UP_TIDB_PORT}
    42      check_table_exists "processor_resolved_ts_fallback.t1" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
    43      check_table_exists "processor_resolved_ts_fallback.t2" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
    44      check_table_exists "processor_resolved_ts_fallback.t3" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
    45      ensure 10 "cdc cli processor list|jq '.|length'|grep -E '^2$'"
    46  
    47      run_sql "INSERT INTO processor_resolved_ts_fallback.t1 values (),(),();" ${UP_TIDB_HOST} ${UP_TIDB_PORT}
    48      # wait cdc server 1 is panic
    49      ensure 10 "cdc cli capture list|jq '.|length'|grep -E '^1$'"
    50      run_sql "INSERT INTO processor_resolved_ts_fallback.t1 values (),(),();" ${UP_TIDB_HOST} ${UP_TIDB_PORT}
    51      run_sql "INSERT INTO processor_resolved_ts_fallback.t2 values (),(),();" ${UP_TIDB_HOST} ${UP_TIDB_PORT}
    52  
    53      check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml
    54  
    55      cleanup_process $CDC_BINARY
    56  }
    57  
    58  trap stop_tidb_cluster EXIT
    59  run $*
    60  check_logs $WORK_DIR
    61  echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>"