From f3e270bb321f24e1bc32c5911c156053565cb2ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Mon, 13 May 2024 17:46:02 +0100 Subject: tests: make independent of main project list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The tests currently rely on the global list of projects. We're about to delete those, so we must import projects needed for tests to a private directory. A couple of tests are changed to use different projects to reduce the number we keep. Signed-off-by: Daniel P. Berrangé --- tests/conftest.py | 3 +- tests/data/projects/libvirt-go-module.yml | 6 ++ tests/data/projects/libvirt-go-xml-module.yml | 2 + tests/data/projects/libvirt.yml | 82 +++++++++++++++++++++++++++ tests/test_commands.py | 6 +- tests/test_inventory.py | 2 +- 6 files changed, 96 insertions(+), 5 deletions(-) create mode 100644 tests/data/projects/libvirt-go-module.yml create mode 100644 tests/data/projects/libvirt-go-xml-module.yml create mode 100644 tests/data/projects/libvirt.yml diff --git a/tests/conftest.py b/tests/conftest.py index 0ae8a31..7c6a7dc 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,6 +6,7 @@ from pathlib import Path from lcitool.packages import Packages from lcitool.projects import Projects from lcitool.targets import Targets +from lcitool.util import DataDir from test_utils.mocks import libvirt, gi import test_utils.utils as test_utils @@ -27,7 +28,7 @@ def pytest_configure(config): # These needs to be a global in order to compute ALL_PROJECTS and ALL_TARGETS # at collection time. Tests do not access it and use the fixtures below. -_PROJECTS = Projects() +_PROJECTS = Projects(DataDir(Path(test_utils.base_data_dir()))) _TARGETS = Targets() ALL_PROJECTS = sorted(_PROJECTS.names + list(_PROJECTS.internal.keys())) diff --git a/tests/data/projects/libvirt-go-module.yml b/tests/data/projects/libvirt-go-module.yml new file mode 100644 index 0000000..5e6304f --- /dev/null +++ b/tests/data/projects/libvirt-go-module.yml @@ -0,0 +1,6 @@ +packages: + - ccache + - gcc + - go + - libc + - pkg-config diff --git a/tests/data/projects/libvirt-go-xml-module.yml b/tests/data/projects/libvirt-go-xml-module.yml new file mode 100644 index 0000000..790a543 --- /dev/null +++ b/tests/data/projects/libvirt-go-xml-module.yml @@ -0,0 +1,2 @@ +packages: + - go diff --git a/tests/data/projects/libvirt.yml b/tests/data/projects/libvirt.yml new file mode 100644 index 0000000..66c1fb6 --- /dev/null +++ b/tests/data/projects/libvirt.yml @@ -0,0 +1,82 @@ +--- +packages: + - apparmor + - augeas + - augeas-lenses + - bash-completion + - black + - ccache + - clang + - codespell + - cpp + - cppi + - cyrus-sasl + - device-mapper + - diffutils + - dlfcn + - dtrace + - dwarves + - ebtables + - firewalld-filesystem + - flake8 + - fuse + - gcc + - gettext + - gettext-native + - glib2 + - glusterfs + - gnutls + - grep + - ip + - iptables + - iscsiadm + - libacl + - libattr + - libaudit + - libblkid + - libc + - libcap-ng + - libcurl + - libiscsi + - libnbd + - libnl3 + - libnlroute3 + - libnuma + - libparted + - libpcap + - libpciaccess + - librbd + - libselinux + - libssh + - libssh2 + - libtirpc + - libudev + - libxml2 + - lvm2 + - make + - meson + - modprobe + - netcf + - ninja + - numad + - openwsman + - perl + - pkg-config + - polkit + - portablexdr + - python3 + - python3-docutils + - python3-pytest + - qemu-img + - readline + - rpmbuild + - sanlock + - sed + - showmount + - systemd-rpm-macros + - tc + - wireshark + - xen + - xmllint + - xsltproc + - yajl diff --git a/tests/test_commands.py b/tests/test_commands.py index f289de7..d59fe06 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -14,8 +14,8 @@ cli_args = [ ["--help"], ["targets"], ["projects"], - ["variables", "almalinux-8", "osinfo-db-tools"], - ["dockerfile", "almalinux-8", "osinfo-db-tools"], + ["variables", "almalinux-8", "libvirt-go-module"], + ["dockerfile", "almalinux-8", "libvirt-go-module"], ["manifest", "-n", Path(__file__).parent.parent.joinpath("examples", "manifest.yml")], ["container", "engines"] ] @@ -30,5 +30,5 @@ def test_commands(test_cli_args): # we're running the tests in a virtual env lcitool_path = Path(sys.prefix, "bin/lcitool") - subprocess.check_call([lcitool_path] + test_cli_args, + subprocess.check_call([lcitool_path, '-d', Path(__file__).parent.joinpath("data")] + test_cli_args, stdout=subprocess.DEVNULL) diff --git a/tests/test_inventory.py b/tests/test_inventory.py index 73c667f..7020882 100644 --- a/tests/test_inventory.py +++ b/tests/test_inventory.py @@ -55,7 +55,7 @@ def test_host_target_name(inventory): def test_group_vars(inventory, targets, packages, projects): target = BuildTarget(targets, packages, "fedora-39") - group_vars = inventory.get_group_vars(target, projects, ["nbdkit"]) + group_vars = inventory.get_group_vars(target, projects, ["libvirt"]) assert "nano" in group_vars["unwanted_packages"] assert "python3-libselinux" in group_vars["early_install_packages"] -- cgit v1.1