Skip to content

Commit

Permalink
test(dm): inject error to a not-auto-resume source (#6624) (#6657)
Browse files Browse the repository at this point in the history
close #6618
  • Loading branch information
ti-chi-bot authored Aug 9, 2022
1 parent afcedf2 commit 84c1531
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions dm/tests/shardddl2/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,9 @@ function DM_DROP_COLUMN_EXEC_ERROR() {
}

function DM_DROP_COLUMN_ALL_DONE_CASE() {
# get worker of source1
# get worker of source2
w="1"
got=$(grep -a "mysql-replica-01" $WORK_DIR/worker1/log/dm-worker.log | wc -l)
got=$(grep -a "mysql-replica-02" $WORK_DIR/worker1/log/dm-worker.log | wc -l)
if [[ "$got" -eq 0 ]]; then
w="2"
fi
Expand All @@ -317,40 +317,32 @@ function DM_DROP_COLUMN_ALL_DONE_CASE() {

run_sql_source1 "insert into ${shardddl1}.${tb1} values(1,'aaa');"
run_sql_source2 "insert into ${shardddl1}.${tb1} values(2,'bbb');"
run_sql_source2 "insert into ${shardddl1}.${tb2} values(3,'ccc');"

run_sql_source2 "alter table ${shardddl1}.${tb1} drop column b;"
run_sql_source1 "alter table ${shardddl1}.${tb1} drop column b;"
check_log_contain_with_retry 'finish to handle ddls in optimistic shard mode.*tb1 drop column' \
$WORK_DIR/worker1/log/dm-worker.log $WORK_DIR/worker2/log/dm-worker.log

run_sql_source1 "alter table ${shardddl1}.${tb1} drop column b;"
run_sql_source2 "alter table ${shardddl1}.${tb1} drop column b;"
run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"query-status test" \
"execute .* error" 1

run_sql_source2 "alter table ${shardddl1}.${tb2} drop column b;"
check_log_contain_with_retry 'finish to handle ddls in optimistic shard mode.*tb2 drop column' \
$WORK_DIR/worker1/log/dm-worker.log $WORK_DIR/worker2/log/dm-worker.log

restart_master

run_sql_source1 "insert into ${shardddl1}.${tb1} values(4);"
run_sql_source2 "insert into ${shardddl1}.${tb1} values(5);"
run_sql_source2 "insert into ${shardddl1}.${tb2} values(6);"

run_sql_source2 "alter table ${shardddl1}.${tb1} add column b varchar(10);"
run_sql_source1 "alter table ${shardddl1}.${tb1} add column b varchar(10);"
run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"query-status test" \
"because schema conflict detected" 1 \
"add column b that wasn't fully dropped in downstream" 1

restart_worker $w ""
run_sql_source2 "alter table ${shardddl1}.${tb2} add column b varchar(10);"
run_sql_source1 "alter table ${shardddl1}.${tb1} add column b varchar(10);"
run_sql_source2 "alter table ${shardddl1}.${tb1} add column b varchar(10);"

run_sql_source1 "insert into ${shardddl1}.${tb1} values(7,'ddd');"
run_sql_source2 "insert into ${shardddl1}.${tb1} values(8,'eee');"
run_sql_source2 "insert into ${shardddl1}.${tb2} values(9,'fff');"

run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \
"query-status test" \
Expand All @@ -361,8 +353,7 @@ function DM_DROP_COLUMN_ALL_DONE_CASE() {
function DM_DROP_COLUMN_ALL_DONE() {
run_case DROP_COLUMN_ALL_DONE "double-source-optimistic" \
"run_sql_source1 \"create table ${shardddl1}.${tb1} (a int primary key, b varchar(10));\"; \
run_sql_source2 \"create table ${shardddl1}.${tb1} (a int primary key, b varchar(10));\"; \
run_sql_source2 \"create table ${shardddl1}.${tb2} (a int primary key, b varchar(10));\"" \
run_sql_source2 \"create table ${shardddl1}.${tb1} (a int primary key, b varchar(10));\"" \
"clean_table" "optimistic"
}

Expand Down

0 comments on commit 84c1531

Please sign in to comment.