Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/cleaner_tests/basic_function_tests/report_with_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ class ReportWithUserCustomisations(StageOneReportTest):
'BOOT_IMAGE,fs.dentry-state --skip-cleaning-files '
'proc/cmdline,sos_commands/*/sysctl* --no-update')

def pre_sos_setup(self):
self.setup_isolated_cleaner_cache()

# Will the 'tmp' be properly treated in path to working dir without
# raising an error?
# To make this test effective, we assume the test runs on a system / with
Expand Down
3 changes: 3 additions & 0 deletions tests/cleaner_tests/existing_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ class ExistingArchiveCleanTmpTest(StageTwoReportTest):
tests/test_data/{ARCHIVE}.tar.xz'
sos_component = 'clean'

def pre_sos_setup(self):
self.setup_isolated_cleaner_cache()

def test_sys_tmp_not_obfuscated(self):
""" Ensure that keywords avocado and ExistingArchiveCleanTmpTest
remains in the final archive path despite they are parts of the
Expand Down
Empty file.
5 changes: 2 additions & 3 deletions tests/cleaner_tests/full_report/full_report_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@ class FullCleanTest(StageTwoReportTest):

sos_cmd = '--clean'
sos_timeout = 600
# replace with an empty placeholder, make sure that this test case is not
# influenced by previous clean runs
files = [('default_mapping', '/etc/sos/cleaner/default_mapping')]
packages = {
'rhel': ['python3-systemd'],
'ubuntu': ['python3-systemd']
}
physical_or_vm_only = True

def pre_sos_setup(self):
self.setup_isolated_cleaner_cache()

# ensure that case-insensitive matching of FQDNs and shortnames work
from systemd import journal
from socket import gethostname
Expand Down
Empty file.
9 changes: 4 additions & 5 deletions tests/cleaner_tests/ipv6_test/ipv6_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ class IPv6Test(StageTwoReportTest):
install_plugins = ['ipv6']
sos_cmd = '--clean -o ipv6'
sos_timeout = 600
# replace default mapping to avoid being influenced by previous runs
# place mock file with crafted address used by mocked plugin
files = [
('default_mapping', '/etc/sos/cleaner/default_mapping'),
('sos-test-ipv6.txt', MOCK_FILE)
]
files = [('sos-test-ipv6.txt', MOCK_FILE)]

def pre_sos_setup(self):
self.setup_isolated_cleaner_cache()

def test_valid_ipv6(self):
self.assertFileCollected(MOCK_FILE)
Expand Down
15 changes: 15 additions & 0 deletions tests/sos_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,21 @@ def get_plugin_manifest(self, plugin):
raise Exception(f"Manifest for {plugin} not present")
return self.manifest['components']['report']['plugins'][plugin]

def setup_isolated_cleaner_cache(self):
"""Create an isolated mapping file in the test's tmpdir to ensure
each test run has its own cleaner_cache directory that doesn't
interfere with other test runs or the system's default cache.

This ensures cleaner_cache will be at {tmpdir}/cleaner_cache/
instead of /etc/sos/cleaner/cleaner_cache/
"""
map_file = os.path.join(self.tmpdir, 'test_mapping')
# Create empty mapping file
with open(map_file, 'w', encoding='utf-8'):
pass
# Dynamically add --map-file to sos_cmd with the unique tmpdir path
self.sos_cmd += f' --map-file {map_file}'


class StageOneReportTest(BaseSoSReportTest):
"""This is the test class to subclass for all Stage One (no mocking) tests
Expand Down
Loading