diff --git a/src/KubeLibrary/KubeLibrary.py b/src/KubeLibrary/KubeLibrary.py index 64f9486d..3c95bd0f 100755 --- a/src/KubeLibrary/KubeLibrary.py +++ b/src/KubeLibrary/KubeLibrary.py @@ -529,3 +529,23 @@ def delete_service_account_in_namespace(self, name, namespace): """ ret = self.v1.delete_namespaced_service_account(name=name, namespace=namespace) return ret + + def get_healthcheck(self): + """Checks cluster level healthcheck + Can be used to verify the readiness/current status of the API server + + Returns tuple of (response data, response status and response headers) + """ + path_params = {} + query_params = [] + header_params = {} + auth_settings = ['BearerToken'] + resp = self.v1.api_client.call_api('/readyz?verbose=', 'GET', + path_params, + query_params, + header_params, + response_type='str', + auth_settings=auth_settings, + async_req=False, + _return_http_data_only=False) + return resp diff --git a/testcases/healthcheck/healthcheck.robot b/testcases/healthcheck/healthcheck.robot new file mode 100644 index 00000000..5c0d5f3b --- /dev/null +++ b/testcases/healthcheck/healthcheck.robot @@ -0,0 +1,8 @@ +*** Settings *** +Resource ./healthcheck_kw.robot + +*** Test Cases *** +Healthcheck + [Tags] other + Healthcheck + diff --git a/testcases/healthcheck/healthcheck_kw.robot b/testcases/healthcheck/healthcheck_kw.robot new file mode 100644 index 00000000..b34d023a --- /dev/null +++ b/testcases/healthcheck/healthcheck_kw.robot @@ -0,0 +1,23 @@ +*** Settings *** +Library Collections +Library RequestsLibrary +Library String +# For regular execution +Library KubeLibrary +# For incluster execution +#Library KubeLibrary None True False +# For development +#Library ../../src/KubeLibrary/KubeLibrary.py ~/.kube/k3d + +*** Keywords *** +Healthcheck + @{RESPONSE}= Get Healthcheck + FOR ${i} IN RANGE 2 + Remove from List ${RESPONSE} -1 + END + + @{ENDPOINTS} = Split String ${RESPONSE}[0] \n + FOR ${ELEMENT} IN @{ENDPOINTS} + Should Be True "ok" in """${ELEMENT}""" + END +