github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/dm/tests/tracker_ignored_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=$TEST_DIR/$TEST_NAME
     8  
     9  function run() {
    10  	source_cfg=$1
    11  	run_sql_file $cur/data/db.prepare.sql $MYSQL_HOST1 $MYSQL_PORT1 $MYSQL_PASSWORD1
    12  
    13  	run_dm_master $WORK_DIR/master $MASTER_PORT $cur/conf/dm-master.toml
    14  	check_rpc_alive $cur/../bin/check_master_online 127.0.0.1:$MASTER_PORT
    15  	run_dm_worker $WORK_DIR/worker1 $WORKER1_PORT $cur/conf/dm-worker.toml
    16  	check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER1_PORT
    17  	# operate mysql config to worker
    18  	cp $cur/conf/$source_cfg $WORK_DIR/source1.yaml
    19  	dmctl_operate_source create $WORK_DIR/source1.yaml $SOURCE_ID1
    20  
    21  	# start DM task only
    22  	dmctl_start_task_standalone $cur/conf/dm-task.yaml
    23  	# use sync_diff_inspector to check full dump loader
    24  	check_sync_diff $WORK_DIR $cur/conf/diff_config.toml
    25  
    26  	run_sql_file $cur/data/db.increment1.sql $MYSQL_HOST1 $MYSQL_PORT1 $MYSQL_PASSWORD1
    27  	run_sql_tidb "show create table $TEST_NAME.t1;"
    28  	check_not_contains "ignore_1"
    29  	echo "increment1 check success"
    30  
    31  	# a not ignored DDL to trigger a checkpoint flush
    32  	run_sql_source1 "create table tracker_ignored_ddl.test (c int primary key);"
    33  
    34  	# sleep 2 second, so the next insert will trigger check point flush since checkpoint-flush-interval=1
    35  	sleep 2
    36  	run_sql_file $cur/data/db.increment2.sql $MYSQL_HOST1 $MYSQL_PORT1 $MYSQL_PASSWORD1
    37  	run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \
    38  		"query-status test" \
    39  		"Error 1054 (42S22): Unknown column" 1
    40  
    41  	# force a resume, the error is still there, but we want to check https://github.com/pingcap/tiflow/issues/5272#issuecomment-1109283279
    42  	run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
    43  		"resume-task test"
    44  
    45  	# need operate tidb
    46  	run_sql_tidb "alter table $TEST_NAME.t1 add column ignore_1 int;"
    47  
    48  	# resume task
    49  	run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \
    50  		"resume-task test" \
    51  		"\"result\": true" 2
    52  	run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \
    53  		"query-status test" \
    54  		"\"stage\": \"Running\"" 2
    55  
    56  	run_sql_tidb_with_retry "select count(1) from $TEST_NAME.t1;" "count(1): 2"
    57  	echo "increment2 check success"
    58  
    59  	run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
    60  		"stop-relay -s $SOURCE_ID1" \
    61  		"\"result\": true" 1
    62  
    63  	run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \
    64  		"query-status test" \
    65  		"\"stage\": \"Running\"" 1
    66  
    67  	run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
    68  		"stop-task test" \
    69  		"\"result\": true" 2
    70  	dmctl_operate_source stop $WORK_DIR/source1.yaml $SOURCE_ID1
    71  }
    72  
    73  cleanup_data $TEST_NAME
    74  # also cleanup dm processes in case of last run failed
    75  cleanup_process
    76  run source1_gtid.yaml
    77  run source1_pos.yaml
    78  cleanup_process
    79  
    80  echo "[$(date)] <<<<<< test case $TEST_NAME success! >>>>>>"