github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/dm/tests/compatibility/start.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  	run_sql_both_source "SET @@GLOBAL.SQL_MODE='NO_AUTO_VALUE_ON_ZERO'"
    11  	run_sql_file $cur/data/db1.prepare.sql $MYSQL_HOST1 $MYSQL_PORT1 $MYSQL_PASSWORD1
    12  	check_contains 'Query OK, 2 rows affected'
    13  	run_sql_file $cur/data/db2.prepare.sql $MYSQL_HOST2 $MYSQL_PORT2 $MYSQL_PASSWORD2
    14  	check_contains 'Query OK, 3 rows affected'
    15  
    16  	echo "use previous dm-master and dm-worker"
    17  	run_dm_master $WORK_DIR/master $MASTER_PORT $cur/conf/dm-master.toml previous
    18  	check_rpc_alive $cur/../bin/check_master_online 127.0.0.1:$MASTER_PORT
    19  	run_dm_worker $WORK_DIR/worker1 $WORKER1_PORT $cur/conf/dm-worker1.toml previous
    20  	check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER1_PORT
    21  	run_dm_worker $WORK_DIR/worker2 $WORKER2_PORT $cur/conf/dm-worker2.toml previous
    22  	check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER2_PORT
    23  	dmctl_operate_source create $cur/conf/source1.yaml $SOURCE_ID1
    24  	dmctl_operate_source create $cur/conf/source2.yaml $SOURCE_ID2
    25  
    26  	echo "start DM task only"
    27  	dmctl_start_task
    28  
    29  	echo "use sync_diff_inspector to check full dump loader"
    30  	check_sync_diff $WORK_DIR $cur/conf/diff_config.toml
    31  
    32  	# upgrading should firstly upgrade master
    33  	echo "use current dm-master"
    34  	kill_process dm-master.test.previous
    35  	run_dm_master $WORK_DIR/master $MASTER_PORT $cur/conf/dm-master.toml current
    36  	check_rpc_alive $cur/../bin/check_master_online 127.0.0.1:$MASTER_PORT
    37  	run_sql_file $cur/data/db1.increment.1.sql $MYSQL_HOST1 $MYSQL_PORT1 $MYSQL_PASSWORD1
    38  	run_sql_file $cur/data/db2.increment.1.sql $MYSQL_HOST2 $MYSQL_PORT2 $MYSQL_PASSWORD2
    39  
    40  	echo "use sync_diff_inspector to check increment data first time"
    41  	check_sync_diff $WORK_DIR $cur/conf/diff_config.toml
    42  
    43  	echo "restart dm-worker, one use the current version, and the other one use the previous version"
    44  	kill_process dm-worker.test.previous
    45  	run_dm_worker $WORK_DIR/worker1 $WORKER1_PORT $cur/conf/dm-worker1.toml current
    46  	check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER1_PORT
    47  	run_dm_worker $WORK_DIR/worker2 $WORKER2_PORT $cur/conf/dm-worker2.toml previous
    48  	check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER2_PORT
    49  
    50  	echo "pause task and check status"
    51  	run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
    52  		"pause-task test" \
    53  		"\"result\": true" 3
    54  
    55  	run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
    56  		"query-status test" \
    57  		"\"stage\": \"Paused\"" 2
    58  
    59  	run_sql_file $cur/data/db1.increment.2.sql $MYSQL_HOST1 $MYSQL_PORT1 $MYSQL_PASSWORD1
    60  	run_sql_file $cur/data/db2.increment.2.sql $MYSQL_HOST2 $MYSQL_PORT2 $MYSQL_PASSWORD2
    61  
    62  	echo "resume task and check status"
    63  	run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \
    64  		"resume-task test" \
    65  		"\"result\": true" 3
    66  
    67  	run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \
    68  		"query-status test" \
    69  		"\"stage\": \"Running\"" 3
    70  
    71  	echo "use sync_diff_inspector to check data second time"
    72  	check_sync_diff $WORK_DIR $cur/conf/diff_config.toml
    73  
    74  	echo "all dm-worker use current version"
    75  	kill_process dm-worker.test.previous
    76  	run_dm_worker $WORK_DIR/worker2 $WORKER2_PORT $cur/conf/dm-worker2.toml current
    77  
    78  	run_sql_file $cur/data/db1.increment.3.sql $MYSQL_HOST1 $MYSQL_PORT1 $MYSQL_PASSWORD1
    79  	run_sql_file $cur/data/db2.increment.3.sql $MYSQL_HOST2 $MYSQL_PORT2 $MYSQL_PASSWORD2
    80  
    81  	echo "use sync_diff_inspector to check data third time"
    82  	check_sync_diff $WORK_DIR $cur/conf/diff_config.toml
    83  }
    84  
    85  cleanup_data compatibility
    86  # also cleanup dm processes in case of last run failed
    87  cleanup_process $*
    88  run $*
    89  cleanup_process $*
    90  
    91  echo "[$(date)] <<<<<< test case $TEST_NAME success! >>>>>>"