Skip to content

Commit

Permalink
[cirrus] Run tests on latest daily builds for ubuntu
Browse files Browse the repository at this point in the history
Fix the issues reported by the tests on the new version of ubuntu

Resolves: sosreport#3587
Closes: sosreport#3588
Signed-off-by: Arif Ali <[email protected]>
  • Loading branch information
arif-ali committed Apr 8, 2024
1 parent 36b2b7d commit 9155b17
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 20 deletions.
54 changes: 51 additions & 3 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,22 @@ env:
FEDORA_PROJECT: "fedora-cloud"
SOS_PROJECT: "sos-devel-jobs"
UBUNTU_PROJECT: "ubuntu-os-cloud"
UBUNTU_DEVEL_PROJECT: "ubuntu-os-cloud-devel"

# Images exist on GCP already
CENTOS_9_IMAGE_NAME: "centos-stream-9-v20230809"
CENTOS_8_IMAGE_NAME: "centos-stream-8-v20230809"
DEBIAN_IMAGE_NAME: "debian-11-bullseye-v20230809"
FEDORA_IMAGE_NAME: "fedora-cloud-base-gcp-38-1-6-x86-64"
FEDORA_PRIOR_IMAGE_NAME: "fedora-cloud-base-gcp-37-1-7-x86-64"

UBUNTU_DEB_IMAGE_NAME: "ubuntu-minimal-2310-mantic-amd64-v20231030"
UBUNTU_LATEST_IMAGE_NAME: "ubuntu-2310-mantic-amd64-v20231031"
UBUNTU_IMAGE_NAME: "ubuntu-2204-jammy-v20231030"
UBUNTU_PRIOR_IMAGE_NAME: "ubuntu-2004-focal-v20231101"
UBUNTU_PRIOR2_IMAGE_NAME: "ubuntu-1804-bionic-v20230605"
UBUNTU_SNAP_IMAGE_NAME: "ubuntu-2204-jammy-v20231030"
UBUNTU_DEVEL_FAMILY_NAME: "ubuntu-2404-lts-amd64"

# Curl-command prefix for downloading task artifacts, simply add the
# the url-encoded task name, artifact name, and path as a suffix.
Expand Down Expand Up @@ -226,14 +229,39 @@ report_stageone_task:
pip3 install avocado-framework==94.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: PYTHONPATH=. avocado run tests/unittests/
main_script: PYTHONPATH=tests/ avocado run -p TESTLOCAL=true --test-runner=runner -t stageone tests/{cleaner,collect,report,vendor}_tests
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
on_failure:
fail_script: &faillogs |
ls -d /var/tmp/avocado* /root/avocado* 2> /dev/null | xargs tar cf sos-fail-logs.tar
log_artifacts: &logs
path: "sos-fail-logs.tar"

report_stageone_daily_task:
alias: "stageone_daily_report"
name: "Report Stage One - ${UBUNTU_DEVEL_FAMILY_NAME}"
allow_failures: true
depends_on:
- snap_build
gce_instance:
image_project: ${UBUNTU_DEVEL_PROJECT}
image_family: ${UBUNTU_DEVEL_FAMILY_NAME}
type: e2-medium
environment:
PKG: "snap"
setup_script: *setup
avocado_install_script: &avocado_setup |
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:
fail_script: *faillogs
log_artifacts: *logs

# IFF the stage one tests all pass, then run stage two for latest distros
report_stagetwo_task:
alias: "stagetwo_report"
Expand All @@ -255,7 +283,27 @@ report_stagetwo_task:
if [ $(command -v dnf) ]; then
dnf -y install python3-pexpect
fi
main_script: PYTHONPATH=tests/ avocado run -p TESTLOCAL=true --test-runner=runner -t stagetwo tests/{cleaner,collect,report,vendor}_tests
main_script: &stagetwo_test |
PYTHONPATH=tests/ avocado run -p TESTLOCAL=true --test-runner=runner -t stagetwo tests/{cleaner,collect,report,vendor}_tests
on_failure:
fail_script: *faillogs
log_artifacts: *logs

