github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/tests/processor_stop_delay/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 TABLE_COUNT=3 11 12 function run() { 13 rm -rf $WORK_DIR && mkdir -p $WORK_DIR 14 start_tidb_cluster --workdir $WORK_DIR 15 cd $WORK_DIR 16 17 pd_addr="http://$UP_PD_HOST_1:$UP_PD_PORT_1" 18 TOPIC_NAME="ticdc-processor-stop-delay-$RANDOM" 19 case $SINK_TYPE in 20 kafka) SINK_URI="kafka://127.0.0.1:9092/$TOPIC_NAME?partition-num=4&kafka-version=${KAFKA_VERSION}";; 21 *) SINK_URI="mysql://normal:123456@127.0.0.1:3306/?max-txn-row=1";; 22 esac 23 if [ "$SINK_TYPE" == "kafka" ]; then 24 run_kafka_consumer $WORK_DIR "kafka://127.0.0.1:9092/$TOPIC_NAME?partition-num=4&version=${KAFKA_VERSION}" 25 fi 26 export GO_FAILPOINTS='github.com/pingcap/ticdc/cdc/processorStopDelay=1*sleep(10000)' # old processor 27 # export GO_FAILPOINTS='github.com/pingcap/ticdc/cdc/processor/processorStopDelay=1*sleep(10000)' # new processor 28 29 run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY --addr "127.0.0.1:8300" --pd $pd_addr 30 changefeed_id=$(cdc cli changefeed create --pd=$pd_addr --sink-uri="$SINK_URI" 2>&1|tail -n2|head -n1|awk '{print $2}') 31 run_sql "CREATE DATABASE processor_stop_delay;" ${UP_TIDB_HOST} ${UP_TIDB_PORT} 32 run_sql "CREATE table processor_stop_delay.t (id int primary key auto_increment, t datetime DEFAULT CURRENT_TIMESTAMP)" ${UP_TIDB_HOST} ${UP_TIDB_PORT} 33 run_sql "INSERT INTO processor_stop_delay.t values (),(),(),(),(),(),()" ${UP_TIDB_HOST} ${UP_TIDB_PORT} 34 check_table_exists "processor_stop_delay.t" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 35 check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml 36 37 # pause changefeed first, and then resume the changefeed. The processor stop 38 # logic will be delayed by 10s, which is controlled by failpoint injection. 39 # The changefeed should be resumed and no data loss. 40 cdc cli changefeed pause --changefeed-id=$changefeed_id --pd=$pd_addr 41 sleep 1 42 run_sql "INSERT INTO processor_stop_delay.t values (),(),(),(),(),(),()" ${UP_TIDB_HOST} ${UP_TIDB_PORT} 43 cdc cli changefeed resume --changefeed-id=$changefeed_id --pd=$pd_addr 44 run_sql "INSERT INTO processor_stop_delay.t values (),(),(),(),(),(),()" ${UP_TIDB_HOST} ${UP_TIDB_PORT} 45 46 check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml 47 48 export GO_FAILPOINTS='' 49 cleanup_process $CDC_BINARY 50 } 51 52 trap stop_tidb_cluster EXIT 53 run $* 54 check_logs $WORK_DIR 55 echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>"