github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/tests/common_1/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 rm -rf $WORK_DIR && mkdir -p $WORK_DIR 13 14 start_tidb_cluster --workdir $WORK_DIR 15 16 cd $WORK_DIR 17 18 tidb_build_branch=$(mysql -uroot -h${UP_TIDB_HOST} -P${UP_TIDB_PORT} -e \ 19 "select tidb_version()\G"|grep "Git Branch"|awk -F: '{print $(NF)}'|tr -d " ") 20 # TODO: refine the release detection after 5.0 tag of TiDB is ready 21 if [[ $tidb_build_branch =~ ^(master)$ ]]; then 22 # https://github.com/pingcap/tidb/pull/21533 disables multi_schema change 23 # feature by default, turn it on first 24 run_sql "set global tidb_enable_change_multi_schema = on" ${UP_TIDB_HOST} ${UP_TIDB_PORT} 25 # This must be set before cdc server starts 26 run_sql "set global tidb_enable_change_multi_schema = on" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 27 # TiDB global variables cache 2 seconds at most 28 sleep 2 29 fi 30 31 # record tso before we create tables to skip the system table DDLs 32 start_ts=$(run_cdc_cli tso query --pd=http://$UP_PD_HOST_1:$UP_PD_PORT_1) 33 34 run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY 35 36 # this test contains `recover table`, which requires super privilege, so we 37 # can't use the normal user 38 TOPIC_NAME="ticdc-common-1-test-$RANDOM" 39 case $SINK_TYPE in 40 kafka) SINK_URI="kafka://127.0.0.1:9092/$TOPIC_NAME?partition-num=4&kafka-version=${KAFKA_VERSION}";; 41 *) SINK_URI="mysql://root@127.0.0.1:3306/";; 42 esac 43 run_cdc_cli changefeed create --start-ts=$start_ts --sink-uri="$SINK_URI" 44 if [ "$SINK_TYPE" == "kafka" ]; then 45 run_kafka_consumer $WORK_DIR "kafka://127.0.0.1:9092/$TOPIC_NAME?partition-num=4&version=${KAFKA_VERSION}" 46 fi 47 48 run_sql_file $CUR/data/test.sql ${UP_TIDB_HOST} ${UP_TIDB_PORT} 49 # TODO: refine the release detection after 5.0 tag of TiDB is ready 50 if [[ ! $tidb_build_branch =~ ^(master)$ ]]; then 51 echo "skip some SQLs in tidb v4.0.x" 52 else 53 run_sql_file $CUR/data/test_v5.sql ${UP_TIDB_HOST} ${UP_TIDB_PORT} 54 fi 55 run_sql_file $CUR/data/test_finish.sql ${UP_TIDB_HOST} ${UP_TIDB_PORT} 56 57 # sync_diff can't check non-exist table, so we check expected tables are created in downstream first 58 check_table_exists common_1.v1 ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 59 check_table_exists common_1.recover_and_insert ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 60 check_table_exists common_1.finish_mark ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 61 check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml 62 63 cleanup_process $CDC_BINARY 64 } 65 66 trap stop_tidb_cluster EXIT 67 run $* 68 check_logs $WORK_DIR 69 echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>"