From 984581beb422a5464249cd6ef506492cab689a31 Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Wed, 10 Apr 2024 01:05:13 +0100 Subject: [PATCH] [avocado] Upgrade avocado to 103.X LTS * Extra changes required due to module and function changes in new avocado * CentOS Stream is now seen as centos-stream in avocado instead of centos * Fine tune tox for stage tests Closes: #3588 Resolves: #3594 Co-authored-by: Jake Hunsaker Signed-off-by: Arif Ali --- .cirrus.yml | 16 +++++----------- tests/collect_tests/help_output_tests.py | 2 +- tests/sos_tests.py | 11 +++++------ tox.ini | 21 +++++++++++---------- 4 files changed, 22 insertions(+), 28 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 48de6c3d61..33c48068fc 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -148,7 +148,7 @@ deb_build_task: apt -y install devscripts equivs python3-pip mk-build-deps apt -y install ./sosreport-build-deps*.deb - pip3 install avocado-framework==94.0 --break-system-packages + pip3 install "avocado-framework<104.0" --break-system-packages main_script: | dpkg-buildpackage -b -us -uc -rfakeroot -m --build-by="noreply@canonical.com" prep_artifacts_script: mv ../*.deb ./sos_cirrus.deb @@ -240,13 +240,13 @@ report_stageone_task: fi PIP_EXTRA="" [[ $(pip3 install --help | grep break-system) ]] && PIP_EXTRA="--break-system-packages" - pip3 install avocado-framework==94.0 ${PIP_EXTRA} + pip3 install "avocado-framework<104.0" ${PIP_EXTRA} # run the unittests separately as they require a different PYTHONPATH in # order for the imports to work properly under avocado unittest_script: &unit_test | PYTHONPATH=. avocado run tests/unittests/ main_script: &stageone_test - PYTHONPATH=tests/ avocado run -p TESTLOCAL=true --test-runner=runner -t stageone tests/{cleaner,collect,report,vendor}_tests + PYTHONPATH=tests/ avocado run -p TESTLOCAL=true --max-parallel-tasks=1 -t stageone tests/{cleaner,collect,report,vendor}_tests on_failure: fail_script: &faillogs | ls -d /var/tmp/avocado* /root/avocado* 2> /dev/null | xargs tar cf sos-fail-logs.tar @@ -266,11 +266,6 @@ report_stageone_daily_task: environment: PKG: "snap" setup_script: *setup - avocado_install_script: &avocado_setup | - pip3 uninstall -y avocado-framework --break-system-packages - git clone --single-branch -b 92lts https://github.com/avocado-framework/avocado.git - cd avocado - make install unittest_script: *unit_test main_script: *stageone_test on_failure: @@ -299,7 +294,7 @@ report_stagetwo_task: dnf -y install python3-pexpect fi main_script: &stagetwo_test | - PYTHONPATH=tests/ avocado run -p TESTLOCAL=true --test-runner=runner -t stagetwo tests/{cleaner,collect,report,vendor}_tests + PYTHONPATH=tests/ avocado run -p TESTLOCAL=true --max-parallel-tasks=1 -t stagetwo tests/{cleaner,collect,report,vendor}_tests on_failure: fail_script: *faillogs log_artifacts: *logs @@ -317,7 +312,6 @@ report_stagetwo_daily_task: environment: PKG: "snap" setup_script: *setup - avocado_install_script: *avocado_setup main_script: *stagetwo_test on_failure: fail_script: *faillogs @@ -349,7 +343,7 @@ report_foreman_task: FOREMAN_VER: "3.7" setup_script: *setup foreman_setup_script: ./tests/test_data/foreman_setup.sh - main_script: PYTHONPATH=tests/ avocado run -p TESTLOCAL=true --test-runner=runner -t foreman tests/product_tests/foreman/ + main_script: PYTHONPATH=tests/ avocado run -p TESTLOCAL=true --max-parallel-tasks=1 -t foreman tests/product_tests/foreman/ on_failure: fail_script: *faillogs log_artifacts: *logs diff --git a/tests/collect_tests/help_output_tests.py b/tests/collect_tests/help_output_tests.py index 4a253f561d..88f6d212ef 100644 --- a/tests/collect_tests/help_output_tests.py +++ b/tests/collect_tests/help_output_tests.py @@ -14,7 +14,7 @@ from sos_tests import StageOneOutputTest, SOS_REPO_ROOT, skipIf installer = software_manager -sm = installer.SoftwareManager() +sm = installer.manager.SoftwareManager() PEXPECT_PRESENT = sm.check_installed('python3-pexpect') diff --git a/tests/sos_tests.py b/tests/sos_tests.py index 4ba98eac05..59374501cc 100644 --- a/tests/sos_tests.py +++ b/tests/sos_tests.py @@ -12,6 +12,7 @@ from avocado import Test from avocado.utils import archive, process, distro, software_manager from avocado.utils.cpu import get_arch +from avocado.utils.software_manager import distro_packages from fnmatch import fnmatch import glob @@ -30,7 +31,7 @@ SOS_TEST_DATA_DIR = os.path.realpath(os.path.join(SOS_TEST_DIR, 'test_data')) SOS_TEST_BIN = os.path.realpath(os.path.join(SOS_TEST_DIR, '../bin/sos')) -RH_DIST = ['rhel', 'centos', 'fedora'] +RH_DIST = ['rhel', 'centos', 'fedora', 'centos-stream'] UBUNTU_DIST = ['Ubuntu', 'debian'] @@ -816,10 +817,7 @@ class StageTwoReportTest(BaseSoSReportTest): def setUp(self): self.end_of_test_case = False - # seems awkward, but check_installed() and remove() are not exposed - # together with install_distro_packages() - self.installer = software_manager - self.sm = self.installer.SoftwareManager() + self.sm = software_manager.manager.SoftwareManager() for dist in self.packages: if isinstance(self.packages[dist], str): @@ -834,6 +832,7 @@ def setUp(self): self.packages['fedora'] = self.packages['rhel'] if 'rhel' in keys: self.packages['centos'] = self.packages['rhel'] + self.packages['centos-stream'] = self.packages['rhel'] super(StageTwoReportTest, self).setUp() @@ -894,7 +893,7 @@ def setup_mocked_packages(self): self._strip_installed_packages() if not self.packages[self.local_distro]: return - installed = self.installer.install_distro_packages(self.packages) + installed = distro_packages.install_distro_packages(self.packages) if not installed: raise Exception( "Unable to install requested packages %s" diff --git a/tox.ini b/tox.ini index 9d4b16e7f9..d7734ab64a 100644 --- a/tox.ini +++ b/tox.ini @@ -4,10 +4,17 @@ envlist = flake8 [testenv] deps = -r{toxinidir}/requirements.txt - avocado-framework==94.0 + avocado-framework<104.0 python_magic setenv = PYTHONPATH = {toxinidir}/tests +avocado_cmd = + avocado run -p TESTLOCAL=true --max-parallel-tasks=1 +stage_tests = + tests/cleaner_tests \ + tests/collect_tests \ + tests/report_tests \ + tests/vendor_tests [testenv:flake8] deps = flake8 @@ -27,23 +34,17 @@ commands = [testenv:stageone_tests] basepython = python3 commands = - avocado run -p TESTLOCAL=true --test-runner=runner -t stageone tests/cleaner_tests - avocado run -p TESTLOCAL=true --test-runner=runner -t stageone tests/collect_tests - avocado run -p TESTLOCAL=true --test-runner=runner -t stageone tests/report_tests - avocado run -p TESTLOCAL=true --test-runner=runner -t stageone tests/vendor_tests + {[testenv]avocado_cmd} -t stageone {[testenv]stage_tests} [testenv:stagetwo_tests] basepython = python3 commands = - avocado run -p TESTLOCAL=true --test-runner=runner -t stagetwo tests/cleaner_tests - avocado run -p TESTLOCAL=true --test-runner=runner -t stagetwo tests/collect_tests - avocado run -p TESTLOCAL=true --test-runner=runner -t stagetwo tests/report_tests - avocado run -p TESTLOCAL=true --test-runner=runner -t stagetwo tests/vendor_tests + {[testenv]avocado_cmd} -t stagetwo {[testenv]stage_tests} [testenv:foreman_tests] basepython = python3 commands = - avocado run -p TESTLOCAL=true --test-runner=runner -t foreman tests/product_tests/foreman/ + {[testenv]avocado_cmd} -t foreman tests/product_tests/foreman/ [testenv:nosetests] basepython = python3