github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/tests/integration_tests/kafka_column_selector_avro/run.sh (about)

     1  #!/bin/bash
     2  
     3  set -eu
     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  	echo 'Starting schema registry...'
    18  	./bin/bin/schema-registry-start -daemon ./bin/etc/schema-registry/schema-registry.properties
    19  	i=0
    20  	while ! curl -o /dev/null -v -s "http://127.0.0.1:8088"; do
    21  		i=$(($i + 1))
    22  		if [ $i -gt 30 ]; then
    23  			echo 'Failed to start schema registry'
    24  			exit 1
    25  		fi
    26  		sleep 2
    27  	done
    28  
    29  	curl -X PUT -H "Content-Type: application/vnd.schemaregistry.v1+json" --data '{"compatibility": "NONE"}' http://127.0.0.1:8088/config
    30  
    31  	rm -rf $WORK_DIR && mkdir -p $WORK_DIR
    32  	start_tidb_cluster --workdir $WORK_DIR
    33  
    34  	cd $WORK_DIR
    35  
    36  	# record tso before we create tables to skip the system table DDLs
    37  	start_ts=$(cdc cli tso query --pd=http://$UP_PD_HOST_1:$UP_PD_PORT_1)
    38  
    39  	run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY
    40  
    41  	changefeed_id="test"
    42  	TOPIC_NAME="column-selector-avro-test"
    43  	SINK_URI="kafka://127.0.0.1:9092/$TOPIC_NAME?protocol=avro&enable-tidb-extension=true&avro-enable-watermark=true"
    44  	run_cdc_cli changefeed create --start-ts=$start_ts --sink-uri="$SINK_URI" -c ${changefeed_id} --config="$CUR/conf/changefeed.toml" --schema-registry=http://127.0.0.1:8088
    45  
    46  	run_kafka_consumer $WORK_DIR $SINK_URI $CUR/conf/changefeed.toml "http://127.0.0.1:8088"
    47  
    48  	run_sql_file $CUR/data/data.sql ${UP_TIDB_HOST} ${UP_TIDB_PORT}
    49  
    50  	echo "Starting build checksum checker..."
    51  	cd $CUR/../../utils/checksum_checker
    52  	if [ ! -f ./checksum_checker ]; then
    53  		GO111MODULE=on go build
    54  	fi
    55  
    56  	check_table_exists "test.finishmark" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
    57  
    58  	./checksum_checker --upstream-uri "root@tcp(${UP_TIDB_HOST}:${UP_TIDB_PORT})/" --downstream-uri "root@tcp(${DOWN_TIDB_HOST}:${DOWN_TIDB_PORT})/" --databases "test" --config="$CUR/conf/changefeed.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! >>>>>>"