github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/tests/integration_tests/multi_topics_v2/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 run() { 12 # test kafka sink only in this case 13 if [ "$SINK_TYPE" != "kafka" ]; then 14 return 15 fi 16 17 rm -rf $WORK_DIR && mkdir -p $WORK_DIR 18 19 start_tidb_cluster --workdir $WORK_DIR 20 21 cd $WORK_DIR 22 23 DEFAULT_TOPIC_NAME="multi_topics" 24 # record tso before we create tables to skip the system table DDLs 25 start_ts=$(run_cdc_cli_tso_query ${UP_PD_HOST_1} ${UP_PD_PORT_1}) 26 27 run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY 28 29 SINK_URI="kafka://127.0.0.1:9092/$DEFAULT_TOPIC_NAME?protocol=canal-json&enable-tidb-extension=true&kafka-version=${KAFKA_VERSION}" 30 run_cdc_cli changefeed create --start-ts=$start_ts --sink-uri="$SINK_URI" --config $CUR/conf/changefeed.toml 31 32 run_sql_file $CUR/data/step1.sql ${UP_TIDB_HOST} ${UP_TIDB_PORT} 33 # NOTICE: we need to wait for the kafka topic to be created. 34 sleep 2m 35 36 for i in $(seq 1 3); do 37 run_kafka_consumer $WORK_DIR "kafka://127.0.0.1:9092/test_table${i}?protocol=canal-json&version=${KAFKA_VERSION}&enable-tidb-extension=true" "" ${i} 38 done 39 40 # sync_diff can't check non-exist table, so we check expected tables are created in downstream first 41 for i in $(seq 1 3); do 42 check_table_exists test.table${i} ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 300 43 done 44 check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml 300 45 46 run_sql "rename table test.table1 to test.table10, test.table2 to test.table20" ${UP_TIDB_HOST} ${UP_TIDB_PORT} 47 check_table_exists test.table10 ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 300 48 check_table_exists test.table20 ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 300 49 check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml 300 50 51 run_sql_file $CUR/data/step2.sql ${UP_TIDB_HOST} ${UP_TIDB_PORT} 52 sleep 30 53 run_kafka_consumer $WORK_DIR "kafka://127.0.0.1:9092/test_table10?protocol=canal-json&version=${KAFKA_VERSION}&enable-tidb-extension=true" "" 10 54 run_kafka_consumer $WORK_DIR "kafka://127.0.0.1:9092/test_table20?protocol=canal-json&version=${KAFKA_VERSION}&enable-tidb-extension=true" "" 20 55 run_kafka_consumer $WORK_DIR "kafka://127.0.0.1:9092/test_finish?protocol=canal-json&version=${KAFKA_VERSION}&enable-tidb-extension=true" "" "finish" 56 57 check_table_exists test.finish ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 300 58 check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml 300 59 60 cleanup_process $CDC_BINARY 61 } 62 63 trap stop_tidb_cluster EXIT 64 run $* 65 check_logs $WORK_DIR 66 echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>"