From: Luke Diamand <luke@diamand.org>
To: larsxschneider@gmail.com, git@vger.kernel.org
Cc: sunshine@sunshineco.com, gitster@pobox.com
Subject: Re: [PATCH v5 3/6] git-p4: retry kill/cleanup operations in tests with timeout
Date: Mon, 16 Nov 2015 08:36:31 +0000 [thread overview]
Message-ID: <5649958F.2010407@diamand.org> (raw)
In-Reply-To: <1447592920-89228-4-git-send-email-larsxschneider@gmail.com>
On 15/11/15 13:08, larsxschneider@gmail.com wrote:
> From: Lars Schneider <larsxschneider@gmail.com>
>
> In rare cases kill/cleanup operations in tests fail. Retry these
> operations with a timeout to make the test less flaky.
Should there be a sleep in that retry_until_success loop so that it
doesn't spin sending signals to p4d?
Do we need to worry about the time offset being updated (e.g. NTP) while
this is running?
>
> Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
> ---
> t/lib-git-p4.sh | 31 +++++++++++++++++++++++--------
> 1 file changed, 23 insertions(+), 8 deletions(-)
>
> diff --git a/t/lib-git-p4.sh b/t/lib-git-p4.sh
> index 7548225..8d6b48f 100644
> --- a/t/lib-git-p4.sh
> +++ b/t/lib-git-p4.sh
> @@ -6,6 +6,10 @@
> # a subdirectory called "$git"
> TEST_NO_CREATE_REPO=NoThanks
>
> +# Some operations require multiple attempts to be successful. Define
> +# here the maximal retry timeout in seconds.
> +RETRY_TIMEOUT=60
> +
> . ./test-lib.sh
>
> if ! test_have_prereq PYTHON
> @@ -121,22 +125,33 @@ p4_add_user() {
> EOF
> }
>
> +retry_until_success() {
> + timeout=$(($(date +%s) + $RETRY_TIMEOUT))
> + until "$@" 2>/dev/null || test $(date +%s) -gt $timeout
> + do :
sleep here?
> + done
> +}
> +
> +retry_until_fail() {
> + timeout=$(($(date +%s) + $RETRY_TIMEOUT))
> + until ! "$@" 2>/dev/null || test $(date +%s) -gt $timeout
> + do :
sleep here?
> + done
> +}
> +
> kill_p4d() {
> pid=$(cat "$pidfile")
> - # it had better exist for the first kill
> - kill $pid &&
> - for i in 1 2 3 4 5 ; do
> - kill $pid >/dev/null 2>&1 || break
> - sleep 1
> - done &&
> + retry_until_fail kill $pid
> + retry_until_fail kill -9 $pid
> # complain if it would not die
> test_must_fail kill $pid >/dev/null 2>&1 &&
> rm -rf "$db" "$cli" "$pidfile"
> }
>
> cleanup_git() {
> - rm -rf "$git" &&
> - mkdir "$git"
> + retry_until_success rm -r "$git"
> + test_must_fail test -d "$git" &&
> + retry_until_success mkdir "$git"
> }
>
> marshal_dump() {
>
next prev parent reply other threads:[~2015-11-16 8:36 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-15 13:08 [PATCH v5 0/6] Add Travis CI support larsxschneider
2015-11-15 13:08 ` [PATCH v5 1/6] implement test_might_fail using a refactored test_must_fail larsxschneider
2015-11-15 13:08 ` [PATCH v5 2/6] add "ok=sigpipe" to test_must_fail and use it to fix flaky tests larsxschneider
2015-11-15 13:08 ` [PATCH v5 3/6] git-p4: retry kill/cleanup operations in tests with timeout larsxschneider
2015-11-16 8:36 ` Luke Diamand [this message]
2015-11-17 8:22 ` Lars Schneider
2015-11-17 9:38 ` Luke Diamand
2015-11-16 21:14 ` Eric Sunshine
2015-11-17 8:28 ` Lars Schneider
2015-11-17 8:35 ` Eric Sunshine
2015-11-17 9:34 ` Luke Diamand
2015-11-17 17:44 ` Eric Sunshine
2015-11-17 23:40 ` Luke Diamand
2015-11-15 13:08 ` [PATCH v5 4/6] git-p4: add p4d timeout in tests larsxschneider
2015-11-16 8:39 ` Luke Diamand
2015-11-15 13:08 ` [PATCH v5 5/6] git-p4: add trap to kill p4d on test exit larsxschneider
2015-11-16 8:43 ` Luke Diamand
2015-11-17 8:29 ` Lars Schneider
2015-11-15 13:08 ` [PATCH v5 6/6] Add Travis CI support larsxschneider
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=5649958F.2010407@diamand.org \
--to=luke@diamand.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=larsxschneider@gmail.com \
--cc=sunshine@sunshineco.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;
as well as URLs for NNTP newsgroup(s).