github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/tests/integration_tests/hang_sink_suicide/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 with mysql sink only
    13  	if [ "$SINK_TYPE" != "mysql" ]; then
    14  		return
    15  	fi
    16  
    17  	rm -rf $WORK_DIR && mkdir -p $WORK_DIR
    18  	start_tidb_cluster --workdir $WORK_DIR
    19  	cd $WORK_DIR
    20  
    21  	pd_addr="http://$UP_PD_HOST_1:$UP_PD_PORT_1"
    22  	export GO_FAILPOINTS='github.com/pingcap/tiflow/cdc/sink/dmlsink/txn/mysql/MySQLSinkHangLongTime=2*return(true)'
    23  	run_cdc_server --workdir $WORK_DIR --binary $CDC_BINARY --pd $pd_addr --logsuffix 1 --addr "127.0.0.1:8300"
    24  
    25  	SINK_URI="mysql://normal:123456@127.0.0.1:3306/?max-txn-row=1"
    26  	changefeed_id=test
    27  	cdc cli changefeed create -c $changefeed_id --config $CUR/conf/changefeed.toml --pd=$pd_addr --sink-uri="$SINK_URI"
    28  
    29  	run_sql "CREATE DATABASE hang_sink_suicide;" ${UP_TIDB_HOST} ${UP_TIDB_PORT}
    30  	run_sql "CREATE table hang_sink_suicide.t1 (id int primary key auto_increment)" ${UP_TIDB_HOST} ${UP_TIDB_PORT}
    31  	run_sql "CREATE table hang_sink_suicide.t2 (id int primary key auto_increment)" ${UP_TIDB_HOST} ${UP_TIDB_PORT}
    32  	check_table_exists "hang_sink_suicide.t1" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
    33  	check_table_exists "hang_sink_suicide.t2" ${DOWN_TIDB_HOST} ${DOWN_TIDB_PORT}
    34  
    35  	run_sql "insert into hang_sink_suicide.t1 values (),(),(),(),()"
    36  	run_sql "insert into hang_sink_suicide.t2 values (),(),(),(),()"
    37  
    38  	check_sync_diff $WORK_DIR $CUR/conf/diff_config.toml
    39  	export GO_FAILPOINTS=''
    40  	cleanup_process $CDC_BINARY
    41  }
    42  
    43  trap stop_tidb_cluster EXIT
    44  # TODO: update the case to use kafka sink instead of mysql sink.
    45  # run $*
    46  # check_logs $WORK_DIR
    47  echo "[$(date)] <<<<<< run test case $TEST_NAME success! >>>>>>"