Skip to content

Commit

Permalink
tests: add check pd alive timeout (#3012)
Browse files Browse the repository at this point in the history
  • Loading branch information
amyangfei authored Oct 14, 2021
1 parent b7c783f commit 075df0f
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion tests/_utils/start_tidb_cluster_impl
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,52 @@ pd-server \
--log-file "$OUT_DIR/down_pd.log" \
--data-dir "$OUT_DIR/down_pd" &

# wait until PD is online...
# wait until upstream PD is online...
echo "Verifying upstream PD is started..."
for idx in $(seq 1 $pd_count); do
host="UP_PD_HOST_$idx"
port="UP_PD_PORT_$idx"

i=0
while ! curl -o /dev/null -sf http://${!host}:${!port}/pd/api/v1/version; do
i=$((i + 1))
if [ "$i" -gt 60 ]; then
echo 'Failed to start upstream PD'
exit 1
fi
sleep 1
done

i=0
while [ -z "$(curl http://${!host}:${!port}/pd/health 2>/dev/null | grep 'health' | grep 'true')" ]; do
i=$((i + 1))
if [ "$i" -gt 60 ]; then
echo 'Failed to start upstream PD'
exit 1
fi
sleep 1
done
done

# wait until downstream PD is online...
echo "Verifying downstream PD is started..."
i=0
while ! curl -o /dev/null -sf http://${DOWN_PD_HOST}:${DOWN_PD_PORT}/pd/api/v1/version; do
i=$((i + 1))
if [ "$i" -gt 60 ]; then
echo 'Failed to start downstream PD'
exit 1
fi
sleep 1
done

i=0
while [ -z "$(curl http://${DOWN_PD_HOST}:${DOWN_PD_PORT}/pd/health 2>/dev/null | grep 'health' | grep 'true')" ]; do
i=$((i + 1))
if [ "$i" -gt 60 ]; then
echo 'Failed to start downstream PD'
exit 1
fi
sleep 1
done

Expand Down

0 comments on commit 075df0f

Please sign in to comment.