Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

test: try fix etcd error in CI #1773

Merged
merged 13 commits into from
Jun 23, 2021
3 changes: 2 additions & 1 deletion tests/_utils/shardddl_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ function clean_table() {

function restart_master() {
echo "restart dm-master"
wait_process_exit dm-master.test
ps aux | grep dm-master | awk '{print $2}' | xargs kill || true
check_port_offline $MASTER_PORT 20
sleep 2

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
Expand Down
27 changes: 9 additions & 18 deletions tests/_utils/wait_process_exit
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
#!/bin/bash
# parameter 1: process name
process=$1

PID=$(pgrep $process)
if [ -z "$PID" ]; then
echo "process $process already exit"
exit
fi

WAIT_COUNT=10
KILL_TIMES=1 # make sure only send kill -9 once.
count=0
process=$1

while true; do
WAIT_COUNT=0
while [ $WAIT_COUNT -lt 30 ]; do
pgrep $process >/dev/null 2>&1
ret=$?
if [ "$ret" != "0" ]; then
echo "process $process already exit"
break
exit 0
fi
sleep 0.2
((count++))
sleep 1
echo "wait process $process exit..."
if [ $count -gt $WAIT_COUNT ] && [ $KILL_TIMES -lt 2 ]; then
((KILL_TIMES++))
kill -9 $PID || true
fi
((WAIT_COUNT++))
done

echo "process $process didn't exit after 30 seconds"
exit 1