Skip to content

Commit e8e4298

Browse files
committed
tests: Use separate virtual environment for avocado
This reverts commits eea2d14 ("Makefile: remove $(TESTS_PYTHON)", 2023-05-26) and 9c6692d ("tests: Use configure-provided pyvenv for tests", 2023-05-18). Right now, there is a conflict between wanting a ">=" constraint when using a distro-provided package and wanting a "==" constraint when installing Avocado from PyPI; this would provide the best of both worlds in terms of resiliency for both distros that have required packages and distros that don't. The conflict is visible also for meson, where we would like to install the latest 0.63.x version but also accept a distro 1.1.x version. But it is worse for avocado, for two reasons: 1) we cannot use an "==" constraint to install avocado if the venv includes a system avocado. The distro will package plugins that have "==" constraints on the version that is included in the distro, and, using "pip install avocado==88.1" on a venv that includes system packages will result in this error: ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. avocado-framework-plugin-varianter-yaml-to-mux 98.0 requires avocado-framework==98.0, but you have avocado-framework 88.1 which is incompatible. avocado-framework-plugin-result-html 98.0 requires avocado-framework==98.0, but you have avocado-framework 88.1 which is incompatible. make[1]: Leaving directory '/home/berrange/src/virt/qemu/build' 2) we cannot use ">=" either if the venv does _not_ include a system avocado, because that would result in the installation of v101.0 which is the one we've just reverted. So the idea is to encode the dependencies as an (acceptable, locked) tuple, like this hypothetical TOML that would be committed inside python/ and used by mkvenv.py: [meson] meson = { minimum = "0.63.0", install = "0.63.3", canary = "meson" } [docs] # 6.0 drops support for Python 3.7 sphinx = { minimum = "1.6", install = "<6.0", canary = "sphinx-build" } sphinx_rtd_theme = { minimum = "0.5" } [avocado] avocado-framework = { minimum = "88.1", install = "88.1", canary = "avocado" } Once this is implemented, it would also be possible to install avocado in pyvenv/ using "mkvenv.py ensure", thus using the distro package on Fedora and CentOS Stream (the only distros where it's available). But until this is implemented, keep avocado in a separate venv. There is still the benefit of using a single python for meson custom_targets and for sphinx. Signed-off-by: Paolo Bonzini <[email protected]>
1 parent eaf245b commit e8e4298

File tree

8 files changed

+28
-29
lines changed

8 files changed

+28
-29
lines changed

.gitlab-ci.d/buildtest.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ crash-test-debian:
103103
script:
104104
- cd build
105105
- make NINJA=":" check-venv
106-
- pyvenv/bin/python3 scripts/device-crash-test -q --tcg-only ./qemu-system-i386
106+
- tests/venv/bin/python3 scripts/device-crash-test -q --tcg-only ./qemu-system-i386
107107

108108
build-system-fedora:
109109
extends:
@@ -146,8 +146,8 @@ crash-test-fedora:
146146
script:
147147
- cd build
148148
- make NINJA=":" check-venv
149-
- pyvenv/bin/python3 scripts/device-crash-test -q ./qemu-system-ppc
150-
- pyvenv/bin/python3 scripts/device-crash-test -q ./qemu-system-riscv32
149+
- tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-ppc
150+
- tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-riscv32
151151

152152
build-system-centos:
153153
extends:

docs/devel/acpi-bits.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,19 @@ Under ``tests/avocado/`` as the root we have:
6161
::
6262

6363
$ make check-venv (needed only the first time to create the venv)
64-
$ ./pyvenv/bin/avocado run -t acpi tests/avocado
64+
$ ./tests/venv/bin/avocado run -t acpi tests/avocado
6565

6666
The above will run all acpi avocado tests including this one.
6767
In order to run the individual tests, perform the following:
6868
::
6969

70-
$ ./pyvenv/bin/avocado run tests/avocado/acpi-bits.py --tap -
70+
$ ./tests/venv/bin/avocado run tests/avocado/acpi-bits.py --tap -
7171

7272
The above will produce output in tap format. You can omit "--tap -" in the
7373
end and it will produce output like the following:
7474
::
7575

