github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/tests/integration_tests/bdr_mode/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  	# BDR mode only supports mysql sink
    13  	if [ "$SINK_TYPE" != "mysql" ]; then
    14  		return
    15  	fi
    16  
    17  	rm -rf $WORK_DIR && mkdir -p $WORK_DIR
    18  
    19  	start_tidb_cluster --workdir $WORK_DIR
    20  
    21  	cd $WORK_DIR
    22  
    23  	# cdc server 1
    24  	run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY
    25  	# cdc server 2
    26  	run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY --addr "127.0.0.1:8400" --pd "http://${DOWN_PD_HOST}:${DOWN_PD_PORT}" --logsuffix "down"
    27  	# down
    28  	SINK_URI_1="mysql://root@127.0.0.1:3306"
    29  	# up
    30  	SINK_URI_2="mysql://root@127.0.0.1:4000"
    31  
    32  	# up -> down
    33  	run_cdc_cli changefeed create --sink-uri="$SINK_URI_1" -c "test-1" --config="$CUR/conf/up.toml"
    34  	# down -> up
    35  	run_cdc_cli changefeed create --sink-uri="$SINK_URI_2" -c "test-2" --server "http://127.0.0.1:8400" --config="$CUR/conf/down.toml"
    36  
    37  	run_sql_file $CUR/data/up.sql ${UP_TIDB_HOST} ${UP_TIDB_PORT}
    38  	run_sql_file $CUR/data/down.sql ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
    39  
    40  	run_sql_file $CUR/data/finished.sql ${UP_TIDB_HOST} ${UP_TIDB_PORT}
    41  
    42  	# syncpoint table should exists in secondary tidb, but does not exists in primary cluster
    43  	check_table_exists "tidb_cdc.syncpoint_v1" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT} 60
    44  	check_table_not_exists "tidb_cdc.syncpoint_v1" ${UP_TIDB_HOST} ${UP_TIDB_PORT} 60
    45  
    46  	check_table_exists "bdr_mode.finish_mark" ${UP_TIDB_HOST} ${UP_TIDB_PORT} 60
    47  
    48  	check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml
    49  
    50  	cleanup_process $CDC_BINARY
    51  }
    52  
    53  trap stop_tidb_cluster EXIT
    54  run $*
    55  check_logs $WORK_DIR
    56  echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>"