github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/tests/integration_tests/csv_storage_multi_tables_ddl/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  	# Now, we run the storage tests in mysql sink tests.
    13  	# It's a temporary solution, we will move it to a new test pipeline later.
    14  	if [ "$SINK_TYPE" != "storage" ]; then
    15  		return
    16  	fi
    17  
    18  	rm -rf $WORK_DIR && mkdir -p $WORK_DIR
    19  	start_tidb_cluster --workdir $WORK_DIR
    20  	cd $WORK_DIR
    21  
    22  	# record tso before we create tables to skip the system table DDLs
    23  	start_ts=$(cdc cli tso query --pd=http://$UP_PD_HOST_1:$UP_PD_PORT_1)
    24  
    25  	run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY
    26  
    27  	TOPIC_NAME_1="ticdc-multi-tables-ddl-test-normal-$RANDOM"
    28  	TOPIC_NAME_2="ticdc-multi-tables-ddl-test-error-1-$RANDOM"
    29  	TOPIC_NAME_3="ticdc-multi-tables-ddl-test-error-2-$RANDOM"
    30  
    31  	cf_normal="test-normal"
    32  	cf_err1="test-error-1"
    33  	cf_err2="test-error-2"
    34  
    35  	SINK_URI1="file://$WORK_DIR/storage_test/$TOPIC_NAME_1?flush-interval=5s&protocol=csv"
    36  	cdc cli changefeed create -c=$cf_normal --start-ts=$start_ts --sink-uri="$SINK_URI1" --config="$CUR/conf/normal.toml"
    37  
    38  	SINK_URI2="file://$WORK_DIR/storage_test/$TOPIC_NAME_2?flush-interval=5s&protocol=csv"
    39  	cdc cli changefeed create -c=$cf_err1 --start-ts=$start_ts --sink-uri="$SINK_URI2" --config="$CUR/conf/error-1.toml"
    40  
    41  	SINK_URI3="file://$WORK_DIR/storage_test/$TOPIC_NAME_3?flush-interval=5s&protocol=csv"
    42  	cdc cli changefeed create -c=$cf_err2 --start-ts=$start_ts --sink-uri="$SINK_URI3" --config="$CUR/conf/error-2.toml"
    43  	run_storage_consumer $WORK_DIR $SINK_URI1 "$CUR/conf/normal.toml" 1
    44  	run_storage_consumer $WORK_DIR $SINK_URI2 "$CUR/conf/error-1.toml" 2
    45  	run_storage_consumer $WORK_DIR $SINK_URI3 "$CUR/conf/error-2.toml" 3
    46  
    47  	run_sql_file $CUR/data/test.sql ${UP_TIDB_HOST} ${UP_TIDB_PORT}
    48  	check_table_exists multi_tables_ddl_test.t55 ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
    49  	check_table_exists multi_tables_ddl_test.t66 ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
    50  	check_table_exists multi_tables_ddl_test.t7 ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
    51  	check_table_exists multi_tables_ddl_test.t88 ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
    52  	# sync_diff can't check non-exist table, so we check expected tables are created in downstream first
    53  	check_table_exists multi_tables_ddl_test.finish_mark ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
    54  	echo "check table exists success"
    55  
    56  	# changefeed test-error will not report an error, "multi_tables_ddl_test.t555 to multi_tables_ddl_test.t55" patr will be skipped.
    57  	run_sql "rename table multi_tables_ddl_test.t7 to multi_tables_ddl_test.t77, multi_tables_ddl_test.t555 to multi_tables_ddl_test.t55;" ${UP_TIDB_HOST} ${UP_TIDB_PORT}
    58  
    59  	check_changefeed_state "http://${UP_PD_HOST_1}:${UP_PD_PORT_1}" $cf_normal "normal" "null" ""
    60  	check_changefeed_state "http://${UP_PD_HOST_1}:${UP_PD_PORT_1}" $cf_err1 "normal" "null" ""
    61  	check_changefeed_state "http://${UP_PD_HOST_1}:${UP_PD_PORT_1}" $cf_err2 "failed" "ErrSyncRenameTableFailed" ""
    62  
    63  	check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml 100
    64  
    65  	cleanup_process $CDC_BINARY
    66  }
    67  
    68  trap stop_tidb_cluster EXIT
    69  run $*
    70  check_logs $WORK_DIR
    71  echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>"