aboutsummaryrefslogtreecommitdiffstats
path: root/tests/report_tests
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2023-02-07 12:54:49 -0500
committerJake Hunsaker <jhunsake@redhat.com>2023-03-07 17:34:32 -0500
commit61e36af743cd0bffcac2c0759ac13d2493caec93 (patch)
tree81a8e93279bf13cd3099cff99bdecd92f170b9b0 /tests/report_tests
parente8dc0e55988b36d0476bcae741652208356f0f07 (diff)
downloadsos-61e36af743cd0bffcac2c0759ac13d2493caec93.tar.gz
[report] Allow users to constrain sos process priority
Adds a new `--low-priority` option to report, which will attempt to constrain the process priority for the report generation. We do this by attempting to set ourselves to an 'idle' IO class, as well as setting our niceness to 19 to avoid contending for CPU time. This is also exposed via `sos collect`, however users should note that this will not be effective until the sos-4.5.1 release. Closes: #3127 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Diffstat (limited to 'tests/report_tests')
-rw-r--r--tests/report_tests/low_priority_tests.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/report_tests/low_priority_tests.py b/tests/report_tests/low_priority_tests.py
new file mode 100644
index 00000000..97bf0a28
--- /dev/null
+++ b/tests/report_tests/low_priority_tests.py
@@ -0,0 +1,33 @@
+# 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 os.path import exists
+from sos_tests import StageOneReportTest
+
+
+class LowPrioTest(StageOneReportTest):
+ """
+ Ensures that --low-priority properly sets our defined constraints on our
+ own process
+
+ :avocado: tags=stageone
+ """
+
+ sos_cmd = '--low-priority -o kernel'
+
+ def test_ionice_class_set(self):
+ _class = self.manifest['components']['report']['priority']['io_class']
+ if exists('/usr/bin/ionice'):
+ self.assertSosLogContains('Set IO class to idle')
+ self.assertEqual(_class, 'idle')
+ else:
+ self.assertEqual(_class, 'unknown')
+
+ def test_niceness_set(self):
+ self.assertSosLogContains('Set niceness of report to 19')
+ self.assertEqual(self.manifest['components']['report']['priority']['niceness'], 19)