diff --git a/dm/tests/_utils/test_prepare b/dm/tests/_utils/test_prepare index de838513889..04e3f298fcd 100644 --- a/dm/tests/_utils/test_prepare +++ b/dm/tests/_utils/test_prepare @@ -10,6 +10,13 @@ function cleanup_data() { run_sql "drop database if exists dm_meta" $TIDB_PORT $TIDB_PASSWORD } +function cleanup_data_upstream() { + for target_db in "$@"; do + run_sql "drop database if exists \`${target_db}\`" $MYSQL_PORT1 $MYSQL_PASSWORD1 + run_sql "drop database if exists \`${target_db}\`" $MYSQL_PORT2 $MYSQL_PASSWORD2 + done +} + function cleanup_process() { dm_master_num=$(ps aux >temp && grep "dm-master.test" temp | wc -l && rm temp) echo "$dm_master_num dm-master alive" diff --git a/dm/tests/adjust_gtid/conf/diff_config_revert_1.toml b/dm/tests/adjust_gtid/conf/diff_config_revert_1.toml new file mode 100644 index 00000000000..455ed32451f --- /dev/null +++ b/dm/tests/adjust_gtid/conf/diff_config_revert_1.toml @@ -0,0 +1,31 @@ +# diff Configuration. + +check-thread-count = 4 + +export-fix-sql = true + +check-struct-only = false + + +[task] + output-dir = "/tmp/ticdc_dm_test/output" + + source-instances = ["tidb0"] + + target-instance = "mysql1" + + target-check-tables = ["adjust_gtid.t?*"] + + +[data-sources] +[data-sources.mysql1] +host = "127.0.0.1" +port = 3306 +user = "root" +password = "123456" + +[data-sources.tidb0] +host = "127.0.0.1" +port = 4000 +user = "test" +password = "123456" diff --git a/dm/tests/adjust_gtid/conf/diff_config_revert_2.toml b/dm/tests/adjust_gtid/conf/diff_config_revert_2.toml new file mode 100644 index 00000000000..6d38ad7fb17 --- /dev/null +++ b/dm/tests/adjust_gtid/conf/diff_config_revert_2.toml @@ -0,0 +1,31 @@ +# diff Configuration. + +check-thread-count = 4 + +export-fix-sql = true + +check-struct-only = false + + +[task] + output-dir = "/tmp/ticdc_dm_test/output" + + source-instances = ["tidb0"] + + target-instance = "mysql2" + + target-check-tables = ["adjust_gtid.t?*"] + + +[data-sources] +[data-sources.mysql2] +host = "127.0.0.1" +port = 3307 +user = "root" +password = "123456" + +[data-sources.tidb0] +host = "127.0.0.1" +port = 4000 +user = "test" +password = "123456" diff --git a/dm/tests/adjust_gtid/run.sh b/dm/tests/adjust_gtid/run.sh index 751f2fca8a3..f51a28a6e9d 100755 --- a/dm/tests/adjust_gtid/run.sh +++ b/dm/tests/adjust_gtid/run.sh @@ -84,10 +84,13 @@ function run() { # avoid cannot unmarshal !!str `binlog-...` into uint32 error sed -i "s/binlog-pos-placeholder-1/4/g" $WORK_DIR/dm-task.yaml sed -i "s/binlog-pos-placeholder-2/4/g" $WORK_DIR/dm-task.yaml - dmctl_start_task "$WORK_DIR/dm-task.yaml" "--remove-meta" + # start DM task. don't check error because it will meet injected error soon + run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ + "start-task $WORK_DIR/dm-task.yaml --remove-meta" # use sync_diff_inspector to check full dump loader - check_sync_diff $WORK_DIR $cur/conf/diff_config.toml + check_sync_diff $WORK_DIR $cur/conf/diff_config_revert_1.toml + check_sync_diff $WORK_DIR $cur/conf/diff_config_revert_2.toml name1=$(grep "Log: " $WORK_DIR/worker1/dumped_data.$TASK_NAME/metadata | awk -F: '{print $2}' | tr -d ' ') pos1=$(grep "Pos: " $WORK_DIR/worker1/dumped_data.$TASK_NAME/metadata | awk -F: '{print $2}' | tr -d ' ') @@ -129,7 +132,8 @@ function run() { check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER2_PORT # use sync_diff_inspector to check incremental dump loader - check_sync_diff $WORK_DIR $cur/conf/diff_config.toml + check_sync_diff $WORK_DIR $cur/conf/diff_config_revert_1.toml + check_sync_diff $WORK_DIR $cur/conf/diff_config_revert_2.toml run_sql_both_source "SET @@GLOBAL.SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'" run_sql_both_source "SET @@global.time_zone = 'SYSTEM';" diff --git a/dm/tests/dm_syncer/run.sh b/dm/tests/dm_syncer/run.sh index 1ed98da1d8a..11994fdb95c 100755 --- a/dm/tests/dm_syncer/run.sh +++ b/dm/tests/dm_syncer/run.sh @@ -71,7 +71,7 @@ function run() { run_dm_syncer $WORK_DIR/syncer2 $WORK_DIR/dm-syncer-2.toml $meta_file --syncer-config-format syncer2 # wait for dm_syncer to init and start - sleep 5 + sleep 10 check_sync_diff $WORK_DIR $cur/conf/diff_config.toml check_sync_diff $WORK_DIR $cur/conf/diff_config_blalist.toml check_sync_diff $WORK_DIR $cur/conf/diff_config_route_rules.toml diff --git a/dm/tests/full_mode/conf/diff_config_revert_1.toml b/dm/tests/full_mode/conf/diff_config_revert_1.toml new file mode 100644 index 00000000000..f690ce6e804 --- /dev/null +++ b/dm/tests/full_mode/conf/diff_config_revert_1.toml @@ -0,0 +1,30 @@ +# diff Configuration. + +check-thread-count = 4 + +export-fix-sql = true + +check-struct-only = false + +[task] + output-dir = "/tmp/ticdc_dm_test/output" + + source-instances = ["tidb0"] + + target-instance = "mysql1" + + target-check-tables = ["full_mode.t?*"] + + +[data-sources] +[data-sources.mysql1] +host = "127.0.0.1" +port = 3306 +user = "root" +password = "123456" + +[data-sources.tidb0] +host = "127.0.0.1" +port = 4000 +user = "test" +password = "123456" diff --git a/dm/tests/full_mode/conf/diff_config_revert_2.toml b/dm/tests/full_mode/conf/diff_config_revert_2.toml new file mode 100644 index 00000000000..84a3ecd2d43 --- /dev/null +++ b/dm/tests/full_mode/conf/diff_config_revert_2.toml @@ -0,0 +1,30 @@ +# diff Configuration. + +check-thread-count = 4 + +export-fix-sql = true + +check-struct-only = false + +[task] + output-dir = "/tmp/ticdc_dm_test/output" + + source-instances = ["tidb0"] + + target-instance = "mysql2" + + target-check-tables = ["full_mode.t?*"] + + +[data-sources] +[data-sources.mysql2] +host = "127.0.0.1" +port = 3307 +user = "root" +password = "123456" + +[data-sources.tidb0] +host = "127.0.0.1" +port = 4000 +user = "test" +password = "123456" diff --git a/dm/tests/full_mode/run.sh b/dm/tests/full_mode/run.sh index 714a9e8a610..30a8344eadc 100755 --- a/dm/tests/full_mode/run.sh +++ b/dm/tests/full_mode/run.sh @@ -60,6 +60,7 @@ function fail_acquire_global_lock() { "you need (at least one of) the RELOAD privilege(s) for this operation" 2 cleanup_data full_mode + cleanup_data_upstream full_mode cleanup_process $* } @@ -104,7 +105,6 @@ function escape_schema() { # start DM task only dmctl_start_task "$WORK_DIR/dm-task.yaml" "--remove-meta" - check_sync_diff $WORK_DIR $WORK_DIR/diff_config.toml check_log_contain_with_retry 'clean dump files' $WORK_DIR/worker1/log/dm-worker.log check_log_contain_with_retry 'clean dump files' $WORK_DIR/worker2/log/dm-worker.log @@ -118,6 +118,7 @@ function escape_schema() { check_metric $WORKER2_PORT 'dumpling_dump_finished_tables' 3 0 3 cleanup_data full/mode + cleanup_data_upstream full/mode cleanup_process $* } @@ -130,7 +131,8 @@ function empty_data() { init_cluster dmctl_start_task "$cur/conf/dm-task.yaml" "--remove-meta" - check_sync_diff $WORK_DIR $cur/conf/diff_config.toml + check_sync_diff $WORK_DIR $cur/conf/diff_config_revert_1.toml + check_sync_diff $WORK_DIR $cur/conf/diff_config_revert_2.toml run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ "query-status test" \ @@ -142,6 +144,7 @@ function empty_data() { check_log_contains $WORK_DIR/worker2/log/dm-worker.log "progress=\"100.00 %\"" cleanup_data full_mode + cleanup_data_upstream full_mode cleanup_process $* } @@ -190,7 +193,8 @@ function run() { dmctl_start_task "$cur/conf/dm-task.yaml" "--remove-meta" # use sync_diff_inspector to check full dump loader - check_sync_diff $WORK_DIR $cur/conf/diff_config.toml + check_sync_diff $WORK_DIR $cur/conf/diff_config_revert_1.toml + check_sync_diff $WORK_DIR $cur/conf/diff_config_revert_2.toml echo "check dump files have been cleaned" ls $WORK_DIR/worker1/dumped_data.test && exit 1 || echo "worker1 auto removed dump files" diff --git a/dm/tests/incremental_mode/conf/diff_config_revert_1.toml b/dm/tests/incremental_mode/conf/diff_config_revert_1.toml new file mode 100644 index 00000000000..45328c12217 --- /dev/null +++ b/dm/tests/incremental_mode/conf/diff_config_revert_1.toml @@ -0,0 +1,30 @@ +# diff Configuration. + +check-thread-count = 4 + +export-fix-sql = true + +check-struct-only = false + +[task] + output-dir = "/tmp/ticdc_dm_test/output" + + source-instances = ["tidb0"] + + target-instance = "mysql1" + + target-check-tables = ["incremental_mode.t?*"] + + +[data-sources] +[data-sources.mysql1] +host = "127.0.0.1" +port = 3306 +user = "root" +password = "123456" + +[data-sources.tidb0] +host = "127.0.0.1" +port = 4000 +user = "test" +password = "123456" diff --git a/dm/tests/incremental_mode/conf/diff_config_revert_2.toml b/dm/tests/incremental_mode/conf/diff_config_revert_2.toml new file mode 100644 index 00000000000..16ed402a93f --- /dev/null +++ b/dm/tests/incremental_mode/conf/diff_config_revert_2.toml @@ -0,0 +1,30 @@ +# diff Configuration. + +check-thread-count = 4 + +export-fix-sql = true + +check-struct-only = false + +[task] + output-dir = "/tmp/ticdc_dm_test/output" + + source-instances = ["tidb0"] + + target-instance = "mysql2" + + target-check-tables = ["incremental_mode.t?*"] + + +[data-sources] +[data-sources.mysql2] +host = "127.0.0.1" +port = 3307 +user = "root" +password = "123456" + +[data-sources.tidb0] +host = "127.0.0.1" +port = 4000 +user = "test" +password = "123456" diff --git a/dm/tests/incremental_mode/run.sh b/dm/tests/incremental_mode/run.sh index 40774b7a469..b8b7dbbf171 100755 --- a/dm/tests/incremental_mode/run.sh +++ b/dm/tests/incremental_mode/run.sh @@ -76,7 +76,8 @@ function run() { sed -i "s/binlog-pos-placeholder-2/4/g" $WORK_DIR/dm-task.yaml dmctl_start_task $WORK_DIR/dm-task.yaml - check_sync_diff $WORK_DIR $cur/conf/diff_config.toml + check_sync_diff $WORK_DIR $cur/conf/diff_config_revert_1.toml + check_sync_diff $WORK_DIR $cur/conf/diff_config_revert_2.toml dmctl_stop_task $TASK_NAME @@ -218,7 +219,9 @@ function run() { check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER2_PORT sleep 3 - dmctl_start_task $WORK_DIR/dm-task.yaml + # start DM task. don't check error because it will meet injected error soon + run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ + "start-task $WORK_DIR/dm-task.yaml" # the task should paused by `FlushCheckpointStage` failpont before flush old checkpoint. # `db2.increment.sql` has no DDL, so we check count of content as `1`. @@ -263,7 +266,8 @@ function run() { "resume-task test" \ "\"result\": true" 3 - check_sync_diff $WORK_DIR $cur/conf/diff_config.toml + check_sync_diff $WORK_DIR $cur/conf/diff_config_revert_1.toml + check_sync_diff $WORK_DIR $cur/conf/diff_config_revert_2.toml # test rotate binlog, after rotate and ddl, master binlog should be equal to sync binlog run_sql "flush logs;" $MYSQL_PORT1 $MYSQL_PASSWORD1