76-
$ ./pyvenv/bin/avocado run tests/avocado/acpi-bits.py
76+
$ ./tests/venv/bin/avocado run tests/avocado/acpi-bits.py
7777
Fetching asset from tests/avocado/acpi-bits.py:AcpiBitsTest.test_acpi_smbios_bits
7878
JOB ID : eab225724da7b64c012c65705dc2fa14ab1defef
7979
JOB LOG : /home/anisinha/avocado/job-results/job-2022-10-10T17.58-eab2257/job.log

docs/devel/testing.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -888,9 +888,9 @@ You can run the avocado tests simply by executing:
888888
889889
make check-avocado
890890
891-
This involves the automatic installation, from PyPI, of all the
892-
necessary avocado-framework dependencies into the QEMU venv within the
893-
build tree (at ``./pyvenv``). Test results are also saved within the
891+
This involves the automatic creation of Python virtual environment
892+
within the build tree (at ``tests/venv``) which will have all the
893+
right dependencies, and will save tests results also within the
894894
build tree (at ``tests/results``).
895895

896896
Note: the build environment must be using a Python 3 stack, and have
@@ -947,7 +947,7 @@ may be invoked by running:
947947

948948
.. code::
949949
950-
pyvenv/bin/avocado run $OPTION1 $OPTION2 tests/avocado/
950+
tests/venv/bin/avocado run $OPTION1 $OPTION2 tests/avocado/
951951
952952
Note that if ``make check-avocado`` was not executed before, it is
953953
possible to create the Python virtual environment with the dependencies
@@ -962,20 +962,20 @@ a test file. To run tests from a single file within the build tree, use:
962962

963963
.. code::
964964
965-
pyvenv/bin/avocado run tests/avocado/$TESTFILE
965+
tests/venv/bin/avocado run tests/avocado/$TESTFILE
966966
967967
To run a single test within a test file, use:
968968

969969
.. code::
970970
971-
pyvenv/bin/avocado run tests/avocado/$TESTFILE:$TESTCLASS.$TESTNAME
971+
tests/venv/bin/avocado run tests/avocado/$TESTFILE:$TESTCLASS.$TESTNAME
972972
973973
Valid test names are visible in the output from any previous execution
974974
of Avocado or ``make check-avocado``, and can also be queried using:
975975

976976
.. code::
977977
978-
pyvenv/bin/avocado list tests/avocado
978+
tests/venv/bin/avocado list tests/avocado
979979
980980
Manual Installation
981981
~~~~~~~~~~~~~~~~~~~

scripts/ci/org.centos/stream/8/x86_64/test-avocado

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# KVM and x86_64, or tests that are generic enough to be valid for all
55
# targets. Such a test list can be generated with:
66
#
7-
# ./pyvenv/bin/avocado list --filter-by-tags-include-empty \
7+
# ./tests/venv/bin/avocado list --filter-by-tags-include-empty \
88
# --filter-by-tags-include-empty-key -t accel:kvm,arch:x86_64 \
99
# tests/avocado/
1010
#
@@ -22,7 +22,7 @@
2222
# - tests/avocado/virtio_check_params.py:VirtioMaxSegSettingsCheck.test_machine_types
2323
#
2424
make get-vm-images
25-
./pyvenv/bin/avocado run \
25+
./tests/venv/bin/avocado run \
2626
--job-results-dir=tests/results/ \
2727
tests/avocado/boot_linux.py:BootLinuxX8664.test_pc_i440fx_kvm \
2828
tests/avocado/boot_linux.py:BootLinuxX8664.test_pc_q35_kvm \

scripts/device-crash-test

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ except ModuleNotFoundError as exc:
4343
print(f"Module '{exc.name}' not found.")
4444
print(" Try 'make check-venv' from your build directory,")
4545
print(" and then one way to run this script is like so:")
46-
print(f' > $builddir/pyvenv/bin/python3 "{path}"')
46+
print(f' > $builddir/tests/venv/bin/python3 "{path}"')
4747
sys.exit(1)
4848

4949
logger = logging.getLogger('device-crash-test')

tests/Makefile.include

+9-7
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ distclean-tcg: $(DISTCLEAN_TCG_TARGET_RULES)
8989
# Build up our target list from the filtered list of ninja targets
9090
TARGETS=$(patsubst libqemu-%.fa, %, $(filter libqemu-%.fa, $(ninja-targets)))
9191

