aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2022-08-17 11:51:21 -0400
committerJake Hunsaker <jhunsake@redhat.com>2022-08-29 09:17:55 -0400
commitedd436a90e6e94029da7e5aa8726dab505c6a738 (patch)
treedecd121c9f1459da14809780597f3b0efae8d046 /tests
parent80f71f6a5229fa262a5ddaaa9be4ef99f648abbb (diff)
downloadsos-edd436a90e6e94029da7e5aa8726dab505c6a738.tar.gz
[tests] Allow test suite to use locally installed sos
Up until now, the test suite was forced to be run using the git checkout. While this is useful for on-the-fly testing, it does miss an important use case of building a test package from the checkout, and running it using that as the system installation of sos. This commit allows the use of an installed version of sos to test against. This may be leveraged by adding `-p TESTLOCAL=true` in the `avocado run` command used to launch the test suite. Setting this parameter to any other value, or omitting it entirely, will continue the current behavior or using the git checkout for running tests. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/report_tests/smoke_tests.py4
-rw-r--r--tests/sos_tests.py11
2 files changed, 10 insertions, 5 deletions
diff --git a/tests/report_tests/smoke_tests.py b/tests/report_tests/smoke_tests.py
index a313405e..2d5c41e3 100644
--- a/tests/report_tests/smoke_tests.py
+++ b/tests/report_tests/smoke_tests.py
@@ -10,7 +10,7 @@ import re
from avocado.utils import process
-from sos_tests import StageOneReportTest, SOS_BIN, redhat_only, ubuntu_only
+from sos_tests import StageOneReportTest, redhat_only, ubuntu_only
# These are the header strings in --list-plugins output
@@ -27,7 +27,7 @@ class AllPluginSmokeTest(StageOneReportTest):
"""
def pre_sos_setup(self):
- _cmd = '%s report --list-plugins' % SOS_BIN
+ _cmd = '%s report --list-plugins' % self.sos_bin
out = process.run(_cmd, timeout=300).stdout.decode()
reg = DISABLED + '(.*?)' + OPTIONS
self.plugs = []
diff --git a/tests/sos_tests.py b/tests/sos_tests.py
index 7ba65a52..06903832 100644
--- a/tests/sos_tests.py
+++ b/tests/sos_tests.py
@@ -25,7 +25,7 @@ SOS_TEST_DIR = os.path.dirname(os.path.realpath(__file__))
SOS_REPO_ROOT = os.path.realpath(os.path.join(SOS_TEST_DIR, '../'))
SOS_PLUGIN_DIR = os.path.realpath(os.path.join(SOS_REPO_ROOT, 'sos/report/plugins'))
SOS_TEST_DATA_DIR = os.path.realpath(os.path.join(SOS_TEST_DIR, 'test_data'))
-SOS_BIN = os.path.realpath(os.path.join(SOS_TEST_DIR, '../bin/sos'))
+SOS_TEST_BIN = os.path.realpath(os.path.join(SOS_TEST_DIR, '../bin/sos'))
RH_DIST = ['rhel', 'centos', 'fedora']
UBUNTU_DIST = ['Ubuntu', 'debian']
@@ -64,6 +64,7 @@ class BaseSoSTest(Test):
_klass_name = None
_tmpdir = None
_exception_expected = False
+ _local_sos_bin = shutil.which('sos') or SOS_TEST_BIN
sos_cmd = ''
sos_timeout = 600
redhat_only = False
@@ -82,6 +83,10 @@ class BaseSoSTest(Test):
self._tmpdir = os.getenv('AVOCADO_TESTS_COMMON_TMPDIR') + self.klass_name
return self._tmpdir
+ @property
+ def sos_bin(self):
+ return self._local_sos_bin if self.params.get('TESTLOCAL') == 'true' else SOS_TEST_BIN
+
def generate_sysinfo(self):
"""Collects some basic information about the system for later reference
in individual tests
@@ -417,7 +422,7 @@ class BaseSoSReportTest(BaseSoSTest):
return os.path.join(self.tmpdir, "sosreport-%s" % self.__class__.__name__)
def _generate_sos_command(self):
- return "%s %s -v --batch --tmp-dir %s %s" % (SOS_BIN, self.sos_component, self.tmpdir, self.sos_cmd)
+ return "%s %s -v --batch --tmp-dir %s %s" % (self.sos_bin, self.sos_component, self.tmpdir, self.sos_cmd)
def _execute_sos_cmd(self):
super(BaseSoSReportTest, self)._execute_sos_cmd()
@@ -949,7 +954,7 @@ class StageOneOutputTest(BaseSoSTest):
sos_cmd = ''
def _generate_sos_command(self):
- return "%s %s" % (SOS_BIN, self.sos_cmd)
+ return "%s %s" % (self.sos_bin, self.sos_cmd)
@skipIf(lambda x: x._exception_expected, "Non-zero exit code expected")
def test_help_output_successful(self):