public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: Eryu Guan <guaneryu@gmail.com>
To: Hou Tao <houtao1@huawei.com>
Cc: fstests@vger.kernel.org
Subject: Re: [PATCH 3/5] generic/131: wait until the server is ready
Date: Sat, 29 Dec 2018 16:14:30 +0800	[thread overview]
Message-ID: <20181229081430.GG21777@desktop> (raw)
In-Reply-To: <20181229023452.28074-4-houtao1@huawei.com>

On Sat, Dec 29, 2018 at 10:34:50AM +0800, Hou Tao wrote:
> 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 the server exits.
> 
> Signed-off-by: Hou Tao <houtao1@huawei.com>
> ---
>  tests/generic/131 | 19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)
> 
> diff --git a/tests/generic/131 b/tests/generic/131
> index d7c146ae..1af86e77 100755
> --- a/tests/generic/131
> +++ b/tests/generic/131
> @@ -37,13 +37,20 @@ TESTFILE=$TEST_DIR/lock_file
>  src/locktest $TESTFILE 2>&1 > $TEST_DIR/server.out &
>  locktest_pid1=$!
>  
> -sleep 1
> +while true; do
> +	sleep 1

Looks like we'll loop forever if the locktest process is there but fails
to print out the server port due to random reasons.

I think it's better to retry N times and give up if the server is still
not ready.

Thanks,
Eryu

>  
> -PORT=$(cat $TEST_DIR/server.out | grep "^server port: " | awk '{print $3}')
> -if [ -z $PORT ]; then
> -	echo "Could not get server port"
> -	exit 1
> -fi
> +	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 "Could not get server port"
> +		exit 1
> +	fi
> +done
>  
>  # Start the client
>  src/locktest -p $PORT -h localhost $TESTFILE 2>&1 > $TEST_DIR/client.out
> -- 
> 2.16.2.dirty
> 

  reply	other threads:[~2018-12-29  8:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-29  2:34 [PATCH 0/5] tiny fixes for xfstests Hou Tao
2018-12-29  2:34 ` [PATCH 1/5] check: use _try_scratch_mount instead of _scratch_mount to mount SCRATCH_DEV Hou Tao
2018-12-29  2:34 ` [PATCH 2/5] generic/019: check scratch device is a block device or not Hou Tao
2018-12-29  2:34 ` [PATCH 3/5] generic/131: wait until the server is ready Hou Tao
2018-12-29  8:14   ` Eryu Guan [this message]
2019-01-04  8:56     ` Hou Tao
2018-12-29  2:34 ` [PATCH 4/5] generic/466: explicitly request $SCRATCH_DEV to be a block device Hou Tao
2018-12-29  2:34 ` [PATCH 5/5] fsx: check ENOSYS in test_copy_range() Hou Tao
2018-12-29  8:16   ` Eryu Guan
2018-12-29 18:56     ` Darrick J. Wong
2019-01-04  8:57       ` Hou Tao
2018-12-29 18:53   ` Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181229081430.GG21777@desktop \
    --to=guaneryu@gmail.com \
    --cc=fstests@vger.kernel.org \
    --cc=houtao1@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox