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
4 changes: 2 additions & 2 deletions tests/tiup/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ function exec_full_stage() {
exec_sql mariadb2 3306 "INSERT INTO $DB2.$TBL3 (c1, c2) VALUES (12, '12');"

# prepare optimsitic full data
exec_sql mysql1 3306 "CREATE DATABASE $DB3;"
exec_sql mariadb2 3306 "CREATE DATABASE $DB4;"
exec_sql mysql1 3306 "CREATE DATABASE $DB3 CHARACTER SET UTF8MB4 COLLATE utf8mb4_bin;"
exec_sql mariadb2 3306 "CREATE DATABASE $DB4 CHARACTER SET UTF8MB4 COLLATE utf8mb4_bin;"
exec_sql mysql1 3306 "CREATE TABLE $DB3.$TBL1 (c1 INT PRIMARY KEY, c2 TEXT);"
exec_sql mysql1 3306 "CREATE TABLE $DB3.$TBL2 (c1 INT PRIMARY KEY, c2 TEXT);"
exec_sql mariadb2 3306 "CREATE TABLE $DB4.$TBL2 (c1 INT PRIMARY KEY, c2 TEXT);"
Expand Down