Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dm/test: swap upstream and downstream of sync_diff in some cases #3413

Merged
merged 7 commits into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions dm/tests/_utils/test_prepare
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
31 changes: 31 additions & 0 deletions dm/tests/adjust_gtid/conf/diff_config_revert_1.toml
Original file line number Diff line number Diff line change
@@ -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"
31 changes: 31 additions & 0 deletions dm/tests/adjust_gtid/conf/diff_config_revert_2.toml
Original file line number Diff line number Diff line change
@@ -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"
10 changes: 7 additions & 3 deletions dm/tests/adjust_gtid/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Ehco1996 marked this conversation as resolved.
Show resolved Hide resolved
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 ' ')
Expand Down Expand Up @@ -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';"
Expand Down
2 changes: 1 addition & 1 deletion dm/tests/dm_syncer/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

@Ehco1996 Ehco1996 Nov 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in our doc: Syncer is no longer maintained. Its features are completely superseded by TiDB Data Migration. It is strongly recommended that you use TiDB Data Migration instead

just a question: do we have plan to delete the code releated to dm-sycner from our codebase and syncer-bin from tidb-enterprise-tools?

also cc @sunzhaoyang

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
Expand Down
30 changes: 30 additions & 0 deletions dm/tests/full_mode/conf/diff_config_revert_1.toml
Original file line number Diff line number Diff line change
@@ -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"
30 changes: 30 additions & 0 deletions dm/tests/full_mode/conf/diff_config_revert_2.toml
Original file line number Diff line number Diff line change
@@ -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"
10 changes: 7 additions & 3 deletions dm/tests/full_mode/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 $*
}

Expand Down Expand Up @@ -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
Ehco1996 marked this conversation as resolved.
Show resolved Hide resolved

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
Expand All @@ -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 $*
}

Expand All @@ -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" \
Expand All @@ -142,6 +144,7 @@ function empty_data() {
check_log_contains $WORK_DIR/worker2/log/dm-worker.log "progress=\"100.00 %\""

cleanup_data full_mode
lichunzhu marked this conversation as resolved.
Show resolved Hide resolved
cleanup_data_upstream full_mode
cleanup_process $*
}

Expand Down Expand Up @@ -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"
Expand Down
30 changes: 30 additions & 0 deletions dm/tests/incremental_mode/conf/diff_config_revert_1.toml
Original file line number Diff line number Diff line change
@@ -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"
30 changes: 30 additions & 0 deletions dm/tests/incremental_mode/conf/diff_config_revert_2.toml
Original file line number Diff line number Diff line change
@@ -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"
10 changes: 7 additions & 3 deletions dm/tests/incremental_mode/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -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
Expand Down