diff options
author | Jake Hunsaker <jhunsake@redhat.com> | 2022-12-02 16:20:01 -0500 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2023-01-12 12:21:25 -0500 |
commit | 131b3bcf5691a158598bed30bd0af6ac9c96737c (patch) | |
tree | e70b824a077300eea34513a6305568c38696ac79 /tests/test_data | |
parent | ca8a8a7b9f452a81c5654234918b99092620bf13 (diff) | |
download | sos-131b3bcf5691a158598bed30bd0af6ac9c96737c.tar.gz |
[testing] Change location of mocked files for tests
Previously, mocked files were kept under the `tests/test_data/`
directory and generally mimic'd the file location they would be
temporarily copied to during the execution of their relevant tests.
This has a few maintainability drawbacks, and the handling of the
`files` attribute for test cases as either strings or tuples is at best
confusing.
Improve on this by instead making the `files` references relative to
where the test case file is written. This enables easier maintenance by
keeping all test requirements closer together, rather than spread across
the repo. As such, the `files` attribute now requires a list of tuples,
taking the form `(relative_src, absolute_dest)`. Additionally, fake
plugins for tests that need them to artificially test a specific
criteria should also be included in the test's subdir now.
Along with this change, move several StageTwo tests to their own subdirs
that now contain both the test cases and the needed files for mocking.
This should be the new design pattern going forward - if a test needs to
mock files of any kind, put it in a new subdirectory (and if it doesn't
need to mock files, continue to keep it in the relevant directory within
the test suite).
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Diffstat (limited to 'tests/test_data')
-rw-r--r-- | tests/test_data/etc/sos/cleaner/default_mapping | 0 | ||||
-rw-r--r-- | tests/test_data/etc/sos/extras.d/sos_clean_config.conf | 3 | ||||
-rw-r--r-- | tests/test_data/etc/sos/extras.d/sos_testing.conf | 4 | ||||
-rw-r--r-- | tests/test_data/etc/sos/options_tests_sos.conf | 18 | ||||
-rw-r--r-- | tests/test_data/etc/sos/sos.conf | 16 | ||||
-rw-r--r-- | tests/test_data/etc/sudo-ldap.conf | 6 | ||||
-rw-r--r-- | tests/test_data/fake_plugins/binary_test.py | 21 | ||||
-rw-r--r-- | tests/test_data/fake_plugins/default_env_test.py | 28 | ||||
-rw-r--r-- | tests/test_data/fake_plugins/skip_versions.py | 24 | ||||
-rw-r--r-- | tests/test_data/fake_plugins/timeout_test.py | 22 | ||||
-rw-r--r-- | tests/test_data/fake_plugins/unicode_test.py | 20 | ||||
-rw-r--r-- | tests/test_data/tmp/sos-test-unicode.txt | 5 | ||||
-rw-r--r-- | tests/test_data/tmp/sos-test-version-noskip | 6 | ||||
-rw-r--r-- | tests/test_data/tmp/sos-test-version.txt | 6 | ||||
-rw-r--r-- | tests/test_data/var/log/binary_test.tar.xz | bin | 208 -> 0 bytes | |||
-rw-r--r-- | tests/test_data/var/log/clean_config_test.txt | 10 |
16 files changed, 0 insertions, 189 deletions
diff --git a/tests/test_data/etc/sos/cleaner/default_mapping b/tests/test_data/etc/sos/cleaner/default_mapping deleted file mode 100644 index e69de29b..00000000 --- a/tests/test_data/etc/sos/cleaner/default_mapping +++ /dev/null diff --git a/tests/test_data/etc/sos/extras.d/sos_clean_config.conf b/tests/test_data/etc/sos/extras.d/sos_clean_config.conf deleted file mode 100644 index 7cf2748d..00000000 --- a/tests/test_data/etc/sos/extras.d/sos_clean_config.conf +++ /dev/null @@ -1,3 +0,0 @@ -# sos_extras config file to assist with the clean_config test. - -:/var/log/clean_config_test.txt diff --git a/tests/test_data/etc/sos/extras.d/sos_testing.conf b/tests/test_data/etc/sos/extras.d/sos_testing.conf deleted file mode 100644 index 40651f4d..00000000 --- a/tests/test_data/etc/sos/extras.d/sos_testing.conf +++ /dev/null @@ -1,4 +0,0 @@ -# this is a fake sos_extras config file -# -echo sos test -:/etc/fstab diff --git a/tests/test_data/etc/sos/options_tests_sos.conf b/tests/test_data/etc/sos/options_tests_sos.conf deleted file mode 100644 index c0f641d9..00000000 --- a/tests/test_data/etc/sos/options_tests_sos.conf +++ /dev/null @@ -1,18 +0,0 @@ -[global] -#verbose = 3 - -[report] -skip-plugins = networking,logs -case-id = 8675309 - -[collect] -#primary = myhost.example.com - -[clean] -#no-update = true - -[plugin_options] -#rpm.rpmva = off -kernel.with-timer = on -kernel.trace = yes -networking.traceroute = yes diff --git a/tests/test_data/etc/sos/sos.conf b/tests/test_data/etc/sos/sos.conf deleted file mode 100644 index 45bdf3fe..00000000 --- a/tests/test_data/etc/sos/sos.conf +++ /dev/null @@ -1,16 +0,0 @@ -[global] -#verbose = 3 - -[report] -#skip-plugins = rpm,selinux,dovecot - -[collect] -#primary = myhost.example.com - -[clean] -keywords = shibboleth -domains = sosexample.com -#no-update = true - -[plugin_options] -#rpm.rpmva = off diff --git a/tests/test_data/etc/sudo-ldap.conf b/tests/test_data/etc/sudo-ldap.conf deleted file mode 100644 index 76300658..00000000 --- a/tests/test_data/etc/sudo-ldap.conf +++ /dev/null @@ -1,6 +0,0 @@ -# This is a fake sudo-ldap.conf -# -# Nothing important is here -uri ldaps://ldap.example.com -binddn cn=sudo,dc=example,dc=com -bindpw sostestpassword diff --git a/tests/test_data/fake_plugins/binary_test.py b/tests/test_data/fake_plugins/binary_test.py deleted file mode 100644 index 80bc841b..00000000 --- a/tests/test_data/fake_plugins/binary_test.py +++ /dev/null @@ -1,21 +0,0 @@ -# This file is part of the sos project: https://github.com/sosreport/sos -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions of -# version 2 of the GNU General Public License. -# -# See the LICENSE file in the source distribution for further information. - -from sos.report.plugins import Plugin, IndependentPlugin - - -class BinaryPlugin(Plugin, IndependentPlugin): - """Test plugin for testing binary removal with --clean - """ - - plugin_name = 'binary_test' - short_desc = 'test plugin for removing binaries with --clean' - - - def setup(self): - self.add_copy_spec('/var/log/binary_test.tar.xz') diff --git a/tests/test_data/fake_plugins/default_env_test.py b/tests/test_data/fake_plugins/default_env_test.py deleted file mode 100644 index d1d1fb78..00000000 --- a/tests/test_data/fake_plugins/default_env_test.py +++ /dev/null @@ -1,28 +0,0 @@ -# This file is part of the sos project: https://github.com/sosreport/sos -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions of -# version 2 of the GNU General Public License. -# -# See the LICENSE file in the source distribution for further information. - -from sos.report.plugins import Plugin, IndependentPlugin - - -class DefaultEnv(Plugin, IndependentPlugin): - - plugin_name = 'default_env_test' - short_desc = 'Fake plugin to test default env var handling' - - def setup(self): - self.set_default_cmd_environment({ - 'TORVALDS': 'Linus', - 'GREATESTSPORT': 'hockey' - }) - - self.add_cmd_output( - "sh -c 'echo Does '$TORVALDS' play '$GREATESTSPORT'?'", - suggest_filename='env_var_test' - ) - - self.add_env_var(['TORVALDS', 'GREATESTSPORT']) diff --git a/tests/test_data/fake_plugins/skip_versions.py b/tests/test_data/fake_plugins/skip_versions.py deleted file mode 100644 index e8a1d533..00000000 --- a/tests/test_data/fake_plugins/skip_versions.py +++ /dev/null @@ -1,24 +0,0 @@ -# This file is part of the sos project: https://github.com/sosreport/sos -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions of -# version 2 of the GNU General Public License. -# -# See the LICENSE file in the source distribution for further information. - -from sos.report.plugins import Plugin, IndependentPlugin - - -class SkipVersions(Plugin, IndependentPlugin): - """Collect the fake version files from the test suite, to ensure proper - skipping of version files - """ - - plugin_name = 'skip_versions' - short_desc = 'fake plugin to test skipping version files via the IP parser' - - def setup(self): - self.add_copy_spec([ - '/tmp/sos-test-version.txt', - '/tmp/sos-test-version-noskip' - ]) diff --git a/tests/test_data/fake_plugins/timeout_test.py b/tests/test_data/fake_plugins/timeout_test.py deleted file mode 100644 index cfb148d7..00000000 --- a/tests/test_data/fake_plugins/timeout_test.py +++ /dev/null @@ -1,22 +0,0 @@ -# This file is part of the sos project: https://github.com/sosreport/sos -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions of -# version 2 of the GNU General Public License. -# -# See the LICENSE file in the source distribution for further information. - -from sos.report.plugins import Plugin, IndependentPlugin - - -class TimeoutTest(Plugin, IndependentPlugin): - - plugin_name = 'timeout_test' - short_desc = 'Tests timeout functionality in test suite' - plugin_timeout = 100 - - - def setup(self): - self.add_cmd_output('sleep 15') - self.add_cmd_output('echo I slept great', suggest_filename='echo_good') - self.add_cmd_output('sleep 30', timeout=10) diff --git a/tests/test_data/fake_plugins/unicode_test.py b/tests/test_data/fake_plugins/unicode_test.py deleted file mode 100644 index 541dfb5c..00000000 --- a/tests/test_data/fake_plugins/unicode_test.py +++ /dev/null @@ -1,20 +0,0 @@ -# This file is part of the sos project: https://github.com/sosreport/sos -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions of -# version 2 of the GNU General Public License. -# -# See the LICENSE file in the source distribution for further information. - -from sos.report.plugins import Plugin, IndependentPlugin - - -class UnicodeTest(Plugin, IndependentPlugin): - """Fake plugin to test the handling of a file with embedded unicode - """ - - plugin_name = 'unicode_test' - short_desc = 'Fake plugin to test unicode file handling' - - def setup(self): - self.add_copy_spec('/tmp/sos-test-unicode.txt') diff --git a/tests/test_data/tmp/sos-test-unicode.txt b/tests/test_data/tmp/sos-test-unicode.txt deleted file mode 100644 index 7dc00099..00000000 --- a/tests/test_data/tmp/sos-test-unicode.txt +++ /dev/null @@ -1,5 +0,0 @@ -This is a line with no unicode in it. -This line has some in it æßøĄ. -If opened normally, the last line may cause errors. -So this file is used to test opening with errors='replace'. -This line has the address 192.168.1.1 in it to ensure our cleaner tests are actually processing this file. diff --git a/tests/test_data/tmp/sos-test-version-noskip b/tests/test_data/tmp/sos-test-version-noskip deleted file mode 100644 index bc5558de..00000000 --- a/tests/test_data/tmp/sos-test-version-noskip +++ /dev/null @@ -1,6 +0,0 @@ -This is a test file for skipping version files with the IP parser. - -All dotted-quad strings SHOULD be changed in this file. - -10.11.12.13 -6.0.0.1 diff --git a/tests/test_data/tmp/sos-test-version.txt b/tests/test_data/tmp/sos-test-version.txt deleted file mode 100644 index 62a96e57..00000000 --- a/tests/test_data/tmp/sos-test-version.txt +++ /dev/null @@ -1,6 +0,0 @@ -This is a test file for skipping version files with the IP parser. - -No dotted-quad strings should be changed in this file. - -10.11.12.13 -6.0.0.1 diff --git a/tests/test_data/var/log/binary_test.tar.xz b/tests/test_data/var/log/binary_test.tar.xz Binary files differdeleted file mode 100644 index 6031c869..00000000 --- a/tests/test_data/var/log/binary_test.tar.xz +++ /dev/null diff --git a/tests/test_data/var/log/clean_config_test.txt b/tests/test_data/var/log/clean_config_test.txt deleted file mode 100644 index f1bdb127..00000000 --- a/tests/test_data/var/log/clean_config_test.txt +++ /dev/null @@ -1,10 +0,0 @@ -This is a test file for use with testing sos. - -The clean_config test should use this file for testing that the config section for -[clean] is loaded when `--clean` is specified on the command line. - -This line contains 'shibboleth' which should be scrubbed. - -The domain sosexample.com should also be scrubbed. Also subdomains like foobar.sosexample.com should be removed. - -The domain example.com should not be removed. |