Skip to content

Commit

Permalink
[avocado] Upgrade avocado to 103.X LTS
Browse files Browse the repository at this point in the history
* 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: sosreport#3588
Resolves: sosreport#3594

Co-authored-by: Jake Hunsaker <[email protected]>
Signed-off-by: Arif Ali <[email protected]>
  • Loading branch information
arif-ali and TurboTurtle committed Apr 12, 2024
1 parent 93bcf51 commit 984581b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 28 deletions.
16 changes: 5 additions & 11 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]"
prep_artifacts_script: mv ../*.deb ./sos_cirrus.deb
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/collect_tests/help_output_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
11 changes: 5 additions & 6 deletions tests/sos_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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']


Expand Down Expand Up @@ -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):
Expand All @@ -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()

Expand Down Expand Up @@ -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"
Expand Down
21 changes: 11 additions & 10 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 984581b

Please sign in to comment.