diff --git a/tests/integration_tests/resourcecontrol/conf/diff_config.toml b/tests/integration_tests/resourcecontrol/conf/diff_config.toml new file mode 100644 index 00000000000..4d4481c8b05 --- /dev/null +++ b/tests/integration_tests/resourcecontrol/conf/diff_config.toml @@ -0,0 +1,29 @@ +# diff Configuration. + +check-thread-count = 4 + +export-fix-sql = true + +check-struct-only = false + +[task] + output-dir = "/tmp/tidb_cdc_test/resourcecontrol/sync_diff/output" + + source-instances = ["mysql1"] + + target-instance = "tidb0" + + target-check-tables = ["resourcecontrol.?*"] + +[data-sources] +[data-sources.mysql1] + host = "127.0.0.1" + port = 4000 + user = "root" + password = "" + +[data-sources.tidb0] + host = "127.0.0.1" + port = 3306 + user = "root" + password = "" diff --git a/tests/integration_tests/resourcecontrol/data/prepare.sql b/tests/integration_tests/resourcecontrol/data/prepare.sql new file mode 100644 index 00000000000..e8b51b50ba7 --- /dev/null +++ b/tests/integration_tests/resourcecontrol/data/prepare.sql @@ -0,0 +1,12 @@ +drop database if exists `resourcecontrol`; +create database `resourcecontrol`; +use `resourcecontrol`; + +SET GLOBAL tidb_enable_resource_control='on'; +create resource group rg1 ru_per_sec=1000; +alter resource group rg1 ru_per_sec=2000, burstable; +drop resource group rg1; +SET GLOBAL tidb_enable_resource_control='off'; + +create table finish_mark (id int PRIMARY KEY); + diff --git a/tests/integration_tests/resourcecontrol/run.sh b/tests/integration_tests/resourcecontrol/run.sh new file mode 100644 index 00000000000..8dbec3abb86 --- /dev/null +++ b/tests/integration_tests/resourcecontrol/run.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +set -eu + +CUR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +source $CUR/../_utils/test_prepare +WORK_DIR=$OUT_DIR/$TEST_NAME +CDC_BINARY=cdc.test +SINK_TYPE=$1 + +function run() { + rm -rf $WORK_DIR && mkdir -p $WORK_DIR + + start_tidb_cluster --workdir $WORK_DIR + + cd $WORK_DIR + + # record tso before we create tables to skip the system table DDLs + start_ts=$(run_cdc_cli_tso_query ${UP_PD_HOST_1} ${UP_PD_PORT_1}) + + run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY + + TOPIC_NAME="ticdc-resourcecontrol-test-$RANDOM" + case $SINK_TYPE in + kafka) SINK_URI="kafka://127.0.0.1:9092/$TOPIC_NAME?protocol=open-protocol&partition-num=4&kafka-version=${KAFKA_VERSION}&max-message-bytes=10485760" ;; + *) SINK_URI="mysql://normal:123456@127.0.0.1:3306/" ;; + esac + run_cdc_cli changefeed create --start-ts=$start_ts --sink-uri="$SINK_URI" + if [ "$SINK_TYPE" == "kafka" ]; then + run_kafka_consumer $WORK_DIR "kafka://127.0.0.1:9092/$TOPIC_NAME?protocol=open-protocol&partition-num=4&version=${KAFKA_VERSION}&max-message-bytes=10485760" + fi + run_sql_file $CUR/data/prepare.sql ${UP_TIDB_HOST} ${UP_TIDB_PORT} + # sync_diff can't check non-exist table, so we check expected tables are created in downstream first + check_table_exists resourcecontrol.finish_mark ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} + check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml + + cleanup_process $CDC_BINARY +} + +trap stop_tidb_cluster EXIT +run $* +check_logs $WORK_DIR +echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>"