github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/tests/cdc/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 prepare() { 12 rm -rf $WORK_DIR && mkdir -p $WORK_DIR 13 stop_tidb_cluster 14 15 start_tidb_cluster --workdir $WORK_DIR 16 17 cd $WORK_DIR 18 19 # record tso before we create tables to skip the system table DDLs 20 start_ts=$(run_cdc_cli tso query --pd=http://$UP_PD_HOST_1:$UP_PD_PORT_1) 21 22 run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY 23 24 TOPIC_NAME="ticdc-cdc-test-$RANDOM" 25 case $SINK_TYPE in 26 kafka) SINK_URI="kafka://127.0.0.1:9092/$TOPIC_NAME?partition-num=4&kafka-version=${KAFKA_VERSION}";; 27 *) SINK_URI="mysql://normal:123456@127.0.0.1:3306/";; 28 esac 29 run_cdc_cli changefeed create --start-ts=$start_ts --sink-uri="$SINK_URI" 30 if [ "$SINK_TYPE" == "kafka" ]; then 31 run_kafka_consumer $WORK_DIR "kafka://127.0.0.1:9092/$TOPIC_NAME?partition-num=4&version=${KAFKA_VERSION}" 32 fi 33 } 34 35 trap stop_tidb_cluster EXIT 36 prepare $* 37 38 cd "$(dirname "$0")" 39 set -o pipefail 40 GO111MODULE=on go run cdc.go -config ./config.toml 2>&1 | tee $WORK_DIR/tester.log 41 cleanup_process $CDC_BINARY 42 check_logs $WORK_DIR 43 echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>"