summaryrefslogtreecommitdiffstats
path: root/roles/openshift_health_checker/test/logging_index_time_test.py
diff options
context:
space:
mode:
authorLuke Meyer <lmeyer@redhat.com>2017-06-16 17:24:01 -0400
committerLuke Meyer <lmeyer@redhat.com>2017-07-25 13:23:58 -0400
commit210fc2d3849a1baf9c1d8535044d92df23424274 (patch)
tree20b6998ca0696257eb816e4ace464ee95b926816 /roles/openshift_health_checker/test/logging_index_time_test.py
parent2a0936b291992ba1b7343680aec915df0c29892c (diff)
downloadopenshift-210fc2d3849a1baf9c1d8535044d92df23424274.tar.gz
openshift-210fc2d3849a1baf9c1d8535044d92df23424274.tar.bz2
openshift-210fc2d3849a1baf9c1d8535044d92df23424274.tar.xz
openshift-210fc2d3849a1baf9c1d8535044d92df23424274.zip
openshift_checks: refactor to internalize task_vars
Move task_vars into instance variable so we don't have to pass it around everywhere. Also store tmp. Make sure both are filled in on execute_module. In the process, is_active became an instance method, and task_vars is basically never used directly outside of test code.
Diffstat (limited to 'roles/openshift_health_checker/test/logging_index_time_test.py')
-rw-r--r--roles/openshift_health_checker/test/logging_index_time_test.py32
1 files changed, 10 insertions, 22 deletions
diff --git a/roles/openshift_health_checker/test/logging_index_time_test.py b/roles/openshift_health_checker/test/logging_index_time_test.py
index 79e7c7d4c..178d7cd84 100644
--- a/roles/openshift_health_checker/test/logging_index_time_test.py
+++ b/roles/openshift_health_checker/test/logging_index_time_test.py
@@ -10,7 +10,7 @@ SAMPLE_UUID = "unique-test-uuid"
def canned_loggingindextime(exec_oc=None):
"""Create a check object with a canned exec_oc method"""
- check = LoggingIndexTime("dummy") # fails if a module is actually invoked
+ check = LoggingIndexTime() # fails if a module is actually invoked
if exec_oc:
check.exec_oc = exec_oc
return check
@@ -64,7 +64,7 @@ not_running_kibana_pod = {
)
])
def test_check_running_pods(pods, expect_pods):
- check = canned_loggingindextime(None)
+ check = canned_loggingindextime()
pods = check.running_pods(pods)
assert pods == expect_pods
@@ -81,11 +81,8 @@ def test_check_running_pods(pods, expect_pods):
),
], ids=lambda argval: argval[0])
def test_wait_until_cmd_or_err_succeeds(name, json_response, uuid, timeout, extra_words):
- def exec_oc(execute_module, ns, exec_cmd, args, task_vars):
- return json.dumps(json_response)
-
- check = canned_loggingindextime(exec_oc)
- check.wait_until_cmd_or_err(plain_running_elasticsearch_pod, uuid, timeout, None)
+ check = canned_loggingindextime(lambda *_: json.dumps(json_response))
+ check.wait_until_cmd_or_err(plain_running_elasticsearch_pod, uuid, timeout)
@pytest.mark.parametrize('name, json_response, uuid, timeout, extra_words', [
@@ -116,12 +113,9 @@ def test_wait_until_cmd_or_err_succeeds(name, json_response, uuid, timeout, extr
)
], ids=lambda argval: argval[0])
def test_wait_until_cmd_or_err(name, json_response, uuid, timeout, extra_words):
- def exec_oc(execute_module, ns, exec_cmd, args, task_vars):
- return json.dumps(json_response)
-
- check = canned_loggingindextime(exec_oc)
+ check = canned_loggingindextime(lambda *_: json.dumps(json_response))
with pytest.raises(OpenShiftCheckException) as error:
- check.wait_until_cmd_or_err(plain_running_elasticsearch_pod, uuid, timeout, None)
+ check.wait_until_cmd_or_err(plain_running_elasticsearch_pod, uuid, timeout)
for word in extra_words:
assert word in str(error)
@@ -138,13 +132,10 @@ def test_wait_until_cmd_or_err(name, json_response, uuid, timeout, extra_words):
),
], ids=lambda argval: argval[0])
def test_curl_kibana_with_uuid(name, json_response, uuid, extra_words):
- def exec_oc(execute_module, ns, exec_cmd, args, task_vars):
- return json.dumps(json_response)
-
- check = canned_loggingindextime(exec_oc)
+ check = canned_loggingindextime(lambda *_: json.dumps(json_response))
check.generate_uuid = lambda: uuid
- result = check.curl_kibana_with_uuid(plain_running_kibana_pod, None)
+ result = check.curl_kibana_with_uuid(plain_running_kibana_pod)
for word in extra_words:
assert word in result
@@ -169,14 +160,11 @@ def test_curl_kibana_with_uuid(name, json_response, uuid, extra_words):
),
], ids=lambda argval: argval[0])
def test_failed_curl_kibana_with_uuid(name, json_response, uuid, extra_words):
- def exec_oc(execute_module, ns, exec_cmd, args, task_vars):
- return json.dumps(json_response)
-
- check = canned_loggingindextime(exec_oc)
+ check = canned_loggingindextime(lambda *_: json.dumps(json_response))
check.generate_uuid = lambda: uuid
with pytest.raises(OpenShiftCheckException) as error:
- check.curl_kibana_with_uuid(plain_running_kibana_pod, None)
+ check.curl_kibana_with_uuid(plain_running_kibana_pod)
for word in extra_words:
assert word in str(error)