report_stagetwo_daily_task:
alias: "stagetwo_daily_report"
name: "Report Stage Two - ${UBUNTU_DEVEL_FAMILY_NAME}"
allow_failures: true
depends_on: stageone_daily_report
timeout_in: 45m
gce_instance:
image_project: ${UBUNTU_DEVEL_PROJECT}
image_family: ${UBUNTU_DEVEL_FAMILY_NAME}
type: e2-medium
environment:
PKG: "snap"
setup_script: *setup
avocado_install_script: *avocado_setup
main_script: *stagetwo_test
on_failure:
fail_script: *faillogs
log_artifacts: *logs
Expand Down
1 change: 1 addition & 0 deletions sos/policies/runtimes/lxd.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class LxdContainerRuntime(ContainerRuntime):
def check_is_active(self):
# the daemon must be running
if (is_executable('lxc', self.policy.sysroot) and
self.policy.package_manager.pkg_by_name('lxd') and
(self.policy.init_system.is_running('lxd') or
self.policy.init_system.is_running('snap.lxd.daemon'))):
self.active = True
Expand Down
4 changes: 2 additions & 2 deletions tests/cleaner_tests/basic_function_tests/report_with_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def test_binary_removed(self):
self.assertFileNotCollected('var/log/binary_test.tar.xz')

def test_binaries_removed_reported(self):
self.assertOutputContains('\[removed .* unprocessable files\]')
self.assertOutputContains(r'\[removed .* unprocessable files\]')


class KeepBinaryFilesTest(StageTwoReportTest):
Expand All @@ -142,4 +142,4 @@ def test_binary_is_in_archive(self):
self.assertFileCollected('var/log/binary_test.tar.xz')

def test_no_binaries_reported_removed(self):
self.assertOutputNotContains('\[removed .* unprocessable files\]')
self.assertOutputNotContains(r'\[removed .* unprocessable files\]')
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 @@ -65,7 +65,7 @@ class CollectOptionsHelpTest(StageOneOutputTest):

