From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Pavel Dovgalyuk <pavel.dovgalyuk@ispras.ru>
Cc: qemu-devel@nongnu.org, pbonzini@redhat.com,
alex.bennee@linaro.org, philmd@redhat.com, crosa@redhat.com,
wainersm@redhat.com, bleal@redhat.com, bakulinm@ispras.ru
Subject: Re: [PATCH] tests/avocado: using several workers while testing
Date: Wed, 16 Nov 2022 14:06:44 +0000 [thread overview]
Message-ID: <Y3TuYPX/RFLgbLRC@redhat.com> (raw)
In-Reply-To: <166860649008.1258000.17066080427505400235.stgit@pasha-ThinkPad-X280>
On Wed, Nov 16, 2022 at 04:48:10PM +0300, Pavel Dovgalyuk wrote:
> From: bakulinm <bakulinm@gmail.com>
>
> make check-avocado takes a lot of time, and avocado since version 91 has
> multithreaded mode for running several tests simultaneously.
> This patch allows to run "make check-avocado -j" to use all cores or,
> for example, "make check-avocado -j4" to select number of workers to use.
> By default ("make check-avocado") only one worker is used.
>
> Changes:
> 1) Version of avocado in requirements.txt upgraded from 88.1 to <93
> (LTS version is used, as mentioned here
> https://avocado-framework.readthedocs.io/en/latest/releases/lts/92_0.html )
> 2) Makefile 4.1 (used in e.g. Ubuntu 18.04) doesn't provide number of jobs
> in $MAKEFLAGS, so python script from here
> https://stackoverflow.com/a/67247743/5936122 is used.
> diff --git a/tests/jobs.py b/tests/jobs.py
> new file mode 100644
> index 0000000000..a339192d97
> --- /dev/null
> +++ b/tests/jobs.py
> @@ -0,0 +1,42 @@
No license information or attribution put on this code that
you've said was directly copied from stackoverflow. AFAICT,
all content on stackoverflow is placed under the creative
commons license. This is not something we would generally
want to be applied to code in QEMU as that's generally
considered as a content license.
Unless the copied code is trivial (this case is not), then
stackoverflow should really only be used a learning resource,
and then code written from scratch without copying, so it
can be placed under the project's usual license.
> +import argparse, os
> +import sys
> +
> +def safe_int(s):
> + try:
> + return int(s)
> + except:
> + return -1
> +
> +class JobserverArgs:
> + known_names = ["jobserver-fds","jobserver-auth"]
> + def __init__(self):
> + self.fds = "-1,-1"
> +
> + @staticmethod
> + def from_argv():
> + ja = JobserverArgs()
> + parser = argparse.ArgumentParser()
> + for name in JobserverArgs.known_names:
> + parser.add_argument('--'+name, dest="fds")
> + parser.parse_known_args(namespace=ja)
> + return ja
> +
> + def get_fds(self):
> + return tuple([safe_int(fd) for fd in (self.fds+",").split(",")][:2])
> +
> +fd_in, fd_out = JobserverArgs.from_argv().get_fds()
> +
> +if fd_in == -1 or fd_out == -1:
> +# if no jobserver is used, but -j is present, use total number of cpu cores
> + if '-j' in sys.argv:
> + print(os.cpu_count())
> +# use single thread
> + else:
> + print(1)
> +else:
> + os.set_blocking(fd_in, False)
> +
> + tokens = os.read(fd_in, 1024)
> + os.write(fd_out, tokens)
> +
> + print(len(tokens)+1)
> \ No newline at end of file
> diff --git a/tests/requirements.txt b/tests/requirements.txt
> index 0ba561b6bd..3b8c4d4706 100644
> --- a/tests/requirements.txt
> +++ b/tests/requirements.txt
> @@ -2,5 +2,5 @@
> # in the tests/venv Python virtual environment. For more info,
> # refer to: https://pip.pypa.io/en/stable/user_guide/#id1
> # Note that qemu.git/python/ is always implicitly installed.
> -avocado-framework==88.1
> +avocado-framework<93
> pycdlib==1.11.0
>
>
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2022-11-16 14:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-16 13:48 [PATCH] tests/avocado: using several workers while testing Pavel Dovgalyuk
2022-11-16 14:06 ` Daniel P. Berrangé [this message]
2022-11-16 14:37 ` bakulinm
2022-11-16 14:42 ` Daniel P. Berrangé
2022-11-22 11:14 ` bakulinm
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=Y3TuYPX/RFLgbLRC@redhat.com \
--to=berrange@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=bakulinm@ispras.ru \
--cc=bleal@redhat.com \
--cc=crosa@redhat.com \
--cc=pavel.dovgalyuk@ispras.ru \
--cc=pbonzini@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=wainersm@redhat.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).