Skip to content

Commit

Permalink
test(dm): fix using pgrep to check argument pattern (#6572) (#6584)
Browse files Browse the repository at this point in the history
close #5287, close #5731, close #6526
  • Loading branch information
ti-chi-bot committed Aug 5, 2022
1 parent f71ccf3 commit 99513bd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
6 changes: 6 additions & 0 deletions dm/tests/_utils/test_prepare
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ function cleanup_process() {
wait_process_exit dm-syncer.test
}

function kill_process() {
keyword=$1
ps aux | grep $keyword | grep -v 'grep' | awk '{print $2}' | xargs kill || true
wait_process_exit $keyword
}

function wait_pattern_exit() {
pattern=$1
while true
Expand Down
6 changes: 3 additions & 3 deletions dm/tests/_utils/wait_process_exit
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
process=$1

WAIT_COUNT=0
while [ $WAIT_COUNT -lt 30 ]; do
pgrep $process >/dev/null 2>&1
while [ $WAIT_COUNT -lt 120 ]; do
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"
Expand All @@ -16,5 +16,5 @@ while [ $WAIT_COUNT -lt 30 ]; 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
9 changes: 3 additions & 6 deletions dm/tests/compatibility/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions dm/tests/shardddl1/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,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
Expand Down

0 comments on commit 99513bd

Please sign in to comment.