diff options
author | Jake Hunsaker <jhunsake@redhat.com> | 2022-02-17 16:41:10 -0500 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2022-03-02 11:53:08 -0500 |
commit | 1682e78d2a63aa771a8209b46382c109bd78e84d (patch) | |
tree | 0e3afc9cc6ea28f6c6ed4014b54d6e417aa50a4a | |
parent | 686351fc6768104504ee14b9cad4140b65a420a2 (diff) | |
download | sos-1682e78d2a63aa771a8209b46382c109bd78e84d.tar.gz |
[tests] Add a test for non-default plugin_timeout compliance
There was a gap in our testing that allows #2863 to escape our notice -
that a `Plugin()`'s `plugin_timeout` attribute would be ignored if it
wasn't set to `TIMEOUT_DEFAULT`.
As that was resolved by #2864, add a test to ensure it remains working
as expected. The expected resolution order for a plugin's whole timeout
is as follows:
1. The value set by `-k plugin.timeout`
2. The value set by `--plugin-timeout`
3. The value hardcoded in the plugin via the `plugin_timeout` attr
4. `TIMEOUT_DEFAULT`
Related: #2863
Related: #2864
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r-- | tests/report_tests/timeout_tests.py | 27 | ||||
-rw-r--r-- | tests/test_data/fake_plugins/timeout_test.py | 1 |
2 files changed, 27 insertions, 1 deletions
diff --git a/tests/report_tests/timeout_tests.py b/tests/report_tests/timeout_tests.py index 58678644..ffce9231 100644 --- a/tests/report_tests/timeout_tests.py +++ b/tests/report_tests/timeout_tests.py @@ -18,6 +18,10 @@ class PluginTimeoutTest(StageTwoReportTest): install_plugins = ['timeout_test'] sos_cmd = '-o timeout_test -vvv --plugin-timeout=10' + def test_correct_plugin_timeout(self): + man = self.get_plugin_manifest('timeout_test') + self.assertEquals(man['timeout'], 10) + def test_plugin_timed_out(self): self.assertSosLogNotContains('collected plugin \'timeout_test\' in') self.assertSosUILogContains('Plugin timeout_test timed out') @@ -33,7 +37,13 @@ class NativeCmdTimeoutTest(StageTwoReportTest): """ install_plugins = ['timeout_test'] - sos_cmd = '-o timeout_test -vvv' + sos_cmd = '-o timeout_test,host -vvv' + + def test_correct_plugin_timeout(self): + man = self.get_plugin_manifest('timeout_test') + self.assertEquals(man['timeout'], 100) + hman = self.get_plugin_manifest('host') + self.assertEquals(hman['timeout'], 300) def test_plugin_completed(self): self.assertSosLogContains('collected plugin \'timeout_test\' in') @@ -42,3 +52,18 @@ class NativeCmdTimeoutTest(StageTwoReportTest): def test_command_timed_out(self): self.assertSosLogContains(r"\[plugin:timeout_test\] command 'sleep 30' timed out after 10s") self.assertFileCollected('sos_commands/timeout_test/sleep_30') + +class MultipleTimeoutValues(NativeCmdTimeoutTest): + """Test that our plugin timeout option priority is functioning correctly + + :avocado: tags=stagetwo + """ + + install_plugins = ['timeout_test'] + sos_cmd = '-o timeout_test,host --plugin-timeout=30 -k timeout_test.timeout=60' + + def test_correct_plugin_timeout(self): + man = self.get_plugin_manifest('timeout_test') + self.assertEquals(man['timeout'], 60) + hman = self.get_plugin_manifest('host') + self.assertEquals(hman['timeout'], 30) diff --git a/tests/test_data/fake_plugins/timeout_test.py b/tests/test_data/fake_plugins/timeout_test.py index 3a027c42..cfb148d7 100644 --- a/tests/test_data/fake_plugins/timeout_test.py +++ b/tests/test_data/fake_plugins/timeout_test.py @@ -13,6 +13,7 @@ class TimeoutTest(Plugin, IndependentPlugin): plugin_name = 'timeout_test' short_desc = 'Tests timeout functionality in test suite' + plugin_timeout = 100 def setup(self): |