diff options
author | Rodolfo Carvalho <rhcarvalho@gmail.com> | 2017-06-23 15:32:19 +0200 |
---|---|---|
committer | Rodolfo Carvalho <rhcarvalho@gmail.com> | 2017-08-24 15:00:21 +0200 |
commit | 80476c7dea2b3f6f42ebce5a7947af1d3b9dbedb (patch) | |
tree | 62b4e269ad4c12fa32c66b5be0493bd277da2b77 /roles/openshift_health_checker/test | |
parent | 75b1ef8fa6e80e7645a60cef2d4e7640a6c87955 (diff) | |
download | openshift-80476c7dea2b3f6f42ebce5a7947af1d3b9dbedb.tar.gz openshift-80476c7dea2b3f6f42ebce5a7947af1d3b9dbedb.tar.bz2 openshift-80476c7dea2b3f6f42ebce5a7947af1d3b9dbedb.tar.xz openshift-80476c7dea2b3f6f42ebce5a7947af1d3b9dbedb.zip |
Rewrite failure summary callback plugin
The intent is to deduplicate similar errors that happened in many hosts,
making the summary more concise.
Diffstat (limited to 'roles/openshift_health_checker/test')
-rw-r--r-- | roles/openshift_health_checker/test/conftest.py | 1 | ||||
-rw-r--r-- | roles/openshift_health_checker/test/zz_failure_summary_test.py | 70 |
2 files changed, 71 insertions, 0 deletions
diff --git a/roles/openshift_health_checker/test/conftest.py b/roles/openshift_health_checker/test/conftest.py index 3cbd65507..244a1f0fa 100644 --- a/roles/openshift_health_checker/test/conftest.py +++ b/roles/openshift_health_checker/test/conftest.py @@ -7,5 +7,6 @@ openshift_health_checker_path = os.path.dirname(os.path.dirname(__file__)) sys.path[1:1] = [ openshift_health_checker_path, os.path.join(openshift_health_checker_path, 'action_plugins'), + os.path.join(openshift_health_checker_path, 'callback_plugins'), os.path.join(openshift_health_checker_path, 'library'), ] diff --git a/roles/openshift_health_checker/test/zz_failure_summary_test.py b/roles/openshift_health_checker/test/zz_failure_summary_test.py new file mode 100644 index 000000000..0fc258133 --- /dev/null +++ b/roles/openshift_health_checker/test/zz_failure_summary_test.py @@ -0,0 +1,70 @@ +from zz_failure_summary import deduplicate_failures + +import pytest + + +@pytest.mark.parametrize('failures,deduplicated', [ + ( + [ + { + 'host': 'master1', + 'msg': 'One or more checks failed', + }, + ], + [ + { + 'host': ('master1',), + 'msg': 'One or more checks failed', + }, + ], + ), + ( + [ + { + 'host': 'master1', + 'msg': 'One or more checks failed', + }, + { + 'host': 'node1', + 'msg': 'One or more checks failed', + }, + ], + [ + { + 'host': ('master1', 'node1'), + 'msg': 'One or more checks failed', + }, + ], + ), + ( + [ + { + 'host': 'node1', + 'msg': 'One or more checks failed', + 'checks': (('test_check', 'error message'),), + }, + { + 'host': 'master2', + 'msg': 'Some error happened', + }, + { + 'host': 'master1', + 'msg': 'One or more checks failed', + 'checks': (('test_check', 'error message'),), + }, + ], + [ + { + 'host': ('master1', 'node1'), + 'msg': 'One or more checks failed', + 'checks': (('test_check', 'error message'),), + }, + { + 'host': ('master2',), + 'msg': 'Some error happened', + }, + ], + ), +]) +def test_deduplicate_failures(failures, deduplicated): + assert deduplicate_failures(failures) == deduplicated |