-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
close #5759
- Loading branch information
Showing
10 changed files
with
233 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Master Configuration. | ||
advertise-addr = "127.0.0.1:8261" | ||
auto-compaction-retention = "3s" | ||
master-addr = ":8261" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
join = "127.0.0.1:8261" | ||
name = "worker1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
source-id: mysql-replica-01 | ||
flavor: '' | ||
enable-gtid: true | ||
enable-relay: true | ||
relay-binlog-name: '' | ||
relay-binlog-gtid: '' | ||
from: | ||
host: 127.0.0.1 | ||
user: root | ||
password: /Q7B9DizNLLTTfiZHv9WoEAKamfpIUs= | ||
port: 3306 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
name: test | ||
task-mode: "all" | ||
is-sharding: false | ||
meta-schema: "dm_meta" | ||
# enable-heartbeat: true | ||
heartbeat-update-interval: 1 | ||
heartbeat-report-interval: 1 | ||
clean-dump-file: false | ||
|
||
target-database: | ||
host: "127.0.0.1" | ||
port: 4000 | ||
user: "test" | ||
password: "/Q7B9DizNLLTTfiZHv9WoEAKamfpIUs=" | ||
|
||
mysql-instances: | ||
- source-id: "mysql-replica-01" | ||
block-allow-list: "instance" | ||
mydumper-config-name: "global" | ||
|
||
|
||
block-allow-list: | ||
instance: | ||
do-dbs: ["checktask"] | ||
|
||
mydumpers: | ||
global: | ||
threads: 1 | ||
chunk-filesize: 64 | ||
skip-tz-utc: true | ||
extra-args: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: test # 任务名称,需要全局唯一 | ||
task-mode: all # 任务模式,可设为 "full"、"incremental"、"all" | ||
shard-mode: "pessimistic" | ||
|
||
target-database: # 下游数据库实例配置 | ||
host: "127.0.0.1" | ||
port: 4000 | ||
user: "root" | ||
password: "" # 如果密码不为空,则推荐使用经过 dmctl 加密的密文 | ||
|
||
## ******** 功能配置集 ********** | ||
block-allow-list: # 上游数据库实例匹配的表的 block-allow-list 过滤规则集,如果 DM 版本 <= v2.0.0-beta.2 则使用 black-white-list | ||
bw-rule-1: # 黑白名单配置的名称 | ||
do-dbs: ["checktask"] # 迁移哪些库 | ||
|
||
# ----------- 实例配置 ----------- | ||
mysql-instances: | ||
- source-id: "mysql-replica-01" # 上游实例或者复制组 ID,参考 的 配置 | ||
block-allow-list: "bw-rule-1" # 黑白名单配置名称,如果 DM 版本 <= v2.0.0-beta.2 则使用 black-white-list | ||
route-rules: ["rule1"] | ||
mydumper-config-name: "global" | ||
|
||
routes: | ||
rule1: | ||
schema-pattern: "checktask" | ||
table-pattern: "t*" | ||
target-schema: "checktask" | ||
target-table: "t" | ||
|
||
mydumpers: | ||
global: | ||
threads: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use checktask; | ||
create table t1(c int primary key); | ||
|
||
create table t2(c int primary key, c2 int); | ||
|
||
create table t3(c int primary key, c3 int); | ||
|
||
create table t4(c int primary key, c4 int); | ||
|
||
create table t5(c int primary key, c5 int); | ||
|
||
create table t6(c int primary key, c6 int); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
set -eu | ||
cur=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) | ||
source $cur/../_utils/test_prepare | ||
WORK_DIR=$TEST_DIR/$TEST_NAME | ||
|
||
TABLE_NUM=20 | ||
|
||
function prepare_incompatible_tables() { | ||
run_sql_both_source "drop database if exists checktask" | ||
run_sql_both_source "create database if not exists checktask" | ||
for i in $(seq $TABLE_NUM); do | ||
run_sql_both_source "create table checktask.test${i}(id int, b varchar(10))" # no primary key | ||
done | ||
} | ||
|
||
function prepare_many_tables() { | ||
run_sql_both_source "drop database if exists checktask" | ||
run_sql_both_source "create database if not exists checktask" | ||
run_sql_file $cur/data/db1.prepare.sql $MYSQL_HOST1 $MYSQL_PORT1 $MYSQL_PASSWORD1 | ||
} | ||
|
||
function prepare() { | ||
run_dm_master $WORK_DIR/master $MASTER_PORT $cur/conf/dm-master.toml | ||
check_rpc_alive $cur/../bin/check_master_online 127.0.0.1:$MASTER_PORT | ||
run_dm_worker $WORK_DIR/worker1 $WORKER1_PORT $cur/conf/dm-worker1.toml | ||
check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER1_PORT | ||
dmctl_operate_source create $cur/conf/source1.yaml $SOURCE_ID1 | ||
} | ||
|
||
function test_check_task_fail_no_block() { | ||
prepare_incompatible_tables | ||
run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ | ||
"check-task $cur/conf/task-noshard.yaml" \ | ||
"\"state\": \"fail\"" 1 | ||
} | ||
|
||
function test_check_task_fail_no_block_forsharding() { | ||
prepare_many_tables | ||
run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ | ||
"check-task $cur/conf/task-sharding.yaml" \ | ||
"\"state\": \"fail\"" 1 | ||
} | ||
|
||
function run() { | ||
prepare | ||
test_check_task_fail_no_block | ||
test_check_task_fail_no_block_forsharding | ||
} | ||
|
||
cleanup_data checktask | ||
cleanup_process $* | ||
run $* | ||
cleanup_process $* | ||
cleanup_data checktask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
check_task | ||
validator_basic | ||
drop_column_with_index | ||
downstream_diff_index | ||
|