aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/report_tests/plugin_tests/teamd.py46
-rw-r--r--tests/sos_tests.py20
2 files changed, 61 insertions, 5 deletions
diff --git a/tests/report_tests/plugin_tests/teamd.py b/tests/report_tests/plugin_tests/teamd.py
new file mode 100644
index 00000000..1c64e457
--- /dev/null
+++ b/tests/report_tests/plugin_tests/teamd.py
@@ -0,0 +1,46 @@
+# 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 avocado.utils import process
+from sos_tests import StageTwoReportTest
+
+
+class TeamdPluginTest(StageTwoReportTest):
+ """Ensure that team device enumeration is working correctly, by creating
+ a 'fake' team device. This inherently also tests proper iteration of
+ add_device_cmd().
+
+ :avocado: tags=stagetwo
+ """
+
+ packages = {
+ 'rhel': ['teamd', 'NetworkManager-team']
+ }
+
+ sos_cmd = '-o teamd'
+ redhat_only = True
+
+ def pre_sos_setup(self):
+ # restart NetworkManager to account for the new package
+ nmout = process.run('systemctl restart NetworkManager', timeout=30)
+ assert nmout.exit_status == 0, "NetworkManager failed to restart"
+ # create the team device
+ res = process.run('nmcli con add type team ifname sostesting',
+ timeout=30)
+ assert res.exit_status == 0, "Failed creating team device: %s" % res.stdout_text
+
+ def post_test_tear_down(self):
+ res = process.run('nmcli con delete team-sostesting', timeout=30)
+ assert res.exit_status == 0, "Failed to delete temp team device: %s" % res.stdout_text
+
+ def test_teamd_plugin_executed(self):
+ self.assertPluginIncluded('teamd')
+
+ def test_team_dev_iteration(self):
+ self.assertFileGlobInArchive('sos_commands/teamd/*sostest*state')
+ self.assertFileGlobInArchive('sos_commands/teamd/*sostesting_ports')
diff --git a/tests/sos_tests.py b/tests/sos_tests.py
index 705e8a38..7ba65a52 100644
--- a/tests/sos_tests.py
+++ b/tests/sos_tests.py
@@ -269,11 +269,18 @@ class BaseSoSTest(Test):
for each `test_*` method defined within it.
"""
if self.end_of_test_case:
+ self.post_test_tear_down()
# remove the extracted directory only if we have the tarball
if self.archive and os.path.exists(self.archive):
if os.path.exists(self.archive_path):
shutil.rmtree(self.archive_path)
+ def post_test_tear_down(self):
+ """Called at the end of a test run to ensure that any needed per-test
+ cleanup can be done.
+ """
+ pass
+
def setup_mocking(self):
"""Since we need to use setUp() in our overrides of avocado.Test,
provide an alternate method for test cases that subclass BaseSoSTest
@@ -807,8 +814,10 @@ class StageTwoReportTest(BaseSoSReportTest):
return
installed = self.installer.install_distro_packages(self.packages)
if not installed:
- raise("Unable to install requested packages %s"
- % ', '.join(pkg for pkg in self.packages[self.local_distro]))
+ raise Exception(
+ "Unable to install requested packages %s"
+ % ', '.join(self.packages[self.local_distro])
+ )
# save installed package list to our tmpdir to be removed later
self._write_file_to_tmpdir('mocked_packages', json.dumps(self.packages[self.local_distro]))
@@ -817,9 +826,10 @@ class StageTwoReportTest(BaseSoSReportTest):
already exist on the test system, remove them from the list of packages
to be installed.
"""
- for pkg in self.packages[self.local_distro]:
- if self.sm.check_installed(pkg):
- self.packages[self.local_distro].remove(pkg)
+ self.packages[self.local_distro] = [
+ p for p in self.packages[self.local_distro] if not
+ self.sm.check_installed(p)
+ ]
def teardown_mocked_packages(self):
"""Uninstall any packages that we installed for this test