Skip to content
Snippets Groups Projects
Unverified Commit bf87df84 authored by Varac's avatar Varac
Browse files

Query "Available" deployment condition

parent 4608e0a5
No related branches found
No related tags found
No related merge requests found
......@@ -120,6 +120,18 @@ def run_around_tests():
config.load_kube_config(config_file=kubeconfig)
yield
def get_readiness(app_status):
"""
Parses an app status's 'conditions' to find a type field called 'Ready' and
returns its status. Works for Kustomizations as well as Helmreleases.
"""
for condition in app_status.conditions:
if condition.type == 'Available':
return condition.status
# If this point is reached, no condition "Ready" exists, so the application
# is not ready.
return False
# Pytest functions
......@@ -184,8 +196,8 @@ def test_deployments(resource, namespace):
for deployment in deployments.items:
resource = deployment.metadata.name
namespace = deployment.metadata.namespace
status = api.read_namespaced_deployment_status(resource, namespace)
ready = status.status.conditions[0].status
deployment = api.read_namespaced_deployment_status(resource, namespace)
ready = get_readiness(deployment.status)
print(f'Deployment "{resource}" in namespace "{namespace}": {ready}')
if ready != 'True':
failed += 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment