aboutsummaryrefslogtreecommitdiffstats
path: root/tests/vendor_tests
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2022-12-02 16:20:01 -0500
committerJake Hunsaker <jhunsake@redhat.com>2023-01-12 12:21:25 -0500
commit131b3bcf5691a158598bed30bd0af6ac9c96737c (patch)
treee70b824a077300eea34513a6305568c38696ac79 /tests/vendor_tests
parentca8a8a7b9f452a81c5654234918b99092620bf13 (diff)
downloadsos-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/vendor_tests')
-rw-r--r--tests/vendor_tests/redhat/rhbz1950350/clean_config_test.txt10
-rw-r--r--tests/vendor_tests/redhat/rhbz1950350/rhbz1950350.py (renamed from tests/vendor_tests/redhat/rhbz1950350.py)7
-rw-r--r--tests/vendor_tests/redhat/rhbz1950350/sos.conf16
-rw-r--r--tests/vendor_tests/redhat/rhbz1950350/sos_clean_config.conf3
-rw-r--r--tests/vendor_tests/redhat/rhbz2018033/rhbz2018033.py (renamed from tests/vendor_tests/redhat/rhbz2018033.py)0
l---------tests/vendor_tests/redhat/rhbz2018033/timeout_test.py1
6 files changed, 35 insertions, 2 deletions
diff --git a/tests/vendor_tests/redhat/rhbz1950350/clean_config_test.txt b/tests/vendor_tests/redhat/rhbz1950350/clean_config_test.txt
new file mode 100644
index 00000000..f1bdb127
--- /dev/null
+++ b/tests/vendor_tests/redhat/rhbz1950350/clean_config_test.txt
@@ -0,0 +1,10 @@
+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.
diff --git a/tests/vendor_tests/redhat/rhbz1950350.py b/tests/vendor_tests/redhat/rhbz1950350/rhbz1950350.py
index 9eab2914..991cb76d 100644
--- a/tests/vendor_tests/redhat/rhbz1950350.py
+++ b/tests/vendor_tests/redhat/rhbz1950350/rhbz1950350.py
@@ -17,8 +17,11 @@ class rhbz1950350(StageTwoReportTest):
:avocado: tags=stagetwo
"""
- files = ['/etc/sos/sos.conf', '/etc/sos/extras.d/sos_clean_config.conf',
- '/var/log/clean_config_test.txt']
+ files = [
+ ('sos.conf', '/etc/sos/sos.conf'),
+ ('sos_clean_config.conf', '/etc/sos/extras.d/sos_clean_config.conf'),
+ ('clean_config_test.txt', '/var/log/clean_config_test.txt')
+ ]
sos_cmd = '-v -o sos_extras --clean'
diff --git a/tests/vendor_tests/redhat/rhbz1950350/sos.conf b/tests/vendor_tests/redhat/rhbz1950350/sos.conf
new file mode 100644
index 00000000..45bdf3fe
--- /dev/null
+++ b/tests/vendor_tests/redhat/rhbz1950350/sos.conf
@@ -0,0 +1,16 @@
+[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/vendor_tests/redhat/rhbz1950350/sos_clean_config.conf b/tests/vendor_tests/redhat/rhbz1950350/sos_clean_config.conf
new file mode 100644
index 00000000..7cf2748d
--- /dev/null
+++ b/tests/vendor_tests/redhat/rhbz1950350/sos_clean_config.conf
@@ -0,0 +1,3 @@
+# sos_extras config file to assist with the clean_config test.
+
+:/var/log/clean_config_test.txt
diff --git a/tests/vendor_tests/redhat/rhbz2018033.py b/tests/vendor_tests/redhat/rhbz2018033/rhbz2018033.py
index 25b9090c..25b9090c 100644
--- a/tests/vendor_tests/redhat/rhbz2018033.py
+++ b/tests/vendor_tests/redhat/rhbz2018033/rhbz2018033.py
diff --git a/tests/vendor_tests/redhat/rhbz2018033/timeout_test.py b/tests/vendor_tests/redhat/rhbz2018033/timeout_test.py
new file mode 120000
index 00000000..b2ece0e1
--- /dev/null
+++ b/tests/vendor_tests/redhat/rhbz2018033/timeout_test.py
@@ -0,0 +1 @@
+../../../report_tests/timeout/timeout_test.py \ No newline at end of file