aboutsummaryrefslogtreecommitdiffstats
path: root/tests/report_tests
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2021-04-06 10:50:23 -0400
committerJake Hunsaker <jhunsake@redhat.com>2021-04-15 11:33:04 -0400
commit02ee553bb5079b4b7e4fcf6f2f31dd7cf86b827d (patch)
tree38e62b863b6a5007782fecf818b1ba8a5d68f857 /tests/report_tests
parent05b456451be1340cf94efacb37fae5130f60f5e1 (diff)
downloadsos-02ee553bb5079b4b7e4fcf6f2f31dd7cf86b827d.tar.gz
[tests] Add a pre-setup setup method and smoke tests
First, add a "pre-setup setup" method, in the form of `pre_sos_setup()`, that can be used in the way the traditional `setUp()` method would be used (but can't because that's our entry point for executing our sos runs). This method will be executed _prior_ to any mocking. Second, add a smoke test that enables all plugins that exist in the local branch being tested. This will test that doing so does not generate any exceptions and that some expected warnings from select plugins are displayed. Related: #2431 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Diffstat (limited to 'tests/report_tests')
-rw-r--r--tests/report_tests/smoke_tests.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/report_tests/smoke_tests.py b/tests/report_tests/smoke_tests.py
new file mode 100644
index 00000000..c184b374
--- /dev/null
+++ b/tests/report_tests/smoke_tests.py
@@ -0,0 +1,56 @@
+# 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.
+
+import re
+
+
+from avocado.utils import process
+from sos_tests import StageOneReportTest, SOS_BIN
+
+
+# These are the header strings in --list-plugins output
+DISABLED = 'The following plugins are currently disabled:'
+OPTIONS = 'The following options are available for ALL plugins:'
+
+
+class AllPluginSmokeTest(StageOneReportTest):
+ """This test forcibly enables ALL plugins available to the local branch
+ and aims to make sure that there are no exceptions generated during the
+ execution
+
+ :avocado: tags=stageone
+ """
+
+ def pre_sos_setup(self):
+ _cmd = '%s report --list-plugins' % SOS_BIN
+ out = process.run(_cmd, timeout=300).stdout.decode()
+ reg = DISABLED + '(.*?)' + OPTIONS
+ self.plugs = []
+ for result in re.findall(reg, out, re.S):
+ for line in result.splitlines():
+ try:
+ self.plugs.append(line.split()[0])
+ except Exception:
+ pass
+
+ self.sos_cmd = '-e %s' % ','.join(p for p in self.plugs)
+
+ def test_all_plugins_ran(self):
+ for plugin in self.plugs:
+ self.assertPluginIncluded(plugin)
+
+ def test_expected_warnings_displayed(self):
+ """We can expect specific plugins to always generate a warning during
+ setup if they are enabled on systems that are not configured for those
+ plugins.
+
+ Make sure our warnings are displayed
+ """
+ self.assertOutputContains('Not logged in to OCP API, and no login token provided. Will not collect `oc` commands')
+ self.assertOutputContains('Source the environment file for the user intended to connect to the OpenStack environment.')
+ self.assertOutputContains('Some or all of the skydive params are not set properly.')