aboutsummaryrefslogtreecommitdiffstats
path: root/tests/report_tests
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2022-08-04 11:39:43 -0400
committerJake Hunsaker <jhunsake@redhat.com>2022-08-10 09:52:54 -0400
commit7f09bfa8c797ffdd435b5c693e8a41843a595bac (patch)
tree6e6c6395b2e8c028af1808e09cc542a3a81b4a5f /tests/report_tests
parent064235ab80420350aad64e9a642592f79d04e675 (diff)
downloadsos-7f09bfa8c797ffdd435b5c693e8a41843a595bac.tar.gz
[teamd,tests] Add a test for teamd plugin and device enumeration
Adds a new test case for the `teamd` plugin that also inherently acts to test team device enumeration. Included with this test case is an addition to the base test classes that allows for tests to define a `post_test_tear_down()` method that will be run at the end of each test execution to allow for manual cleanup - in this case deleting a 'fake' team device created for the test. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Diffstat (limited to 'tests/report_tests')
-rw-r--r--tests/report_tests/plugin_tests/teamd.py46
1 files changed, 46 insertions, 0 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')