diff --git a/test/pytest/test_resources.py b/test/pytest/test_resources.py index 7b2f153173a65bf32263d2e2a4499e62bd5da1ea..8ee1e36a333ad78c48837c0de2915980e77e06f9 100644 --- a/test/pytest/test_resources.py +++ b/test/pytest/test_resources.py @@ -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