github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/tests/kv_client_stream_reconnect/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=10 11 12 # This test mainly verifies kv client force reconnect can work 13 # Trigger force reconnect by failpoint injection 14 function run() { 15 rm -rf $WORK_DIR && mkdir -p $WORK_DIR 16 start_tidb_cluster --workdir $WORK_DIR 17 cd $WORK_DIR 18 19 pd_addr="http://$UP_PD_HOST_1:$UP_PD_PORT_1" 20 TOPIC_NAME="kv-client-stream-reconnect-$RANDOM" 21 case $SINK_TYPE in 22 kafka) SINK_URI="kafka://127.0.0.1:9092/$TOPIC_NAME?partition-num=4&kafka-version=${KAFKA_VERSION}";; 23 *) SINK_URI="mysql://normal:123456@127.0.0.1:3306/?max-txn-row=1";; 24 esac 25 if [ "$SINK_TYPE" == "kafka" ]; then 26 run_kafka_consumer $WORK_DIR "kafka://127.0.0.1:9092/$TOPIC_NAME?partition-num=4&version=${KAFKA_VERSION}" 27 fi 28 # this will be triggered every 5s in kv client 29 export GO_FAILPOINTS='github.com/pingcap/ticdc/cdc/kv/kvClientForceReconnect=return(true)' 30 run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY --addr "127.0.0.1:8300" --pd $pd_addr 31 changefeed_id=$(cdc cli changefeed create --pd=$pd_addr --sink-uri="$SINK_URI" 2>&1|tail -n2|head -n1|awk '{print $2}') 32 33 run_sql "CREATE DATABASE kv_client_stream_reconnect;" ${UP_TIDB_HOST} ${UP_TIDB_PORT} 34 35 for i in $(seq $TABLE_COUNT); do 36 run_sql "create table kv_client_stream_reconnect.t$i (id int primary key auto_increment, a int default 10);" ${UP_TIDB_HOST} ${UP_TIDB_PORT} 37 done 38 39 for i in $(seq 30); do 40 tbl="t$((1 + $RANDOM % $TABLE_COUNT))" 41 run_sql "insert into kv_client_stream_reconnect.$tbl values (),(),();" ${UP_TIDB_HOST} ${UP_TIDB_PORT} 42 sleep 1 43 done 44 45 check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml 46 export GO_FAILPOINTS='' 47 cleanup_process $CDC_BINARY 48 } 49 50 trap stop_tidb_cluster EXIT 51 run $* 52 check_logs $WORK_DIR 53 echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>"