diff options
author | Luke Meyer <lmeyer@redhat.com> | 2017-09-08 12:07:41 -0400 |
---|---|---|
committer | Luke Meyer <lmeyer@redhat.com> | 2017-09-12 10:32:43 -0400 |
commit | 5f54a91de69bafa70fc4e2657c8bdd8a82c54f11 (patch) | |
tree | 4876181ae022a470de49bce0f044a31ecf5dcd29 | |
parent | 9fbd9c25e39eb4e03af71e16ae8184659b056c77 (diff) | |
download | openshift-5f54a91de69bafa70fc4e2657c8bdd8a82c54f11.tar.gz openshift-5f54a91de69bafa70fc4e2657c8bdd8a82c54f11.tar.bz2 openshift-5f54a91de69bafa70fc4e2657c8bdd8a82c54f11.tar.xz openshift-5f54a91de69bafa70fc4e2657c8bdd8a82c54f11.zip |
openshift_health_check: allow disabling all checks
Can now set openshift_disable_check=* to disable all checks without
needing to know their names.
fixes bug 1462106
https://bugzilla.redhat.com/show_bug.cgi?id=1462106
-rw-r--r-- | roles/openshift_health_checker/action_plugins/openshift_health_check.py | 2 | ||||
-rw-r--r-- | roles/openshift_health_checker/test/action_plugin_test.py | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/roles/openshift_health_checker/action_plugins/openshift_health_check.py b/roles/openshift_health_checker/action_plugins/openshift_health_check.py index 8d35db6b5..d02a43655 100644 --- a/roles/openshift_health_checker/action_plugins/openshift_health_check.py +++ b/roles/openshift_health_checker/action_plugins/openshift_health_check.py @@ -187,7 +187,7 @@ def normalize(checks): def run_check(name, check, user_disabled_checks): """Run a single check if enabled and return a result dict.""" - if name in user_disabled_checks: + if name in user_disabled_checks or '*' in user_disabled_checks: return dict(skipped=True, skipped_reason="Disabled by user request") # pylint: disable=broad-except; capturing exceptions broadly is intentional, diff --git a/roles/openshift_health_checker/test/action_plugin_test.py b/roles/openshift_health_checker/test/action_plugin_test.py index c109ebd24..58864da21 100644 --- a/roles/openshift_health_checker/test/action_plugin_test.py +++ b/roles/openshift_health_checker/test/action_plugin_test.py @@ -110,11 +110,16 @@ def test_action_plugin_skip_non_active_checks(plugin, task_vars, monkeypatch): assert not skipped(result) -def test_action_plugin_skip_disabled_checks(plugin, task_vars, monkeypatch): +@pytest.mark.parametrize('to_disable', [ + 'fake_check', + ['fake_check', 'spam'], + '*,spam,eggs', +]) +def test_action_plugin_skip_disabled_checks(to_disable, plugin, task_vars, monkeypatch): checks = [fake_check('fake_check', is_active=True)] monkeypatch.setattr('openshift_checks.OpenShiftCheck.subclasses', classmethod(lambda cls: checks)) - task_vars['openshift_disable_check'] = 'fake_check' + task_vars['openshift_disable_check'] = to_disable result = plugin.run(tmp=None, task_vars=task_vars) assert result['checks']['fake_check'] == dict(skipped=True, skipped_reason="Disabled by user request") |