All of lore.kernel.org
 help / color / mirror / Atom feed
From: bakulinm@ispras.ru
To: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: "Pavel Dovgalyuk" <pavel.dovgalyuk@ispras.ru>,
	qemu-devel@nongnu.org, pbonzini@redhat.com,
	alex.bennee@linaro.org, crosa@redhat.com, wainersm@redhat.com,
	bleal@redhat.com
Subject: Re: [PATCH] tests/avocado: using several workers while testing
Date: Tue, 22 Nov 2022 11:14:17 +0000	[thread overview]
Message-ID: <5080ffd09cfee32c9bb10bc64f20d062@ispras.ru> (raw)
In-Reply-To: <Y3T26+ZNRsd7ELbB@redhat.com>

Version of patch that uses sh script to parse MAKEFLAGS and set --nrunner-max-parallel-tasks accordingly. As already mentioned, works with Make 4.2 or newer, otherwise only single thread or all cores can be used.

diff --git a/tests/Makefile.include b/tests/Makefile.include
index 9422ddaece..ee059dc135 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -93,6 +93,9 @@ TESTS_VENV_DIR=$(BUILD_DIR)/tests/venv
 TESTS_VENV_REQ=$(SRC_PATH)/tests/requirements.txt
 TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results
 TESTS_PYTHON=$(TESTS_VENV_DIR)/bin/python3
+# 1 task is used by default
+NRUNNER_MAX_TASKS=--nrunner-max-parallel-tasks 1
+
 ifndef AVOCADO_TESTS
 	AVOCADO_TESTS=tests/avocado
 endif
@@ -111,6 +114,21 @@ quiet-venv-pip = $(quiet-@)$(call quiet-command-run, \
     $(TESTS_PYTHON) -m pip -q --disable-pip-version-check $1, \
     "VENVPIP","$1")
 
+get_avocado_max_tasks:
+# make 4.2 and later provide number of jobs in MAKEFLAGS
+# in earlier versions only -j can be used
+# Use N jobs if -jN isprovided. Use $(nproc) jobs if only -j is provided,
+# Use 1 job if no -j is found in MAKEFLAGS string.
+	$(eval MAKE_JOBS=$(shell (if (echo $(MAKEFLAGS) | grep -Eq ^.*-j\([0-9]+\).*$$); then \
+		(echo $(MAKEFLAGS) | sed -r 's/.*-j([0-9]+).*/\1/'); \
+	elif (echo $(MAKEFLAGS) | grep -Eq ^.*-j.*$$); then \
+		nproc; \
+	else \
+		echo 1; \
+	fi)))
+
+	$(eval NRUNNER_MAX_TASKS=--nrunner-max-parallel-tasks $$(MAKE_JOBS))
+
 $(TESTS_VENV_DIR): $(TESTS_VENV_REQ)
 	$(call quiet-command, $(PYTHON) -m venv $@, VENV, $@)
 	$(call quiet-venv-pip,install -e "$(SRC_PATH)/python/")
@@ -138,14 +156,14 @@ get-vm-image-fedora-31-%: check-venv
 # download all vm images, according to defined targets
 get-vm-images: check-venv $(patsubst %,get-vm-image-fedora-31-%, $(FEDORA_31_DOWNLOAD))
 
-check-avocado: check-venv $(TESTS_RESULTS_DIR) get-vm-images
+check-avocado: check-venv $(TESTS_RESULTS_DIR) get-vm-images get_avocado_max_tasks
 	$(call quiet-command, \
             $(TESTS_PYTHON) -m avocado \
             --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \
             $(if $(AVOCADO_TAGS),, --filter-by-tags-include-empty \
 			--filter-by-tags-include-empty-key) \
             $(AVOCADO_CMDLINE_TAGS) \
-            $(if $(GITLAB_CI),,--failfast) $(AVOCADO_TESTS), \
+            $(if $(GITLAB_CI),,--failfast) $(AVOCADO_TESTS) $(NRUNNER_MAX_TASKS), \
             "AVOCADO", "tests/avocado")
 
 check-acceptance-deprecated-warning:
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


November 16, 2022 6:42 PM, "Daniel P. Berrangé" <berrange@redhat.com> wrote:

> On Wed, Nov 16, 2022 at 02:37:43PM +0000, bakulinm@ispras.ru wrote:
> 
>> Valid point, thank you.
>> 
>> I can see three options what to do:
>> e1) Ignore older version of make and assume that 4.2 or newer is used
>> (4.1 is in Ubuntu 18.04 that is no longer supported as a build platform
>> as I was told; 20.04 has 4.2). In this case make provides number of
>> jobs in $MAKEFLAGS and this makes getting it trivial. In case of an
>> older make only two options will be available: (default) single-threaded,
>> and using all cores.
>> 
>> Which one should I choose?
> 
> Ignore older make. Ubuntu 18.04 is not a platform we target anymore,
> so we shouldn't be writing compat code for handling it, and in any
> case degrading to single threaded or all-cores is fine fallback IMHO.
> 
> 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 :|


      reply	other threads:[~2022-11-22 11:15 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é
2022-11-16 14:37   ` bakulinm
2022-11-16 14:42     ` Daniel P. Berrangé
2022-11-22 11:14       ` bakulinm [this message]

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=5080ffd09cfee32c9bb10bc64f20d062@ispras.ru \
    --to=bakulinm@ispras.ru \
    --cc=alex.bennee@linaro.org \
    --cc=berrange@redhat.com \
    --cc=bleal@redhat.com \
    --cc=crosa@redhat.com \
    --cc=pavel.dovgalyuk@ispras.ru \
    --cc=pbonzini@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.