github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/dm/tests/async_checkpoint_flush/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 TASK_NAME="test" 9 SQL_RESULT_FILE="$TEST_DIR/sql_res.$TEST_NAME.txt" 10 11 function run_sql_silent() { 12 TIDB_PORT=4000 13 user="root" 14 if [[ "$2" = $TIDB_PORT ]]; then 15 user="test" 16 fi 17 mysql -u$user -h127.0.0.1 -P$2 -p$3 --default-character-set utf8 -E -e "$1" >>/dev/null 18 } 19 20 function insert_data() { 21 i=1 22 23 while true; do 24 run_sql_silent "insert into async_checkpoint_flush.t1 values ($(($i * 2 + 1)));" $MYSQL_PORT1 $MYSQL_PASSWORD1 25 ((i++)) 26 done 27 } 28 29 function run() { 30 export GO_FAILPOINTS="github.com/pingcap/tiflow/dm/syncer/AsyncCheckpointFlushThrowError=return(true)" 31 32 run_sql_file $cur/data/db1.prepare.sql $MYSQL_HOST1 $MYSQL_PORT1 $MYSQL_PASSWORD1 33 check_contains 'Query OK, 1 row affected' 34 35 # run dm master 36 run_dm_master $WORK_DIR/master $MASTER_PORT $cur/conf/dm-master.toml 37 check_rpc_alive $cur/../bin/check_master_online 127.0.0.1:$MASTER_PORT 38 check_metric $MASTER_PORT 'start_leader_counter' 3 0 2 39 40 # copy config file 41 cp $cur/conf/source1.yaml $WORK_DIR/source1.yaml 42 sed -i "/relay-binlog-name/i\relay-dir: $WORK_DIR/worker1/relay_log" $WORK_DIR/source1.yaml 43 44 # bound source1 to worker1, source2 to worker2 45 run_dm_worker $WORK_DIR/worker1 $WORKER1_PORT $cur/conf/dm-worker1.toml 46 check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER1_PORT 47 dmctl_operate_source create $WORK_DIR/source1.yaml $SOURCE_ID1 48 49 # check dm-workers metrics unit: relay file index must be 1. 50 check_metric $WORKER1_PORT "dm_relay_binlog_file" 3 0 2 51 52 # start a task in all mode, and when enter incremental mode, we only execute DML 53 dmctl_start_task_standalone $cur/conf/dm-task.yaml 54 55 # check task has started state=2 running 56 check_metric $WORKER1_PORT "dm_worker_task_state{source_id=\"mysql-replica-01\",task=\"$TASK_NAME\",worker=\"worker1\"}" 10 1 3 57 58 # check diff 59 check_sync_diff $WORK_DIR $cur/conf/diff_config.toml 60 61 insert_data & 62 pid=$! 63 echo "PID of insert_data is $pid" 64 65 sleep 30 66 67 kill $pid 68 check_log_contain_with_retry 'async flush checkpoint snapshot failed, ignore this error' $WORK_DIR/worker1/log/dm-worker.log 69 check_log_contain_with_retry 'sync flush checkpoint snapshot successfully' $WORK_DIR/worker1/log/dm-worker.log 70 check_sync_diff $WORK_DIR $cur/conf/diff_config.toml 71 export GO_FAILPOINTS="" 72 } 73 74 cleanup_data $TEST_NAME 75 # also cleanup dm processes in case of last run failed 76 cleanup_process $* 77 run $* 78 cleanup_process $* 79 80 echo "[$(date)] <<<<<< test case $TEST_NAME success! >>>>>>"