github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/tests/integration_tests/kafka_simple_basic/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 # use kafka-consumer with canal-json decoder to sync data from kafka to mysql 12 function run() { 13 if [ "$SINK_TYPE" != "kafka" ]; then 14 return 15 fi 16 17 # clean up environment 18 rm -rf $WORK_DIR && mkdir -p $WORK_DIR 19 20 # start tidb cluster 21 start_tidb_cluster --workdir $WORK_DIR 22 23 cd $WORK_DIR 24 25 # upstream tidb cluster enable row level checksum 26 run_sql "set global tidb_enable_row_level_checksum=true" ${UP_TIDB_HOST} ${UP_TIDB_PORT} 27 28 TOPIC_NAME="ticdc-simple-basic-$RANDOM" 29 30 run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY 31 32 SINK_URI="kafka://127.0.0.1:9092/$TOPIC_NAME?protocol=simple" 33 run_cdc_cli changefeed create --sink-uri="$SINK_URI" --config="$CUR/conf/changefeed.toml" -c "simple-basic" 34 sleep 5 # wait for changefeed to start 35 36 run_kafka_consumer $WORK_DIR $SINK_URI 37 38 # pre execute some ddls 39 run_sql_file $CUR/data/pre_ddl.sql ${UP_TIDB_HOST} ${UP_TIDB_PORT} 40 check_table_exists test.finish_mark_for_ddl ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 200 41 42 # pause and resume changefeed makes sure changefeed sending bootstrap events 43 # when it is resumed, so the data after pause can be decoded correctly 44 run_cdc_cli changefeed pause -c "simple-basic" 45 run_cdc_cli changefeed resume -c "simple-basic" 46 47 run_sql_file $CUR/data/data.sql ${UP_TIDB_HOST} ${UP_TIDB_PORT} 48 49 # sync_diff can't check non-exist table, so we check expected tables are created in downstream first 50 check_table_exists test.finish_mark ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 200 51 check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml 52 53 run_sql_file $CUR/data/data_gbk.sql ${UP_TIDB_HOST} ${UP_TIDB_PORT} 54 check_table_exists test.finish_mark ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 200 55 check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml 56 57 cleanup_process $CDC_BINARY 58 } 59 60 trap stop_tidb_cluster EXIT 61 run $* 62 check_logs $WORK_DIR 63 echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>"