summaryrefslogtreecommitdiffstats
path: root/roles/openshift_health_checker/test/curator_test.py
diff options
context:
space:
mode:
authorjuanvallejo <jvallejo@redhat.com>2017-03-22 15:52:35 -0400
committerjuanvallejo <jvallejo@redhat.com>2017-06-02 16:44:07 -0400
commit2e53dbb4c0d9bfe79cd79e0a0ece9db065b286df (patch)
treee2bcc99a895fc6647bc7623a8bcbf6c8fd5385f8 /roles/openshift_health_checker/test/curator_test.py
parent46dca9b8b15ed67adfa2ca617f300e5d1df7c3e0 (diff)
downloadopenshift-2e53dbb4c0d9bfe79cd79e0a0ece9db065b286df.tar.gz
openshift-2e53dbb4c0d9bfe79cd79e0a0ece9db065b286df.tar.bz2
openshift-2e53dbb4c0d9bfe79cd79e0a0ece9db065b286df.tar.xz
openshift-2e53dbb4c0d9bfe79cd79e0a0ece9db065b286df.zip
add elasticseatch, fluentd, kibana check
Diffstat (limited to 'roles/openshift_health_checker/test/curator_test.py')
-rw-r--r--roles/openshift_health_checker/test/curator_test.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/roles/openshift_health_checker/test/curator_test.py b/roles/openshift_health_checker/test/curator_test.py
new file mode 100644
index 000000000..ae108c96e
--- /dev/null
+++ b/roles/openshift_health_checker/test/curator_test.py
@@ -0,0 +1,68 @@
+import pytest
+
+from openshift_checks.logging.curator import Curator
+
+
+def canned_curator(exec_oc=None):
+ """Create a Curator check object with canned exec_oc method"""
+ check = Curator("dummy") # fails if a module is actually invoked
+ if exec_oc:
+ check._exec_oc = exec_oc
+ return check
+
+
+def assert_error(error, expect_error):
+ if expect_error:
+ assert error
+ assert expect_error in error
+ else:
+ assert not error
+
+
+plain_curator_pod = {
+ "metadata": {
+ "labels": {"component": "curator", "deploymentconfig": "logging-curator"},
+ "name": "logging-curator-1",
+ },
+ "status": {
+ "containerStatuses": [{"ready": True}],
+ "conditions": [{"status": "True", "type": "Ready"}],
+ "podIP": "10.10.10.10",
+ }
+}
+
+not_running_curator_pod = {
+ "metadata": {
+ "labels": {"component": "curator", "deploymentconfig": "logging-curator"},
+ "name": "logging-curator-2",
+ },
+ "status": {
+ "containerStatuses": [{"ready": False}],
+ "conditions": [{"status": "False", "type": "Ready"}],
+ "podIP": "10.10.10.10",
+ }
+}
+
+
+@pytest.mark.parametrize('pods, expect_error', [
+ (
+ [],
+ "no Curator pods",
+ ),
+ (
+ [plain_curator_pod],
+ None,
+ ),
+ (
+ [not_running_curator_pod],
+ "not currently in a running state",
+ ),
+ (
+ [plain_curator_pod, plain_curator_pod],
+ "more than one Curator pod",
+ ),
+])
+def test_get_curator_pods(pods, expect_error):
+ check = canned_curator()
+ error = check.check_curator(pods)
+ assert_error(error, expect_error)