From e18876187ce76fd69118728206b89c7007752ea7 Mon Sep 17 00:00:00 2001 From: Hou Tao Date: Fri, 4 Jan 2019 16:19:26 +0800 Subject: [PATCH] generic/131: wait until the server is ready or timeout When running xfstests under KVM VM and the load of host is high, only delaying 1s and checking the readiness of server are not enough, and the test case will fail early. Fix it by repeatedly checking the readiness signal until it's found, or timeout is triggered. [Eryu: check if lock server died or not, like v1 patch did] Signed-off-by: Hou Tao Reviewed-by: Eryu Guan Signed-off-by: Eryu Guan --- tests/generic/131 | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/generic/131 b/tests/generic/131 index d7c146ae..c7bac3bc 100755 --- a/tests/generic/131 +++ b/tests/generic/131 @@ -37,10 +37,25 @@ TESTFILE=$TEST_DIR/lock_file src/locktest $TESTFILE 2>&1 > $TEST_DIR/server.out & locktest_pid1=$! -sleep 1 +timeout=30 +while [ $timeout -gt 0 ]; do + sleep 1 -PORT=$(cat $TEST_DIR/server.out | grep "^server port: " | awk '{print $3}') -if [ -z $PORT ]; then + PORT=$(cat $TEST_DIR/server.out | grep "^server port: " | awk '{print $3}') + if [ -n "$PORT" ]; then + break + fi + + # check the existence of server process + if ! kill -s 0 $locktest_pid1 >/dev/null 2>&1; then + echo "Server died abnormally" + exit 1 + fi + + let timeout=timeout-1 +done + +if [ -z "$PORT" ]; then echo "Could not get server port" exit 1 fi -- 2.39.5