From 4e8b508a4c3679a0a00b9908255cf98dcc6c64be Mon Sep 17 00:00:00 2001 From: lance6716 Date: Tue, 2 Aug 2022 14:33:00 +0800 Subject: [PATCH 1/8] test(dm): fix using pgrep to check argument pattern Signed-off-by: lance6716 --- dm/tests/_utils/wait_process_exit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dm/tests/_utils/wait_process_exit b/dm/tests/_utils/wait_process_exit index 42e3f048d4b..6eff24d3408 100755 --- a/dm/tests/_utils/wait_process_exit +++ b/dm/tests/_utils/wait_process_exit @@ -5,7 +5,7 @@ process=$1 WAIT_COUNT=0 while [ $WAIT_COUNT -lt 120 ]; do - pgrep $process >/dev/null 2>&1 + pgrep -f $process >/dev/null 2>&1 ret=$? if [ "$ret" != "0" ]; then echo "process $process already exit" From 3fb24671cc78ec9c087c730e4934bd92fc62b6f7 Mon Sep 17 00:00:00 2001 From: lance6716 Date: Tue, 2 Aug 2022 16:01:24 +0800 Subject: [PATCH 2/8] fix the script itself will interfere Signed-off-by: lance6716 --- dm/tests/_utils/wait_process_exit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dm/tests/_utils/wait_process_exit b/dm/tests/_utils/wait_process_exit index 6eff24d3408..7e57654002d 100755 --- a/dm/tests/_utils/wait_process_exit +++ b/dm/tests/_utils/wait_process_exit @@ -5,7 +5,7 @@ process=$1 WAIT_COUNT=0 while [ $WAIT_COUNT -lt 120 ]; do - pgrep -f $process >/dev/null 2>&1 + ps aux | grep $process | grep -v 'wait_process_exit' >/dev/null 2>&1 ret=$? if [ "$ret" != "0" ]; then echo "process $process already exit" From 56cff201f0e40b037bc048616a5c0eb13d886895 Mon Sep 17 00:00:00 2001 From: lance6716 Date: Tue, 2 Aug 2022 16:22:50 +0800 Subject: [PATCH 3/8] fix forget filter grep itself Signed-off-by: lance6716 --- dm/tests/_utils/wait_process_exit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dm/tests/_utils/wait_process_exit b/dm/tests/_utils/wait_process_exit index 7e57654002d..394fc3ffd70 100755 --- a/dm/tests/_utils/wait_process_exit +++ b/dm/tests/_utils/wait_process_exit @@ -5,7 +5,7 @@ process=$1 WAIT_COUNT=0 while [ $WAIT_COUNT -lt 120 ]; do - ps aux | grep $process | grep -v 'wait_process_exit' >/dev/null 2>&1 + ps aux | grep $process | grep -v 'grep' | grep -v 'wait_process_exit' >/dev/null 2>&1 ret=$? if [ "$ret" != "0" ]; then echo "process $process already exit" From 67b0ecc66b8ef3f77be931c7119253abd3b89ac7 Mon Sep 17 00:00:00 2001 From: lance6716 Date: Tue, 2 Aug 2022 17:43:52 +0800 Subject: [PATCH 4/8] fix IT Signed-off-by: lance6716 --- dm/tests/_utils/wait_process_exit | 2 +- dm/tests/compatibility/start.sh | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/dm/tests/_utils/wait_process_exit b/dm/tests/_utils/wait_process_exit index 394fc3ffd70..bc0ec81fc0d 100755 --- a/dm/tests/_utils/wait_process_exit +++ b/dm/tests/_utils/wait_process_exit @@ -16,5 +16,5 @@ while [ $WAIT_COUNT -lt 120 ]; do ((WAIT_COUNT++)) done -echo "process $process didn't exit after 120 seconds, current processlist: $(ps aux | grep $process | grep -v 'grep')" +echo "process $process didn't exit after 120 seconds, current processlist: $(ps aux | grep $process | grep -v 'grep' | grep -v 'wait_process_exit')" exit 1 diff --git a/dm/tests/compatibility/start.sh b/dm/tests/compatibility/start.sh index d93fc4250ba..1c25d0cb806 100755 --- a/dm/tests/compatibility/start.sh +++ b/dm/tests/compatibility/start.sh @@ -31,8 +31,7 @@ function run() { # upgrading should firstly upgrade master echo "use current dm-master" - pkill -hup dm-master.test.previous 2>/dev/null || true - wait_process_exit dm-master.test.previous + kill_process dm-master.test.previous run_dm_master $WORK_DIR/master $MASTER_PORT $cur/conf/dm-master.toml current check_rpc_alive $cur/../bin/check_master_online 127.0.0.1:$MASTER_PORT run_sql_file $cur/data/db1.increment.1.sql $MYSQL_HOST1 $MYSQL_PORT1 $MYSQL_PASSWORD1 @@ -42,8 +41,7 @@ function run() { check_sync_diff $WORK_DIR $cur/conf/diff_config.toml echo "restart dm-worker, one use the current version, and the other one use the previous version" - pkill -hup dm-worker.test.previous 2>/dev/null || true - wait_process_exit dm-worker.test.previous + kill_process dm-worker.test.previous run_dm_worker $WORK_DIR/worker1 $WORKER1_PORT $cur/conf/dm-worker1.toml current check_rpc_alive $cur/../bin/check_worker_online 127.0.0.1:$WORKER1_PORT run_dm_worker $WORK_DIR/worker2 $WORKER2_PORT $cur/conf/dm-worker2.toml previous @@ -74,8 +72,7 @@ function run() { check_sync_diff $WORK_DIR $cur/conf/diff_config.toml echo "all dm-worker use current version" - pkill -hup dm-worker.test.previous 2>/dev/null || true - wait_process_exit dm-worker.test.previous + kill_process dm-worker.test.previous run_dm_worker $WORK_DIR/worker2 $WORKER2_PORT $cur/conf/dm-worker2.toml current run_sql_file $cur/data/db1.increment.3.sql $MYSQL_HOST1 $MYSQL_PORT1 $MYSQL_PASSWORD1 From 1a398a369570599efe9cb51bcc04b45df8b06972 Mon Sep 17 00:00:00 2001 From: lance6716 Date: Wed, 3 Aug 2022 11:04:13 +0800 Subject: [PATCH 5/8] fix 2 source order Signed-off-by: lance6716 --- dm/tests/shardddl1/run.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dm/tests/shardddl1/run.sh b/dm/tests/shardddl1/run.sh index 03516e92fde..3b608f4b416 100644 --- a/dm/tests/shardddl1/run.sh +++ b/dm/tests/shardddl1/run.sh @@ -243,6 +243,14 @@ function DM_RestartMaster_CASE() { check_sync_diff $WORK_DIR $cur/conf/diff_config.toml run_sql_source1 "alter table ${shardddl1}.${tb1} add column c double;" + if [[ "$1" = "pessimistic" ]]; then + check_log_contain_with_retry 'putted shard DDL info.*ADD COLUMN' \ + $WORK_DIR/worker1/log/dm-worker.log $WORK_DIR/worker2/log/dm-worker.log + else + check_log_contain_with_retry 'finish to handle ddls in optimistic shard mode.*add column' \ + $WORK_DIR/worker1/log/dm-worker.log $WORK_DIR/worker2/log/dm-worker.log + fi + run_sql_source2 "alter table ${shardddl1}.${tb1} add column c text;" if [[ "$1" = "pessimistic" ]]; then From 1a08b8503d4d4bfd378975fe8f74a3e01d8f800f Mon Sep 17 00:00:00 2001 From: lance6716 Date: Wed, 3 Aug 2022 11:53:30 +0800 Subject: [PATCH 6/8] fix another case caused by 2 source race Signed-off-by: lance6716 --- dm/tests/shardddl2/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dm/tests/shardddl2/run.sh b/dm/tests/shardddl2/run.sh index 76bb2fe7f96..50d9898c309 100644 --- a/dm/tests/shardddl2/run.sh +++ b/dm/tests/shardddl2/run.sh @@ -127,7 +127,7 @@ function DM_040_CASE() { run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \ "query-status test" \ 'ALTER TABLE `shardddl`.`tb` ADD COLUMN `col1` VARCHAR(10) CHARACTER SET UTF8' 1 \ - "\"${SOURCE_ID2}-\`${shardddl1}\`.\`${tb1}\`\"" 1 + "-\`${shardddl1}\`.\`${tb1}\`\"" 1 fi } From e98b9469d094a12ba6b87a1809dc955bbcb5a20a Mon Sep 17 00:00:00 2001 From: lance6716 Date: Fri, 29 Jul 2022 18:57:47 +0800 Subject: [PATCH 7/8] test(dm): fix unstable test due to write relay log too slow Signed-off-by: lance6716 --- dm/tests/duplicate_event/run.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/dm/tests/duplicate_event/run.sh b/dm/tests/duplicate_event/run.sh index 85561e9f559..4274df9bc87 100644 --- a/dm/tests/duplicate_event/run.sh +++ b/dm/tests/duplicate_event/run.sh @@ -73,11 +73,22 @@ function run_with_prepared_source_config() { run_sql_source2 "show master status;" binlog_file=$(grep "File" $TEST_DIR/sql_res.$TEST_NAME.txt | awk -F: '{print $2}' | xargs) binlog_pos=$(grep "Position" $TEST_DIR/sql_res.$TEST_NAME.txt | awk -F: '{print $2}' | xargs) - server_uuid=$(tail -n 1 $WORK_DIR/worker2/relay-dir/server-uuid.index) - relay_log_size=$(ls -al $WORK_DIR/worker2/relay-dir/$server_uuid/$binlog_file | awk '{print $5}') - echo "binlog_pos: $binlog_pos relay_log_size: $relay_log_size" - [ "$binlog_pos" -eq "$relay_log_size" ] + + succ=0 + for ((k = 1; k < 6; k++)); do + relay_log_size=$(ls -al $WORK_DIR/worker2/relay-dir/$server_uuid/$binlog_file | awk '{print $5}') + echo "binlog_pos: $binlog_pos relay_log_size: $relay_log_size" + if [[ "$binlog_pos" -eq "$relay_log_size" ]]; then + succ=1 + break + fi + sleep 1 + done + if [[ $succ -eq 0 ]]; then + echo "binlog_pos is not equal to relay_log_size" + exit 1 + fi echo "============== run_with_prepared_source_config success ===================" } From 45bb14c1d4c5da52a4344e1685ac6d871e952075 Mon Sep 17 00:00:00 2001 From: lance6716 Date: Wed, 3 Aug 2022 12:36:40 +0800 Subject: [PATCH 8/8] Update run.sh --- dm/tests/shardddl2/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dm/tests/shardddl2/run.sh b/dm/tests/shardddl2/run.sh index 50d9898c309..30aa8c326c8 100644 --- a/dm/tests/shardddl2/run.sh +++ b/dm/tests/shardddl2/run.sh @@ -127,7 +127,7 @@ function DM_040_CASE() { run_dm_ctl_with_retry $WORK_DIR "127.0.0.1:$MASTER_PORT" \ "query-status test" \ 'ALTER TABLE `shardddl`.`tb` ADD COLUMN `col1` VARCHAR(10) CHARACTER SET UTF8' 1 \ - "-\`${shardddl1}\`.\`${tb1}\`\"" 1 + "\`${shardddl1}\`.\`${tb1}\`\"" 1 fi }