92-
TESTS_VENV_TOKEN=$(BUILD_DIR)/pyvenv/tests.group
92+
TESTS_VENV_DIR=$(BUILD_DIR)/tests/venv
9393
TESTS_VENV_REQ=$(SRC_PATH)/tests/requirements.txt
9494
TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results
95+
TESTS_PYTHON=$(TESTS_VENV_DIR)/bin/python3
9596
ifndef AVOCADO_TESTS
9697
AVOCADO_TESTS=tests/avocado
9798
endif
@@ -107,10 +108,11 @@ else
107108
endif
108109

109110
quiet-venv-pip = $(quiet-@)$(call quiet-command-run, \
110-
$(PYTHON) -m pip -q --disable-pip-version-check $1, \
111+
$(TESTS_PYTHON) -m pip -q --disable-pip-version-check $1, \
111112
"VENVPIP","$1")
112113

113-
$(TESTS_VENV_TOKEN): $(TESTS_VENV_REQ)
114+
$(TESTS_VENV_DIR): $(TESTS_VENV_REQ)
115+
$(call quiet-command, $(PYTHON) -m venv $@, VENV, $@)
114116
$(call quiet-venv-pip,install -e "$(SRC_PATH)/python/")
115117
$(call quiet-venv-pip,install -r $(TESTS_VENV_REQ))
116118
$(call quiet-command, touch $@)
@@ -119,7 +121,7 @@ $(TESTS_RESULTS_DIR):
119121
$(call quiet-command, mkdir -p $@, \
120122
MKDIR, $@)
121123

122-
check-venv: $(TESTS_VENV_TOKEN)
124+
check-venv: $(TESTS_VENV_DIR)
123125

124126
FEDORA_31_ARCHES_TARGETS=$(patsubst %-softmmu,%, $(filter %-softmmu,$(TARGETS)))
125127
FEDORA_31_ARCHES_CANDIDATES=$(patsubst ppc64,ppc64le,$(FEDORA_31_ARCHES_TARGETS))
@@ -129,7 +131,7 @@ FEDORA_31_DOWNLOAD=$(filter $(FEDORA_31_ARCHES),$(FEDORA_31_ARCHES_CANDIDATES))
129131
# download one specific Fedora 31 image
130132
get-vm-image-fedora-31-%: check-venv
131133
$(call quiet-command, \
132-
$(PYTHON) -m avocado vmimage get \
134+
$(TESTS_PYTHON) -m avocado vmimage get \
133135
--distro=fedora --distro-version=31 --arch=$*, \
134136
"AVOCADO", "Downloading avocado tests VM image for $*")
135137

@@ -138,7 +140,7 @@ get-vm-images: check-venv $(patsubst %,get-vm-image-fedora-31-%, $(FEDORA_31_DOW
138140

139141
check-avocado: check-venv $(TESTS_RESULTS_DIR) get-vm-images
140142
$(call quiet-command, \
141-
$(PYTHON) -m avocado \
143+
$(TESTS_PYTHON) -m avocado \
142144
--show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \
143145
$(if $(AVOCADO_TAGS),, --filter-by-tags-include-empty \
144146
--filter-by-tags-include-empty-key) \
@@ -161,7 +163,7 @@ check:
161163
check-build: run-ninja
162164

163165
check-clean:
164-
rm -rf $(TESTS_RESULTS_DIR)
166+
rm -rf $(TESTS_VENV_DIR) $(TESTS_RESULTS_DIR)
165167

166168
clean: check-clean clean-tcg
167169
distclean: distclean-tcg

tests/requirements.txt

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# Add Python module requirements, one per line, to be installed
2-
# in the qemu build_dir/pyvenv Python virtual environment. For more info,
2+
# in the tests/venv Python virtual environment. For more info,
33
# refer to: https://pip.pypa.io/en/stable/user_guide/#id1
4-
#
5-
# Note that qemu.git/python/ is implicitly installed to this venv when
6-
# 'make check-venv' is run, and will persist until configure is run
7-
# again.
4+
# Note that qemu.git/python/ is always implicitly installed.
85
avocado-framework==88.1
96
pycdlib==1.11.0

tests/vm/Makefile.include

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ifeq ($(realpath $(SRC_PATH)),$(realpath .))
55
VM_PYTHON = PYTHONPATH=$(SRC_PATH)/python /usr/bin/env python3
66
VM_VENV =
77
else
8-
VM_PYTHON = $(PYTHON)
8+
VM_PYTHON = $(TESTS_PYTHON)
99
VM_VENV = check-venv
1010
endif
1111

0 commit comments

Comments
 (0)