github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/tests/integration_tests/multi_cdc_cluster/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 mysql sink only in this case
    13  	if [ "$SINK_TYPE" != "mysql" ]; then
    14  		return
    15  	fi
    16  	rm -rf $WORK_DIR && mkdir -p $WORK_DIR
    17  
    18  	start_tidb_cluster --workdir $WORK_DIR
    19  
    20  	cd $WORK_DIR
    21  
    22  	# record tso before we create tables to skip the system table DDLs
    23  	start_ts=$(run_cdc_cli_tso_query ${UP_PD_HOST_1} ${UP_PD_PORT_1})
    24  
    25  	run_sql "CREATE table test.multi_cdc1(id int primary key, val int);"
    26  	run_sql "CREATE table test.multi_cdc2(id int primary key, val int);"
    27  
    28  	# run one cdc cluster
    29  	run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY --cluster-id "test1" --addr "127.0.0.1:8300" --logsuffix mult_cdc.server1
    30  	# run another cdc cluster
    31  	run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY --cluster-id "test2" --addr "127.0.0.1:8301" --logsuffix mult_cdc.server2
    32  
    33  	SINK_URI="mysql://normal:123456@127.0.0.1:3306/"
    34  
    35  	run_cdc_cli changefeed create --start-ts=$start_ts --sink-uri="$SINK_URI" --server "http://127.0.0.1:8300" --config="$CUR/conf/changefeed1.toml"
    36  	run_cdc_cli changefeed create --start-ts=$start_ts --sink-uri="$SINK_URI" --server "http://127.0.0.1:8301" --config="$CUR/conf/changefeed2.toml"
    37  
    38  	# same dml for table multi_cdc1
    39  	run_sql "INSERT INTO test.multi_cdc1(id, val) VALUES (1, 1);"
    40  	run_sql "INSERT INTO test.multi_cdc1(id, val) VALUES (2, 2);"
    41  	run_sql "INSERT INTO test.multi_cdc1(id, val) VALUES (3, 3);"
    42  
    43  	# same dml for table multi_cdc2
    44  	run_sql "INSERT INTO test.multi_cdc2(id, val) VALUES (1, 1);"
    45  	run_sql "INSERT INTO test.multi_cdc2(id, val) VALUES (2, 2);"
    46  	run_sql "INSERT INTO test.multi_cdc2(id, val) VALUES (3, 3);"
    47  
    48  	check_table_exists "test.multi_cdc1" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
    49  	check_table_exists "test.multi_cdc2" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
    50  	check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml
    51  	cleanup_process $CDC_BINARY
    52  }
    53  
    54  trap stop_tidb_cluster EXIT
    55  run $*
    56  check_logs $WORK_DIR
    57  echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>"