github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/tests/integration_tests/canal_json_content_compatible/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" ] && [ "$SINK_TYPE" != "pulsar" ]; 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 TOPIC_NAME="ticdc-canal-json-content-compatible" 26 27 run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY 28 29 if [ "$SINK_TYPE" == "kafka" ]; then 30 SINK_URI="kafka://127.0.0.1:9092/$TOPIC_NAME?protocol=canal-json&enable-tidb-extension=true&content-compatible=true" 31 fi 32 33 if [ "$SINK_TYPE" == "pulsar" ]; then 34 run_pulsar_cluster $WORK_DIR normal 35 SINK_URI="pulsar://127.0.0.1:6650/$TOPIC_NAME?protocol=canal-json&enable-tidb-extension=true" 36 fi 37 38 run_cdc_cli changefeed create --sink-uri="$SINK_URI" 39 sleep 5 # wait for changefeed to start 40 # determine the sink uri and run corresponding consumer 41 # currently only kafka and pulsar are supported 42 if [ "$SINK_TYPE" == "kafka" ]; then 43 run_kafka_consumer $WORK_DIR $SINK_URI 44 fi 45 46 if [ "$SINK_TYPE" == "pulsar" ]; then 47 run_pulsar_consumer --upstream-uri $SINK_URI 48 fi 49 50 run_sql_file $CUR/data/data.sql ${UP_TIDB_HOST} ${UP_TIDB_PORT} 51 52 # sync_diff can't check non-exist table, so we check expected tables are created in downstream first 53 check_table_exists test.finish_mark ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 200 54 check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml 55 56 run_sql_file $CUR/data/data_gbk.sql ${UP_TIDB_HOST} ${UP_TIDB_PORT} 57 check_table_exists test.finish_mark ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 200 58 check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml 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! >>>>>>"