@skipIf(PEXPECT_PRESENT is False, "python3-pexpect not installed locally")
def test_cluster_profiles_shown(self):
_out = re.search("Use the short name with --cluster-type or cluster options \(-c\)(.*?)The following cluster options are available:",
_out = re.search(r"Use the short name with --cluster-type or cluster options \(-c\)(.*?)The following cluster options are available:",
self.cmd_output.stdout, re.S).group(1).splitlines()
_profs = {}
for ln in _out:
Expand Down
6 changes: 3 additions & 3 deletions tests/report_tests/basic_report_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_debug_in_logs_verbose(self):

def test_debug_not_printed_to_console(self):
self.assertOutputNotContains('added cmd output')
self.assertOutputNotContains('\[archive:.*\]')
self.assertOutputNotContains(r'\[archive:.*\]')

def test_postproc_called(self):
self.assertSosLogContains('substituting scrpath')
Expand Down Expand Up @@ -61,11 +61,11 @@ class LogLevelTest(StageOneReportTest):
sos_cmd = '-vvv -o kernel,host,boot,filesys'

def test_archive_logging_enabled(self):
self.assertSosLogContains('DEBUG: \[archive:.*\]')
self.assertSosLogContains(r'DEBUG: \[archive:.*\]')
self.assertSosLogContains('Making leading paths for')

def test_debug_printed_to_console(self):
self.assertOutputContains('\[plugin:.*\]')
self.assertOutputContains(r'\[plugin:.*\]')


class RestrictedSoSReport(StageOneReportTest):
Expand Down
5 changes: 3 additions & 2 deletions tests/report_tests/encryption_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ class EncryptedReportTest(StageOneReportTest):
sos_cmd = "-o kernel --encrypt-pass %s" % encrypt_pass

def test_archive_gpg_encrypted(self):
self.assertOutputContains('/.*sosreport-.*tar.*\.gpg')
self.assertOutputContains(r'/.*sosreport-.*tar.*\.gpg')
_cmd = "file %s" % self.encrypted_path
res = process.run(_cmd)
self.assertTrue("GPG symmetrically encrypted data" in res.stdout.decode())
self.assertTrue(("GPG symmetrically encrypted data" in res.stdout.decode())
or ("PGP symmetric key encrypted dat" in res.stdout.decode()))

def test_tarball_named_secure(self):
self.assertTrue('secured-' in self.encrypted_path)
Expand Down
6 changes: 3 additions & 3 deletions tests/report_tests/exception_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class InvalidPluginEnabledTest(StageOneReportExceptionTest):
sos_cmd = '-o foobar'

def test_caught_invalid_plugin(self):
self.assertOutputContains('a non-existing plugin \(foobar\)')
self.assertOutputContains(r'a non-existing plugin \(foobar\)')


class InvalidPluginOptionTest(StageOneReportExceptionTest):
Expand All @@ -28,7 +28,7 @@ class InvalidPluginOptionTest(StageOneReportExceptionTest):
sos_cmd = '-o kernel -k kernel.colonel=on'

def test_caught_invalid_plugin_option(self):
self.assertOutputContains('no such option "colonel" for plugin \(kernel\)')
self.assertOutputContains(r'no such option "colonel" for plugin \(kernel\)')


class InvalidReportOptionTest(StageOneReportExceptionTest):
Expand All @@ -39,7 +39,7 @@ class InvalidReportOptionTest(StageOneReportExceptionTest):
sos_cmd = '--magic'

def test_caught_invalid_option(self):
self.assertOutputContains('unrecognized arguments\: --magic')
self.assertOutputContains(r'unrecognized arguments\: --magic')


class InvalidPluginDisableTest(StageOneReportTest):
Expand Down
4 changes: 2 additions & 2 deletions tests/report_tests/options_tests/options_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ def test_plugins_only_from_config(self):

def test_plugopts_logged_from_config(self):
self.assertSosLogContains(
"Set kernel plugin option to \(name=with-timer, desc='gather /proc/timer\* statistics', value=True, default=False\)"
r"Set kernel plugin option to \(name=with-timer, desc='gather /proc/timer\* statistics', value=True, default=False\)"
)
self.assertSosLogContains(
"Set kernel plugin option to \(name=trace, desc='gather /sys/kernel/debug/tracing/trace file', value=True, default=False\)"
r"Set kernel plugin option to \(name=trace, desc='gather /sys/kernel/debug/tracing/trace file', value=True, default=False\)"
)

def test_disabled_plugopts_not_loaded(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/sos_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def get_encrypted_path(self):
override
"""
try:
return re.findall('/.*sosreport-.*tar.*\.gpg', self.cmd_output.stdout)[-1]
return re.findall(r'/.*sosreport-.*tar.*\.gpg', self.cmd_output.stdout)[-1]
except:
return None

Expand Down
6 changes: 3 additions & 3 deletions tests/unittests/policy_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def setUp(self):
self.pm = RpmPackageManager()

def test_load_all_packages(self):
self.assertNotEquals(self.pm.packages, {})
self.assertNotEqual(self.pm.packages, {})

def test_pkg_is_formatted(self):
kpkg = self.pm.pkg_by_name('coreutils')
Expand All @@ -125,7 +125,7 @@ def setUp(self):
self.pm = DpkgPackageManager()

def test_load_all_packages(self):
self.assertNotEquals(self.pm.packages, {})
self.assertNotEqual(self.pm.packages, {})

def test_pkg_is_formatted(self):
kpkg = self.pm.pkg_by_name('coreutils')
Expand All @@ -141,7 +141,7 @@ def setUp(self):
fallbacks=[DpkgPackageManager])

def test_load_all_packages(self):
self.assertNotEquals(self.pm.packages, {})
self.assertNotEqual(self.pm.packages, {})

def test_pkg_is_formatted(self):
kpkg = self.pm.pkg_by_name('coreutils')
Expand Down

0 comments on commit 9155b17

Please sign in to comment.