Tests: introduce custom jobs
cover Tests: introduce custom jobs
Different users (or even companies) have different interests, and may want to run a reduced set of tests during development, or a larger set of tests during QE.
To cover these use cases, this introduces some example (but functional) jobs.
It's expected that some common jobs will come up from common requirements for different users (and maybe be added to a common location such as tests/jobs), and that very specific jobs will be added to directories specific to certain groups, say "contrib/com.redhat/jobs" or the like.
This series does *not* add new jobs to GitLab CI pipeline, but this is expected to be done later on custom runners. That is, custom runners could be used for custom jobs. Anyway, a GitLab CI pipeline can be seen here:
https://gitlab.com/cleber.gnu/qemu/-/pipelines/287210066
This is based on the Avocado version bump patch:
https://lists.gnu.org/archive/html/qemu-devel/2021-04/msg02391.html
Based-On: <[email protected]>
Cleber Rosa (8):
Acceptance Jobs: preserve the cache for pip on GitLab CI Acceptance tests: do not try to reuse packages from the system tests/acceptance/linux_ssh_mips_malta.py: drop identical setUp tests/acceptance/migration.py: cancel test if migration is not
supported
tests/acceptance/cpu_queries.py: use the proper logging channels Acceptance tests: prevent shutdown on non-specific target tests tests/acceptance/migration.py: cancel test on s390x
Tests: add custom test jobs
.gitlab-ci.yml | 1 + configure | 2 +- tests/Makefile.include | 10 +++- tests/acceptance/cpu_queries.py | 4 +- tests/acceptance/linux_ssh_mips_malta.py | 7 +-- tests/acceptance/migration.py | 16 ++++-- tests/acceptance/version.py | 2 +- tests/jobs/acceptance-all-targets.py | 67 ++++++++++++++++++++++++ tests/jobs/acceptance-kvm-only.py | 35 +++++++++++++ tests/jobs/qtest-unit-acceptance.py | 31 +++++++++++ tests/jobs/qtest-unit.py | 24 +++++++++ tests/jobs/utils.py | 22 ++++++++ 12 files changed, 207 insertions(+), 14 deletions(-) create mode 100644 tests/jobs/acceptance-all-targets.py create mode 100644 tests/jobs/acceptance-kvm-only.py create mode 100644 tests/jobs/qtest-unit-acceptance.py create mode 100644 tests/jobs/qtest-unit.py create mode 100644 tests/jobs/utils.py
Signature · 1 line
2.25.4
PATCH 1/8 Acceptance Jobs: preserve the cache for pip on GitLab CI
The acceptance jobs (via make check-venv) will setup a virtual environment, and after that install packages defined in tests/requirements.txt via pip.
Let's enable pip's default cache directory, so that we can save a bit on time/bandwidth.
--- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+)
.gitlab-ci.yml +1 -0
@@ -53,6 +53,7 @@ include: key: "${CI_JOB_NAME}-cache" paths: - ${CI_PROJECT_DIR}/avocado-cache + - ~/.cache/pip policy: pull-push artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
Signature · 1 line
2.25.4
Re: [PATCH 1/8] Acceptance Jobs: preserve the cache for pip on GitLab CI
Quoted 17 lines · Cleber Rosa
The acceptance jobs (via
make check-venv) will setup a virtual environment, and after that install packages defined intests/requirements.txtvia pip.Let's enable pip's default cache directory, so that we can save a bit on time/bandwidth.
Signed-off-by Cleber Rosa <[email protected]>--- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+).gitlab-ci.yml +0
-0
.gitlab-ci.yml include: · line 56
Quoted 4 lines
.gitlab-ci.yml +1
-0@@ -53,6 +53,7 @@ include: key: "${CI_JOB_NAME}-cache" paths: - ${CI_PROJECT_DIR}/avocado-cache + - ~/.cache/pip
Did you check whether this works? AFAIK the cache directories have to be part of the project directory, see:
https://docs.gitlab.com/ee/ci/yaml/README.html#cache
We already tried to cache ~/avocado/data/cache in the past, but it did not work and we had to move the cache manually to the current working directory (see commit 5896c539547).
Thomas
Re: [PATCH 1/8] Acceptance Jobs: preserve the cache for pip on GitLab CI
Quoted 26 lines · Thomas Huth
Quoted 17 lines · Cleber Rosa
The acceptance jobs (via
make check-venv) will setup a virtual environment, and after that install packages defined intests/requirements.txtvia pip.Let's enable pip's default cache directory, so that we can save a bit on time/bandwidth.
Signed-off-by Cleber Rosa <[email protected]>--- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+).gitlab-ci.yml +0
-0.gitlab-ci.yml include: · line 56
Quoted 4 lines
.gitlab-ci.yml +1
-0@@ -53,6 +53,7 @@ include: key: "${CI_JOB_NAME}-cache" paths: - ${CI_PROJECT_DIR}/avocado-cache + - ~/.cache/pipDid you check whether this works? AFAIK the cache directories have to be part of the project directory, see:
Quoted 7 lines
https://docs.gitlab.com/ee/ci/yaml/README.html#cache
We already tried to cache ~/avocado/data/cache in the past, but it did not work and we had to move the cache manually to the current working directory (see commit
5896c539547).Thomas
You're absolutely right, it won't work like that. My bad.
I was trying to avoid having to set variables or configurations, but something like the following will be needed:
before_script:
- export PIP_CACHE_DIR=${CI_PROJECT_DIR}/pip-cache
- mkdir -p ${CI_PROJECT_DIR}/pip-cache
cache:
paths:
- ${CI_PROJECT_DIR}/pip-cache
Resulting in:
Using cached avocado_framework-87.0-py3-none-any.whl (399 kB)
And the likes of:
https://gitlab.com/cleber.gnu/democi/-/jobs/1186910932#L166
I'll change that on v2.
Thanks!
- Cleber.
PATCH 2/8 Acceptance tests: do not try to reuse packages from the system
In reply to Cleber RosaThe premise behind the original behavior is that it would save people from downloading Avocado (and other dependencies) if already installed on the system. To be honest, I think it's extremely rare that the same versions described as dependencies will be available on most systems. But, the biggest motivations here are that:
1) Hacking on QEMU in the same system used to develop Avocado leads
to confusion with regards to the exact bits that are being used;
2) Not reusing Python packages from system wide installations gives extra assurance that the same behavior will be seen from tests run on different machines;
With regards to downloads, pip already caches the downloaded wheels and tarballs under ~/.cache/pip, so there should not be more than one download even if the venv is destroyed and recreated.
--- tests/Makefile.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/Makefile.include +1 -1
@@ -96,7 +96,7 @@ AVOCADO_TAGS=$(patsubst %-softmmu,-t arch:%, $(filter %-softmmu,$(TARGETS))) $(TESTS_VENV_DIR): $(TESTS_VENV_REQ) $(call quiet-command, \ - $(PYTHON) -m venv --system-site-packages $@, \ + $(PYTHON) -m venv $@, \ VENV, $@) $(call quiet-command, \ $(TESTS_VENV_DIR)/bin/python -m pip -q install -r $(TESTS_VENV_REQ), \
Signature · 1 line
2.25.4
Re: [PATCH 2/8] Acceptance tests: do not try to reuse packages from the system
Quoted 13 lines · Cleber Rosa
The premise behind the original behavior is that it would save people from downloading Avocado (and other dependencies) if already installed on the system. To be honest, I think it's extremely rare that the same versions described as dependencies will be available on most systems. But, the biggest motivations here are that:
1) Hacking on QEMU in the same system used to develop Avocado leads
to confusion with regards to the exact bits that are being used;2) Not reusing Python packages from system wide installations gives extra assurance that the same behavior will be seen from tests run on different machines;
Quoted 8 lines
With regards to downloads, pip already caches the downloaded wheels and tarballs under ~/.cache/pip, so there should not be more than one download even if the venv is destroyed and recreated.
Signed-off-by Cleber Rosa <[email protected]>--- tests/Makefile.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Re: [PATCH 2/8] Acceptance tests: do not try to reuse packages from the system
In reply to Cleber RosaQuoted 10 lines · Cleber Rosa
The premise behind the original behavior is that it would save people from downloading Avocado (and other dependencies) if already installed on the system. To be honest, I think it's extremely rare that the same versions described as dependencies will be available on most systems. But, the biggest motivations here are that:
1) Hacking on QEMU in the same system used to develop Avocado leads
to confusion with regards to the exact bits that are being used;
Indeed!
Quoted 4 lines
2) Not reusing Python packages from system wide installations gives extra assurance that the same behavior will be seen from tests run on different machines;
Quoted 9 lines
With regards to downloads, pip already caches the downloaded wheels and tarballs under ~/.cache/pip, so there should not be more than one download even if the venv is destroyed and recreated.
Signed-off-by Cleber Rosa <[email protected]>--- tests/Makefile.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Re: [PATCH 2/8] Acceptance tests: do not try to reuse packages from the system
In reply to Cleber RosaQuoted 13 lines · Cleber Rosa
The premise behind the original behavior is that it would save people from downloading Avocado (and other dependencies) if already installed on the system. To be honest, I think it's extremely rare that the same versions described as dependencies will be available on most systems. But, the biggest motivations here are that:
1) Hacking on QEMU in the same system used to develop Avocado leads
to confusion with regards to the exact bits that are being used;2) Not reusing Python packages from system wide installations gives extra assurance that the same behavior will be seen from tests run on different machines;
Quoted 8 lines
With regards to downloads, pip already caches the downloaded wheels and tarballs under ~/.cache/pip, so there should not be more than one download even if the venv is destroyed and recreated.
Signed-off-by Cleber Rosa <[email protected]>--- tests/Makefile.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines
tests/Makefile.include +1
-1@@ -96,7 +96,7 @@ AVOCADO_TAGS=$(patsubst %-softmmu,-t arch:%, $(filter %-softmmu,$(TARGETS))) $(TESTS_VENV_DIR): $(TESTS_VENV_REQ) $(call quiet-command, \ - $(PYTHON) -m venv --system-site-packages $@, \ + $(PYTHON) -m venv $@, \ VENV, $@) $(call quiet-command, \ $(TESTS_VENV_DIR)/bin/python -m pip -q install -r $(TESTS_VENV_REQ), \
PATCH 3/8 tests/acceptance/linux_ssh_mips_malta.py: drop identical setUp
In reply to Cleber RosaThese tests' setUp do not do anything beyong what their base class do. And while they do decorate the setUp() we can decorate the classes instead, so no functionality is lost here.
--- tests/acceptance/linux_ssh_mips_malta.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
tests/acceptance/linux_ssh_mips_malta.py +2 -5
@@ -19,6 +19,8 @@ from avocado.utils import ssh +@skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout') +@skipUnless(ssh.SSH_CLIENT_BINARY, 'No SSH client available') class LinuxSSH(Test): timeout = 150 # Not for 'configure --enable-debug --enable-debug-tcg'
@@ -65,11 +67,6 @@ def get_kernel_info(self, endianess, wordsize): kernel_hash = self.IMAGE_INFO[endianess]['kernel_hash'][wordsize] return kernel_url, kernel_hash - @skipUnless(ssh.SSH_CLIENT_BINARY, 'No SSH client available') - @skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout') - def setUp(self): - super(LinuxSSH, self).setUp() - def get_portfwd(self): res = self.vm.command('human-monitor-command', command_line='info usernet')
Signature · 1 line
2.25.4
Re: [PATCH 3/8] tests/acceptance/linux_ssh_mips_malta.py: drop identical setUp
Quoted 3 lines · Cleber Rosa
These tests' setUp do not do anything beyong what their base class do. And while they do decorate the
setUp()we can decorate the classes instead, so no functionality is lost here.
This is what I did first when adding this test, but it was not working, so I had to duplicate it to each method. Did something change so now this is possible?
Quoted 31 lines
Signed-off-by Cleber Rosa <[email protected]>--- tests/acceptance/linux_ssh_mips_malta.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)tests/acceptance/linux_ssh_mips_malta.py +2
-5@@ -19,6 +19,8 @@ from avocado.utils import ssh +@skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout') +@skipUnless(ssh.SSH_CLIENT_BINARY, 'No SSH client available') class LinuxSSH(Test): timeout = 150 # Not for 'configure --enable-debug --enable-debug-tcg'@@ -65,11 +67,6 @@ def get_kernel_info(self, endianess, wordsize): kernel_hash = self.IMAGE_INFO[endianess]['kernel_hash'][wordsize] return kernel_url, kernel_hash - @skipUnless(ssh.SSH_CLIENT_BINARY, 'No SSH client available') - @skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout') - def setUp(self): - super(LinuxSSH, self).setUp() - def get_portfwd(self): res = self.vm.command('human-monitor-command', command_line='info usernet')
Re: [PATCH 3/8] tests/acceptance/linux_ssh_mips_malta.py: drop identical setUp
Quoted 10 lines · Philippe Mathieu-Daudé
Quoted 3 lines · Cleber Rosa
These tests' setUp do not do anything beyong what their base class do. And while they do decorate the
setUp()we can decorate the classes instead, so no functionality is lost here.This is what I did first when adding this test, but it was not working, so I had to duplicate it to each method. Did something change so now this is possible?
If your attempt was made prior
https://github.com/avocado-framework/avocado/pull/3570, or with a version that did not have this fix, this, indeed, wasn't working.
Re: [PATCH 3/8] tests/acceptance/linux_ssh_mips_malta.py: drop identical setUp
In reply to Philippe Mathieu-DaudéQuoted 9 lines · Philippe Mathieu-Daudé
Quoted 3 lines · Cleber Rosa
These tests' setUp do not do anything beyong what their base class do. And while they do decorate the
setUp()we can decorate the classes instead, so no functionality is lost here.This is what I did first when adding this test, but it was not working, so I had to duplicate it to each method. Did something change so now this is possible?
It did, but quite a while ago:
https://avocado-framework.readthedocs.io/en/87.0/releases/76_0.html#users-test-writers
It could have been updated much earlier, but, better late than never.
Cheers,
- Cleber.
Philippe Mathieu-Daudé
Reviewed-byRe: [PATCH 3/8] tests/acceptance/linux_ssh_mips_malta.py: drop identical setUp
Quoted 6 lines · Cleber Rosa
Quoted 5 lines · Philippe Mathieu-Daudé
Quoted 3 lines · Cleber Rosa
These tests' setUp do not do anything beyong what their base class do. And while they do decorate the
setUp()we can decorate the classes instead, so no functionality is lost here.
Quoted 8 lines
Quoted 4 lines
This is what I did first when adding this test, but it was not working, so I had to duplicate it to each method. Did something change so now this is possible?
It did, but quite a while ago:
https://avocado-framework.readthedocs.io/en/87.0/releases/76_0.html#users-test-writers
OK, the test is older. Do you mind adding a comment?
"Since Avocado 76.0 we can decorate setUp() directly, ..."
Quoted 1 line
It could have been updated much earlier, but, better late than never.
Sure :)
Thanks,
Phil.
Re: [PATCH 3/8] tests/acceptance/linux_ssh_mips_malta.py: drop identical setUp
Quoted 10 lines · Philippe Mathieu-Daudé
Quoted 9 lines · Cleber Rosa
Quoted 8 lines · Philippe Mathieu-Daudé
Quoted 3 lines · Cleber Rosa
These tests' setUp do not do anything beyong what their base class do. And while they do decorate the
setUp()we can decorate the classes instead, so no functionality is lost here.This is what I did first when adding this test, but it was not working, so I had to duplicate it to each method. Did something change so now this is possible?
Quoted 6 lines
Quoted 3 lines
It did, but quite a while ago:
https://avocado-framework.readthedocs.io/en/87.0/releases/76_0.html#users-test-writersOK, the test is older. Do you mind adding a comment?
"Since Avocado 76.0 we can decorate
setUp()directly, ..."
Ditto.
Also you may want to adjust VirtiofsSubmountsTest.setUp() in tests/acceptance/virtiofs_submounts.py as well.
- Wainer
Quoted 10 lines
Reviewed-by Philippe Mathieu-Daudé <[email protected]>Quoted 1 line
It could have been updated much earlier, but, better late than never.
Sure :)
Thanks,
Phil.
Re: [PATCH 3/8] tests/acceptance/linux_ssh_mips_malta.py: drop identical setUp
In reply to Cleber RosaQuoted 10 lines · Cleber Rosa
These tests' setUp do not do anything beyong what their base class do. And while they do decorate the
setUp()we can decorate the classes instead, so no functionality is lost here.Signed-off-by Cleber Rosa <[email protected]>--- tests/acceptance/linux_ssh_mips_malta.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
PATCH 4/8 tests/acceptance/migration.py: cancel test if migration is not supported
In reply to Cleber RosaFIXME: check if there's a way to query migration support before actually requesting migration.
Some targets/machines contain devices that do not support migration. Let's acknowledge that and cancel the test as early as possible.
--- tests/acceptance/migration.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
tests/acceptance/migration.py +5 -1
@@ -53,7 +53,11 @@ def do_migrate(self, dest_uri, src_uri=None): source_vm = self.get_vm() source_vm.add_args('-nodefaults') source_vm.launch() - source_vm.qmp('migrate', uri=src_uri) + response = source_vm.qmp('migrate', uri=src_uri) + if 'error' in response: + if 'desc' in response['error']: + msg = response['error']['desc'] + self.cancel('Migration does not seem to be supported: %s' % msg) self.assert_migration(source_vm, dest_vm) def _get_free_port(self):
Signature · 1 line
2.25.4
Re: [PATCH 4/8] tests/acceptance/migration.py: cancel test if migration is not supported
Quoted 16 lines · Cleber Rosa
FIXME: check if there's a way to query migration support before actually requesting migration.
Some targets/machines contain devices that do not support migration. Let's acknowledge that and cancel the test as early as possible.
Signed-off-by Cleber Rosa <[email protected]>--- tests/acceptance/migration.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)tests/acceptance/migration.py +0
-0
tests/acceptance/migration.py def do_migrate(self, dest_uri, src_uri=None): · line 61
Quoted 10 lines
tests/acceptance/migration.py +5
-1@@ -53,7 +53,11 @@ def do_migrate(self, dest_uri, src_uri=None): source_vm = self.get_vm() source_vm.add_args('-nodefaults') source_vm.launch() - source_vm.qmp('migrate', uri=src_uri) + response = source_vm.qmp('migrate', uri=src_uri) + if 'error' in response: + if 'desc' in response['error']: + msg = response['error']['desc'] + self.cancel('Migration does not seem to be supported: %s' % msg) self.assert_migration(source_vm, dest_vm)
It would be better to have this done as a generic check_requisites() method. First because we could reuse it (also at the class level), second because we could account the time spent for checking separately from the time spent for the actual testing.
Re: [PATCH 4/8] tests/acceptance/migration.py: cancel test if migration is not supported
Quoted 24 lines · Philippe Mathieu-Daudé
Quoted 23 lines · Cleber Rosa
FIXME: check if there's a way to query migration support before actually requesting migration.
Some targets/machines contain devices that do not support migration. Let's acknowledge that and cancel the test as early as possible.
Signed-off-by Cleber Rosa <[email protected]>--- tests/acceptance/migration.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)tests/acceptance/migration.py +3
-1@@ -53,7 +53,11 @@ def do_migrate(self, dest_uri, src_uri=None): source_vm = self.get_vm() source_vm.add_args('-nodefaults') source_vm.launch() - source_vm.qmp('migrate', uri=src_uri) + response = source_vm.qmp('migrate', uri=src_uri) + if 'error' in response: + if 'desc' in response['error']:
Quoted 9 lines
tests/acceptance/migration.py def do_migrate(self, dest_uri, src_uri=None): · line 61
Quoted 3 lines
tests/acceptance/migration.py +2
-0+ msg = response['error']['desc'] + self.cancel('Migration does not seem to be supported: %s' % msg) self.assert_migration(source_vm, dest_vm)It would be better to have this done as a generic
check_requisites()method. First because we could reuse it (also at the class level), second because we could account the time spent for checking separately from the time spent for the actual testing.
With regards to separating the time, you suggest that we should perform the check at the setUp(), and I absolutely agree with the principle. But, I wonder if any characteristic of the "vm", configured during the test (and not available earlier), could affect its migration capabilities.
Right now we are proposing some "require_*()" methods, such as require_accelerator("kvm"), because they are checks that, to the best of my knowlege, do not depend on any further configuration for the vm instance.
But, your second point, about this being in a method for common use, is very sound. IMO the place to put something like you suggest would be QEMUMachine. Something like:
try:
source_vm.require_migrate()
except RequirementError as e:
self.cancel(e)
Ideally, though, one instance of the QEMUMachine used for the checks, would not be re-used during the test. The ideal implementation of QEMUMachine.require_*(), would create a fresh QEMUMachine instance with user defined characteristics and verify the requirement, leaving the original instance untouched.
IMO we can pursue that discussion further, while handling this error condition locally for now.
Thanks,
- Cleber.
Re: [PATCH 4/8] tests/acceptance/migration.py: cancel test if migration is not supported
In reply to Cleber RosaQuoted 17 lines · Cleber Rosa
FIXME: check if there's a way to query migration support before actually requesting migration.
Some targets/machines contain devices that do not support migration. Let's acknowledge that and cancel the test as early as possible.
Signed-off-by Cleber Rosa <[email protected]>--- tests/acceptance/migration.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)tests/acceptance/migration.py +0
-0
tests/acceptance/migration.py def do_migrate(self, dest_uri, src_uri=None): · line 60
Quoted 9 lines
tests/acceptance/migration.py +5
-1@@ -53,7 +53,11 @@ def do_migrate(self, dest_uri, src_uri=None): source_vm = self.get_vm() source_vm.add_args('-nodefaults') source_vm.launch() - source_vm.qmp('migrate', uri=src_uri) + response = source_vm.qmp('migrate', uri=src_uri) + if 'error' in response: + if 'desc' in response['error']: + msg = response['error']['desc'] + self.cancel('Migration does not seem to be supported: %s' % msg)
I agree with Phil that a generic function would be reusable when needed, but as it is not needed yet, this looks good to me:
Re: [PATCH 4/8] tests/acceptance/migration.py: cancel test if migration is not supported
In reply to Cleber RosaHi,
Quoted 16 lines · Cleber Rosa
FIXME: check if there's a way to query migration support before actually requesting migration.
Some targets/machines contain devices that do not support migration. Let's acknowledge that and cancel the test as early as possible.
Signed-off-by Cleber Rosa <[email protected]>--- tests/acceptance/migration.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)tests/acceptance/migration.py +0
-0
tests/acceptance/migration.py def do_migrate(self, dest_uri, src_uri=None): · line 60
Quoted 9 lines
tests/acceptance/migration.py +5
-1@@ -53,7 +53,11 @@ def do_migrate(self, dest_uri, src_uri=None): source_vm = self.get_vm() source_vm.add_args('-nodefaults') source_vm.launch() - source_vm.qmp('migrate', uri=src_uri) + response = source_vm.qmp('migrate', uri=src_uri) + if 'error' in response: + if 'desc' in response['error']: + msg = response['error']['desc'] + self.cancel('Migration does not seem to be supported: %s' % msg)
My concern is about that cancellation actually covering up a real bug.
Cleber, have you seen the test failing on CI?
- Wainer
Quoted 3 lines
tests/acceptance/migration.py +0
-0self.assert_migration(source_vm, dest_vm) def _get_free_port(self):
PATCH 5/8 tests/acceptance/cpu_queries.py: use the proper logging channels
In reply to Cleber RosaThe test contains methods for the proper log of test related information. Let's use that and remove the print and the unused logging import.
Reference: https://avocado-framework.readthedocs.io/en/87.0/api/test/avocado.html#avocado.Test.log
--- tests/acceptance/cpu_queries.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
tests/acceptance/cpu_queries.py +1 -3
@@ -8,8 +8,6 @@ # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. -import logging - from avocado_qemu import Test class QueryCPUModelExpansion(Test):
@@ -27,7 +25,7 @@ def test(self): cpus = self.vm.command('query-cpu-definitions') for c in cpus: - print(repr(c)) + self.log.info("Checking CPU: %s", c) self.assertNotIn('', c['unavailable-features'], c['name']) for c in cpus:
Signature · 1 line
2.25.4
Re: [PATCH 5/8] tests/acceptance/cpu_queries.py: use the proper logging channels
Quoted 1 line · Cleber Rosa
The test contains methods for the proper log of test related
"The Test class ..."?
Quoted 4 lines
information. Let's use that and remove the print and the unused logging import.
Reference: https://avocado-framework.readthedocs.io/en/87.0/api/test/avocado.html#avocado.Test.log
This test predates Avocado 87.0 :) Maybe mention this is an update to the recent API?
Quoted 28 lines
Signed-off-by Cleber Rosa <[email protected]>--- tests/acceptance/cpu_queries.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)tests/acceptance/cpu_queries.py +1
-3@@ -8,8 +8,6 @@ # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. -import logging - from avocado_qemu import Test class QueryCPUModelExpansion(Test):@@ -27,7 +25,7 @@ def test(self): cpus = self.vm.command('query-cpu-definitions') for c in cpus: - print(repr(c)) + self.log.info("Checking CPU: %s", c) self.assertNotIn('', c['unavailable-features'], c['name']) for c in cpus:
Re: [PATCH 5/8] tests/acceptance/cpu_queries.py: use the proper logging channels
Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 1 line · Cleber Rosa
The test contains methods for the proper log of test related
"The Test class ..."?
Quoted 7 lines
Quoted 4 lines
information. Let's use that and remove the print and the unused logging import.
Reference: https://avocado-framework.readthedocs.io/en/87.0/api/test/avocado.html#avocado.Test.log
This test predates Avocado 87.0 :) Maybe mention this is an update to the recent API?
This is not a new feature of Avocado 87.0, it has been there since before Avocado was used on QEMU.
Re: [PATCH 5/8] tests/acceptance/cpu_queries.py: use the proper logging channels
In reply to Philippe Mathieu-DaudéQuoted 5 lines · Philippe Mathieu-Daudé
Quoted 1 line · Cleber Rosa
The test contains methods for the proper log of test related
"The Test class ..."?
Yes, good catch!
Quoted 8 lines
Quoted 4 lines
information. Let's use that and remove the print and the unused logging import.
Reference: https://avocado-framework.readthedocs.io/en/87.0/api/test/avocado.html#avocado.Test.log
This test predates Avocado 87.0 :) Maybe mention this is an update to the recent API?
In fact, that API is *ages* old. I just happened to post a link to the latest stable release, because the build of ancient versions are disable on readthedocs.io.
Regards,
- Cleber.
Re: [PATCH 5/8] tests/acceptance/cpu_queries.py: use the proper logging channels
In reply to Cleber RosaQuoted 11 lines · Cleber Rosa
The test contains methods for the proper log of test related information. Let's use that and remove the print and the unused logging import.
Reference: https://avocado-framework.readthedocs.io/en/87.0/api/test/avocado.html#avocado.Test.log
Signed-off-by Cleber Rosa <[email protected]>--- tests/acceptance/cpu_queries.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
Re: [PATCH 5/8] tests/acceptance/cpu_queries.py: use the proper logging channels
In reply to Cleber RosaHi,
Quoted 24 lines · Cleber Rosa
The test contains methods for the proper log of test related information. Let's use that and remove the print and the unused logging import.
Reference: https://avocado-framework.readthedocs.io/en/87.0/api/test/avocado.html#avocado.Test.log
Signed-off-by Cleber Rosa <[email protected]>--- tests/acceptance/cpu_queries.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)tests/acceptance/cpu_queries.py +0
-2@@ -8,8 +8,6 @@ # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. -import logging - from avocado_qemu import Test class QueryCPUModelExpansion(Test):
tests/acceptance/cpu_queries.py def test(self): · line 31
Quoted 8 lines
tests/acceptance/cpu_queries.py +1
-1@@ -27,7 +25,7 @@ def test(self): cpus = self.vm.command('query-cpu-definitions') for c in cpus: - print(repr(c)) + self.log.info("Checking CPU: %s", c) self.assertNotIn('', c['unavailable-features'], c['name']) for c in cpus:
While you are here, maybe merge the two for c in cpus loops? :D
Anyway,
PATCH 6/8 Acceptance tests: prevent shutdown on non-specific target tests
In reply to Cleber RosaWhen running tests that are not target specific with various target binaries, some specific behavior appears. For s390x, when there's no guest code running, it will produce GUEST_PANICKED events as the firmware will shutdown the machine.
With this change, no GUEST_PANICKED *event* will be generated.
For some QMP commands, such as "query-migrate", a proper response ("guest-panicked" for the s390x target) will still be given.
--- tests/acceptance/migration.py | 4 ++-- tests/acceptance/version.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
tests/acceptance/migration.py +2 -2
@@ -46,12 +46,12 @@ def assert_migration(self, src_vm, dst_vm): def do_migrate(self, dest_uri, src_uri=None): dest_vm = self.get_vm('-incoming', dest_uri) - dest_vm.add_args('-nodefaults') + dest_vm.add_args('-nodefaults', '-no-shutdown') dest_vm.launch() if src_uri is None: src_uri = dest_uri source_vm = self.get_vm() - source_vm.add_args('-nodefaults') + source_vm.add_args('-nodefaults', '-no-shutdown') source_vm.launch() response = source_vm.qmp('migrate', uri=src_uri) if 'error' in response:
tests/acceptance/version.py +1 -1
@@ -17,7 +17,7 @@ class Version(Test): :avocado: tags=quick """ def test_qmp_human_info_version(self): - self.vm.add_args('-nodefaults') + self.vm.add_args('-nodefaults', '-no-shutdown') self.vm.launch() res = self.vm.command('human-monitor-command', command_line='info version')
Signature · 1 line
2.25.4
Re: [PATCH 6/8] Acceptance tests: prevent shutdown on non-specific target tests
Quoted 8 lines · Cleber Rosa
When running tests that are not target specific with various target binaries, some specific behavior appears. For s390x, when there's no guest code running, it will produce
GUEST_PANICKEDevents as the firmware will shutdown the machine.With this change, no
GUEST_PANICKED*event* will be generated.
Quoted 9 lines
For some QMP commands, such as "query-migrate", a proper response ("guest-panicked" for the s390x target) will still be given.
Signed-off-by Cleber Rosa <[email protected]>--- tests/acceptance/migration.py | 4 ++-- tests/acceptance/version.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
Re: [PATCH 6/8] Acceptance tests: prevent shutdown on non-specific target tests
In reply to Cleber RosaHi,
Quoted 21 lines · Cleber Rosa
When running tests that are not target specific with various target binaries, some specific behavior appears. For s390x, when there's no guest code running, it will produce
GUEST_PANICKEDevents as the firmware will shutdown the machine.With this change, no
GUEST_PANICKED*event* will be generated.For some QMP commands, such as "query-migrate", a proper response ("guest-panicked" for the s390x target) will still be given.
Signed-off-by Cleber Rosa <[email protected]>--- tests/acceptance/migration.py | 4 ++-- tests/acceptance/version.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)tests/acceptance/migration.py +0
-0
tests/acceptance/migration.py def assert_migration(self, src_vm, dst_vm): · line 49
Quoted 5 lines
tests/acceptance/migration.py +1
-1@@ -46,12 +46,12 @@ def assert_migration(self, src_vm, dst_vm): def do_migrate(self, dest_uri, src_uri=None): dest_vm = self.get_vm('-incoming', dest_uri) - dest_vm.add_args('-nodefaults') + dest_vm.add_args('-nodefaults', '-no-shutdown')
On the other hand, can't that new argument introduce unwanted behavior on other targets? Maybe the argument should be set only for s390 because we know it prevents the test failure on that target only.
- Wainer
Quoted 22 lines
tests/acceptance/migration.py +1
-1dest_vm.launch() if src_uri is None: src_uri = dest_uri source_vm = self.get_vm() - source_vm.add_args('-nodefaults') + source_vm.add_args('-nodefaults', '-no-shutdown') source_vm.launch() response = source_vm.qmp('migrate', uri=src_uri) if 'error' in response:tests/acceptance/version.py +1
-1@@ -17,7 +17,7 @@ class Version(Test): :avocado: tags=quick """ def test_qmp_human_info_version(self): - self.vm.add_args('-nodefaults') + self.vm.add_args('-nodefaults', '-no-shutdown') self.vm.launch() res = self.vm.command('human-monitor-command', command_line='info version')
PATCH 7/8 tests/acceptance/migration.py: cancel test on s390x
In reply to Cleber RosaBecause s390x targets it can not currently migrate without a guest running.
Future work may provide a proper guest, but for now, it's safer to cancel the test.
--- tests/acceptance/migration.py | 6 ++++++ 1 file changed, 6 insertions(+)
tests/acceptance/migration.py +6 -0
@@ -48,6 +48,12 @@ def do_migrate(self, dest_uri, src_uri=None): dest_vm = self.get_vm('-incoming', dest_uri) dest_vm.add_args('-nodefaults', '-no-shutdown') dest_vm.launch() + + cpus = dest_vm.command('query-cpus-fast') + if cpus: + if cpus[0].get('target') == 's390x': + self.cancel('Migration without a guest not possible on s390') + if src_uri is None: src_uri = dest_uri source_vm = self.get_vm()
Signature · 1 line
2.25.4
Re: [PATCH 7/8] tests/acceptance/migration.py: cancel test on s390x
Quoted 10 lines · Cleber Rosa
Because s390x targets it can not currently migrate without a guest running.
Future work may provide a proper guest, but for now, it's safer to cancel the test.
Signed-off-by Cleber Rosa <[email protected]>--- tests/acceptance/migration.py | 6 ++++++ 1 file changed, 6 insertions(+)
Quoted 18 lines
tests/acceptance/migration.py +6
-0@@ -48,6 +48,12 @@ def do_migrate(self, dest_uri, src_uri=None): dest_vm = self.get_vm('-incoming', dest_uri) dest_vm.add_args('-nodefaults', '-no-shutdown') dest_vm.launch() + + cpus = dest_vm.command('query-cpus-fast') + if cpus: + if cpus[0].get('target') == 's390x': + self.cancel('Migration without a guest not possible on s390') + if src_uri is None: src_uri = dest_uri source_vm = self.get_vm()
Re: [PATCH 7/8] tests/acceptance/migration.py: cancel test on s390x
In reply to Cleber RosaQuoted 4 lines · Cleber Rosa
Because s390x targets it can not currently migrate without a guest running.
Quoted 8 lines
Future work may provide a proper guest, but for now, it's safer to cancel the test.
Signed-off-by Cleber Rosa <[email protected]>--- tests/acceptance/migration.py | 6 ++++++ 1 file changed, 6 insertions(+)
PATCH 8/8 Tests: add custom test jobs
In reply to Cleber RosaDifferent users (or even companies) have different interests, and may want to run a reduced set of tests during development, or a larger set of tests during QE.
To cover these use cases, some example (but functional) jobs are introduced here:
1) acceptance-all-targets.py: runs all arch agnostic tests on all built targets, unless there are conditions that make them not work out of the box ATM, then run all tests that are specific to predefined targets.
2) acceptance-kvm-only.py: runs only tests that require KVM and are specific to the host architecture.
3) qtest-unit.py: runs a combination of qtest and unit tests (in parallel).
4) qtest-unit-acceptance.py: runs a combineation of qtest, unit tests and acceptance tests (all of them in parallel)
To run the first two manually, follow the example bellow:
$ cd build $ make check-venv $ ./tests/venv/bin/python3 tests/jobs/acceptance-all-targets.py $ ./tests/venv/bin/python3 tests/jobs/acceptance-kvm-only.py
The third and fouth example depends on information coming from Meson, so the easiest way to run it is:
$ cd build $ make check-qtest-unit $ make check-qtest-unit-acceptance
These are based on Avocado's Job API, a way to customize an Avocado job execution beyond the possibilities of command line arguments. For more Job API resources, please refer to:
a) Job API Examples:
- https://github.com/avocado-framework/avocado/tree/master/examples/jobs
b) Documentation about configurable features at the Job Level:
- https://avocado-framework.readthedocs.io/en/87.0/config/index.html
c) Documentation about the TestSuite class
- https://avocado-framework.readthedocs.io/en/87.0/api/core/avocado.core.html#avocado.core.suite.TestSuite
d) Documentation about the Job class
- https://avocado-framework.readthedocs.io/en/87.0/api/core/avocado.core.html#avocado.core.job.Job
--- configure | 2 +- tests/Makefile.include | 8 ++++ tests/jobs/acceptance-all-targets.py | 67 ++++++++++++++++++++++++++++ tests/jobs/acceptance-kvm-only.py | 35 +++++++++++++++ tests/jobs/qtest-unit-acceptance.py | 31 +++++++++++++ tests/jobs/qtest-unit.py | 24 ++++++++++ tests/jobs/utils.py | 22 +++++++++ 7 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 tests/jobs/acceptance-all-targets.py create mode 100644 tests/jobs/acceptance-kvm-only.py create mode 100644 tests/jobs/qtest-unit-acceptance.py create mode 100644 tests/jobs/qtest-unit.py create mode 100644 tests/jobs/utils.py
configure +1 -1
@@ -6265,7 +6265,7 @@ LINKS="$LINKS pc-bios/s390-ccw/Makefile" LINKS="$LINKS roms/seabios/Makefile" LINKS="$LINKS pc-bios/qemu-icon.bmp" LINKS="$LINKS .gdbinit scripts" # scripts needed by relative path in .gdbinit -LINKS="$LINKS tests/acceptance tests/data" +LINKS="$LINKS tests/acceptance tests/data tests/jobs" LINKS="$LINKS tests/qemu-iotests/check" LINKS="$LINKS python" LINKS="$LINKS contrib/plugins/Makefile "
tests/Makefile.include +8 -0
@@ -133,6 +133,14 @@ check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images $(if $(GITLAB_CI),,--failfast) tests/acceptance, \ "AVOCADO", "tests/acceptance") +# Runs qtest and unit tests on a custom Avocado job +check-qtest-unit: check-venv $(TESTS_RESULTS_DIR) + $(MESON) introspect --tests | $(TESTS_VENV_DIR)/bin/python $(SRC_PATH)/tests/jobs/qtest-unit.py $(TESTS_RESULTS_DIR) + +# Runs qtest and unit and accpetance tests on a custom Avocado job +check-qtest-unit-acceptance: check-venv $(TESTS_RESULTS_DIR) + $(MESON) introspect --tests | $(TESTS_VENV_DIR)/bin/python $(SRC_PATH)/tests/jobs/qtest-unit-acceptance.py $(TESTS_RESULTS_DIR) + # Consolidated targets .PHONY: check-block check check-clean get-vm-images
tests/jobs/acceptance-all-targets.py new file +67 -0
67 lines not on this page · raw message
tests/jobs/acceptance-kvm-only.py new file +35 -0
@@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +import os +import sys + +# This comes from tests/acceptance/avocado_qemu/__init__.py and should +# not be duplicated here. The solution is to have the "avocado_qemu" +# code and "python/qemu" available during build +BUILD_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) +if os.path.islink(os.path.dirname(os.path.dirname(__file__))): + # The link to the acceptance tests dir in the source code directory + lnk = os.path.dirname(os.path.dirname(__file__)) + #: The QEMU root source directory + SOURCE_DIR = os.path.dirname(os.path.dirname(os.readlink(lnk))) +else: + SOURCE_DIR = BUILD_DIR +sys.path.append(os.path.join(SOURCE_DIR, 'python')) + +from avocado.core.job import Job + +from qemu.accel import kvm_available + + +def main(): + if not kvm_available(): + sys.exit(0) + + config = {'run.references': ['tests/acceptance/'], + 'filter.by_tags.tags': ['accel:kvm,arch:%s' % os.uname()[4]]} + with Job.from_config(config) as job: + return job.run() + + +if __name__ == '__main__': + sys.exit(main())
tests/jobs/qtest-unit-acceptance.py new file +31 -0
@@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +import json +import random +import sys + +from avocado.core.job import Job +from avocado.core.resolver import resolve +from avocado.core.suite import resolutions_to_runnables + +from utils import meson_introspect_to_avocado_suite + + +def main(): + config = {'run.test_runner': 'nrunner'} + if len(sys.argv) > 1: + config['run.results_dir'] = sys.argv[1] + + suite = meson_introspect_to_avocado_suite(json.load(sys.stdin), + 'qtest-unit-acceptance', + config) + acceptance = resolutions_to_runnables(resolve(["tests/acceptance"]), + config) + suite.tests += acceptance + random.shuffle(suite.tests) + with Job(config, [suite]) as j: + return j.run() + + +if __name__ == '__main__': + sys.exit(main())
tests/jobs/qtest-unit.py new file +24 -0
@@ -0,0 +1,24 @@ +#!/usr/bin/env python3 + +import sys +import json + +from avocado.core.job import Job + +from utils import meson_introspect_to_avocado_suite + + +def main(): + config = {'run.test_runner': 'nrunner'} + if len(sys.argv) > 1: + config['run.results_dir'] = sys.argv[1] + + suite = meson_introspect_to_avocado_suite(json.load(sys.stdin), + 'qtest-unit', + config) + with Job(config, [suite]) as j: + return j.run() + + +if __name__ == '__main__': + sys.exit(main())
tests/jobs/utils.py new file +22 -0
@@ -0,0 +1,22 @@ +from avocado.core.suite import TestSuite +from avocado.core.nrunner import Runnable + + +def protocol_tap_to_runnable(entry): + runnable = Runnable('tap', + entry['cmd'][0], + *entry['cmd'][1:], + **entry['env']) + return runnable + + +def meson_introspect_to_avocado_suite(introspect, suite_name, config): + tests = [] + for entry in introspect: + if entry['protocol'] != 'tap': + continue + runnable = protocol_tap_to_runnable(entry) + tests.append(runnable) + + suite = TestSuite(name=suite_name, config=config, tests=tests) + return suite
Signature · 1 line
2.25.4
Re: [PATCH 8/8] Tests: add custom test jobs
Hi Cleber,
Quoted 12 lines · Cleber Rosa
Different users (or even companies) have different interests, and may want to run a reduced set of tests during development, or a larger set of tests during QE.
To cover these use cases, some example (but functional) jobs are introduced here:
1)
acceptance-all-targets.py: runs all arch agnostic tests on all built targets, unless there are conditions that make them not work out of the box ATM, then run all tests that are specific to predefined targets.
Quoted 7 lines
2)
acceptance-kvm-only.py: runs only tests that require KVM and are specific to the host architecture.3)
qtest-unit.py: runs a combination of qtest and unit tests (in parallel).4)
qtest-unit-acceptance.py: runs a combineation of qtest, unit tests
Typo "combination".
Quoted 75 lines
and acceptance tests (all of them in parallel)
To run the first two manually, follow the example bellow:
$ cd build $ make check-venv $ ./tests/venv/bin/python3 tests/jobs/acceptance-all-targets.py $ ./tests/venv/bin/python3 tests/jobs/acceptance-kvm-only.pyThe third and fouth example depends on information coming from Meson, so the easiest way to run it is:
$ cd build $ make check-qtest-unit $ make check-qtest-unit-acceptanceThese are based on Avocado's Job API, a way to customize an Avocado job execution beyond the possibilities of command line arguments. For more Job API resources, please refer to:
a) Job API Examples:
- https://github.com/avocado-framework/avocado/tree/master/examples/jobsb) Documentation about configurable features at the Job Level:
- https://avocado-framework.readthedocs.io/en/87.0/config/index.htmlc) Documentation about the TestSuite class
- https://avocado-framework.readthedocs.io/en/87.0/api/core/avocado.core.html#avocado.core.suite.TestSuited) Documentation about the Job class
- https://avocado-framework.readthedocs.io/en/87.0/api/core/avocado.core.html#avocado.core.job.JobSigned-off-by Cleber Rosa <[email protected]>--- configure | 2 +- tests/Makefile.include | 8 ++++ tests/jobs/acceptance-all-targets.py | 67 ++++++++++++++++++++++++++++ tests/jobs/acceptance-kvm-only.py | 35 +++++++++++++++ tests/jobs/qtest-unit-acceptance.py | 31 +++++++++++++ tests/jobs/qtest-unit.py | 24 ++++++++++ tests/jobs/utils.py | 22 +++++++++ 7 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 tests/jobs/acceptance-all-targets.py create mode 100644 tests/jobs/acceptance-kvm-only.py create mode 100644 tests/jobs/qtest-unit-acceptance.py create mode 100644 tests/jobs/qtest-unit.py create mode 100644 tests/jobs/utils.py(quoted diff) +2
-0+if __name__ == '__main__': + sys.exit(main())tests/jobs/acceptance-kvm-only.py new file +19
-0@@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +import os +import sys + +# This comes from tests/acceptance/avocado_qemu/__init__.py and should +# not be duplicated here. The solution is to have the "avocado_qemu" +# code and "python/qemu" available during build +BUILD_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) +if os.path.islink(os.path.dirname(os.path.dirname(__file__))): + # The link to the acceptance tests dir in the source code directory + lnk = os.path.dirname(os.path.dirname(__file__)) + #: The QEMU root source directory + SOURCE_DIR = os.path.dirname(os.path.dirname(os.readlink(lnk))) +else: + SOURCE_DIR = BUILD_DIR +sys.path.append(os.path.join(SOURCE_DIR, 'python')) + +from avocado.core.job import Job
tests/jobs/acceptance-kvm-only.py line 29
Quoted 10 lines
tests/jobs/acceptance-kvm-only.py new file +10
-0+ +from qemu.accel import kvm_available + + +def main(): + if not kvm_available(): + sys.exit(0) + + config = {'run.references': ['tests/acceptance/'], + 'filter.by_tags.tags': ['accel:kvm,arch:%s' % os.uname()[4]]}
If we want forks to use their own set of tags, it would be better to provide an uniform way, not adding new test entry point for each set of fork tags. Could we consume a YAML config file instead? And provide templates so forks could adapt to their needs?
Thanks,
Phil.
Re: [PATCH 8/8] Tests: add custom test jobs
Quoted 116 lines · Philippe Mathieu-Daudé
Hi Cleber,
Quoted 12 lines · Cleber Rosa
Different users (or even companies) have different interests, and may want to run a reduced set of tests during development, or a larger set of tests during QE.
To cover these use cases, some example (but functional) jobs are introduced here:
1)
acceptance-all-targets.py: runs all arch agnostic tests on all built targets, unless there are conditions that make them not work out of the box ATM, then run all tests that are specific to predefined targets.Quoted 7 lines
2)
acceptance-kvm-only.py: runs only tests that require KVM and are specific to the host architecture.3)
qtest-unit.py: runs a combination of qtest and unit tests (in parallel).4)
qtest-unit-acceptance.py: runs a combineation of qtest, unit testsTypo "combination".
Quoted 75 lines
and acceptance tests (all of them in parallel)
To run the first two manually, follow the example bellow:
$ cd build $ make check-venv $ ./tests/venv/bin/python3 tests/jobs/acceptance-all-targets.py $ ./tests/venv/bin/python3 tests/jobs/acceptance-kvm-only.pyThe third and fouth example depends on information coming from Meson, so the easiest way to run it is:
$ cd build $ make check-qtest-unit $ make check-qtest-unit-acceptanceThese are based on Avocado's Job API, a way to customize an Avocado job execution beyond the possibilities of command line arguments. For more Job API resources, please refer to:
a) Job API Examples:
- https://github.com/avocado-framework/avocado/tree/master/examples/jobsb) Documentation about configurable features at the Job Level:
- https://avocado-framework.readthedocs.io/en/87.0/config/index.htmlc) Documentation about the TestSuite class
- https://avocado-framework.readthedocs.io/en/87.0/api/core/avocado.core.html#avocado.core.suite.TestSuited) Documentation about the Job class
- https://avocado-framework.readthedocs.io/en/87.0/api/core/avocado.core.html#avocado.core.job.JobSigned-off-by Cleber Rosa <[email protected]>--- configure | 2 +- tests/Makefile.include | 8 ++++ tests/jobs/acceptance-all-targets.py | 67 ++++++++++++++++++++++++++++ tests/jobs/acceptance-kvm-only.py | 35 +++++++++++++++ tests/jobs/qtest-unit-acceptance.py | 31 +++++++++++++ tests/jobs/qtest-unit.py | 24 ++++++++++ tests/jobs/utils.py | 22 +++++++++ 7 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 tests/jobs/acceptance-all-targets.py create mode 100644 tests/jobs/acceptance-kvm-only.py create mode 100644 tests/jobs/qtest-unit-acceptance.py create mode 100644 tests/jobs/qtest-unit.py create mode 100644 tests/jobs/utils.py(quoted diff) +2
-0+if __name__ == '__main__': + sys.exit(main())tests/jobs/acceptance-kvm-only.py new file +19
-0@@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +import os +import sys + +# This comes from tests/acceptance/avocado_qemu/__init__.py and should +# not be duplicated here. The solution is to have the "avocado_qemu" +# code and "python/qemu" available during build +BUILD_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) +if os.path.islink(os.path.dirname(os.path.dirname(__file__))): + # The link to the acceptance tests dir in the source code directory + lnk = os.path.dirname(os.path.dirname(__file__)) + #: The QEMU root source directory + SOURCE_DIR = os.path.dirname(os.path.dirname(os.readlink(lnk))) +else: + SOURCE_DIR = BUILD_DIR +sys.path.append(os.path.join(SOURCE_DIR, 'python')) + +from avocado.core.job import Jobtests/jobs/acceptance-kvm-only.py line 29
Quoted 10 lines
tests/jobs/acceptance-kvm-only.py new file +10
-0+ +from qemu.accel import kvm_available + + +def main(): + if not kvm_available(): + sys.exit(0) + + config = {'run.references': ['tests/acceptance/'], + 'filter.by_tags.tags': ['accel:kvm,arch:%s' % os.uname()[4]]}If we want forks to use their own set of tags, it would be better to provide an uniform way, not adding new test entry point for each set of fork tags. Could we consume a YAML config file instead? And provide templates so forks could adapt to their needs?
Quoted 4 lines
Thanks,
Phil.
Yes, it should be possible indeed. BTW, starting this kind of discussion is one of the main goals of this series.
With regards to your suggestion, I believe there's an audience and value to this KVM only job. But, your idea of a YAML config file is also very much valid.
Maybe even a job that retrieves the list of tags from a CI variable? That could allow people to run jobs for different subset of tests at "push" time, without the need to add committed changes to (YAML) config files.
Cheers,
- Cleber.
Quoted 18 lines · Cleber Rosa
Different users (or even companies) have different interests, and may want to run a reduced set of tests during development, or a larger set of tests during QE.
To cover these use cases, this introduces some example (but functional) jobs.
It's expected that some common jobs will come up from common requirements for different users (and maybe be added to a common location such as tests/jobs), and that very specific jobs will be added to directories specific to certain groups, say "contrib/com.redhat/jobs" or the like.
This series does*not* add new jobs to GitLab CI pipeline, but this is expected to be done later on custom runners. That is, custom runners could be used for custom jobs. Anyway, a GitLab CI pipeline can be seen here:
Quoted 5 lines
https://gitlab.com/cleber.gnu/qemu/-/pipelines/287210066
This is based on the Avocado version bump patch:
https://lists.gnu.org/archive/html/qemu-devel/2021-04/msg02391.html
I admit I haven't even having read the patches (only the diffstat), but still: documentation please.
Paolo
Quoted 21 lines · Paolo Bonzini
Quoted 20 lines · Cleber Rosa
Different users (or even companies) have different interests, and may want to run a reduced set of tests during development, or a larger set of tests during QE.
To cover these use cases, this introduces some example (but functional) jobs.
It's expected that some common jobs will come up from common requirements for different users (and maybe be added to a common location such as tests/jobs), and that very specific jobs will be added to directories specific to certain groups, say "contrib/com.redhat/jobs" or the like.
This series does*not* add new jobs to GitLab CI pipeline, but this is expected to be done later on custom runners. That is, custom runners could be used for custom jobs. Anyway, a GitLab CI pipeline can be seen here:
Quoted 9 lines
Quoted 3 lines
This is based on the Avocado version bump patch:
https://lists.gnu.org/archive/html/qemu-devel/2021-04/msg02391.html
I admit I haven't even having read the patches (only the diffstat), but
still: documentation please.Paolo
Hi Paolo,
Absolutely, formal docs are very much needed and will be provided.
For now, please refer to patch 8's commit message. It contains basic usage information for these jobs, and pointers to external documentation.
PS: I'm very much interested in knowing what are user's first questions or use cases, so that I can tune the documentation accordingly. Questions and ideas like the one from Phil (about a YAML config file) would definitely help me to write a more relevant set of docs.
Thanks,
- Cleber.