summaryrefslogtreecommitdiffstats
path: root/roles/openshift_health_checker
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
commit2a0936b291992ba1b7343680aec915df0c29892c (patch)
tree22fe8d099f5a1bc11a35ff1cdf0c05f9cef12053 /roles/openshift_health_checker
parent3f3f87b7982b570ffb976865e3eace2d36960bd4 (diff)
downloadopenshift-2a0936b291992ba1b7343680aec915df0c29892c.tar.gz
openshift-2a0936b291992ba1b7343680aec915df0c29892c.tar.bz2
openshift-2a0936b291992ba1b7343680aec915df0c29892c.tar.xz
openshift-2a0936b291992ba1b7343680aec915df0c29892c.zip
openshift_checks: get rid of deprecated module_executor
Diffstat (limited to 'roles/openshift_health_checker')
-rw-r--r--roles/openshift_health_checker/openshift_checks/__init__.py13
-rw-r--r--roles/openshift_health_checker/openshift_checks/etcd_imagedata_size.py2
-rw-r--r--roles/openshift_health_checker/openshift_checks/logging/curator.py2
-rw-r--r--roles/openshift_health_checker/test/openshift_check_test.py18
4 files changed, 10 insertions, 25 deletions
diff --git a/roles/openshift_health_checker/openshift_checks/__init__.py b/roles/openshift_health_checker/openshift_checks/__init__.py
index 5c9949ced..c2cfd0175 100644
--- a/roles/openshift_health_checker/openshift_checks/__init__.py
+++ b/roles/openshift_health_checker/openshift_checks/__init__.py
@@ -21,13 +21,12 @@ class OpenShiftCheckException(Exception):
class OpenShiftCheck(object):
"""A base class for defining checks for an OpenShift cluster environment."""
- def __init__(self, execute_module=None, module_executor=None):
- if execute_module is module_executor is None:
- raise TypeError(
- "__init__() takes either execute_module (recommended) "
- "or module_executor (deprecated), none given")
- self.execute_module = execute_module or module_executor
- self.module_executor = self.execute_module
+ def __init__(self, execute_module=None):
+ def placeholder(*_):
+ """Fail tests more helpfully when execute_module not provided."""
+ raise TypeError(self.__class__.__name__ +
+ " invoked execute_module without providing the method at initialization.")
+ self.execute_module = execute_module or placeholder
@abstractproperty
def name(self):
diff --git a/roles/openshift_health_checker/openshift_checks/etcd_imagedata_size.py b/roles/openshift_health_checker/openshift_checks/etcd_imagedata_size.py
index c04a69765..3097728aa 100644
--- a/roles/openshift_health_checker/openshift_checks/etcd_imagedata_size.py
+++ b/roles/openshift_health_checker/openshift_checks/etcd_imagedata_size.py
@@ -46,7 +46,7 @@ class EtcdImageDataSize(OpenShiftCheck):
},
}
- etcdkeysize = self.module_executor("etcdkeysize", args, task_vars)
+ etcdkeysize = self.execute_module("etcdkeysize", args, task_vars)
if etcdkeysize.get("rc", 0) != 0 or etcdkeysize.get("failed"):
msg = 'Failed to retrieve stats for etcd host "{host}": {reason}'
diff --git a/roles/openshift_health_checker/openshift_checks/logging/curator.py b/roles/openshift_health_checker/openshift_checks/logging/curator.py
index d8e64074f..7e932cf98 100644
--- a/roles/openshift_health_checker/openshift_checks/logging/curator.py
+++ b/roles/openshift_health_checker/openshift_checks/logging/curator.py
@@ -15,7 +15,7 @@ class Curator(LoggingCheck):
def run(self, tmp, task_vars):
self.logging_namespace = get_var(task_vars, "openshift_logging_namespace", default="logging")
curator_pods, error = super(Curator, self).get_pods_for_component(
- self.module_executor,
+ self.execute_module,
self.logging_namespace,
"curator",
task_vars
diff --git a/roles/openshift_health_checker/test/openshift_check_test.py b/roles/openshift_health_checker/test/openshift_check_test.py
index e3153979c..c6169ca22 100644
--- a/roles/openshift_health_checker/test/openshift_check_test.py
+++ b/roles/openshift_health_checker/test/openshift_check_test.py
@@ -30,32 +30,18 @@ def test_OpenShiftCheck_init():
# initialization requires at least one argument (apart from self)
with pytest.raises(TypeError) as excinfo:
- TestCheck()
+ TestCheck().execute_module("foo")
assert 'execute_module' in str(excinfo.value)
- assert 'module_executor' in str(excinfo.value)
execute_module = object()
# initialize with positional argument
check = TestCheck(execute_module)
- # new recommended name
assert check.execute_module == execute_module
- # deprecated attribute name
- assert check.module_executor == execute_module
- # initialize with keyword argument, recommended name
+ # initialize with keyword argument
check = TestCheck(execute_module=execute_module)
- # new recommended name
assert check.execute_module == execute_module
- # deprecated attribute name
- assert check.module_executor == execute_module
-
- # initialize with keyword argument, deprecated name
- check = TestCheck(module_executor=execute_module)
- # new recommended name
- assert check.execute_module == execute_module
- # deprecated attribute name
- assert check.module_executor == execute_module
def test_subclasses():