From a319536d0c3e6efd6e9585debb3a66cd79891f58 Mon Sep 17 00:00:00 2001 From: Jakub Smolar Date: Mon, 17 Jun 2024 15:44:18 +0200 Subject: [PATCH] Moved wait_for_ready to parent object for CRs --- testsuite/openshift/__init__.py | 10 ++++++++++ testsuite/openshift/authorino.py | 12 +----------- testsuite/openshift/kuadrant.py | 12 +----------- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/testsuite/openshift/__init__.py b/testsuite/openshift/__init__.py index f8476e77..3a3a57ea 100644 --- a/testsuite/openshift/__init__.py +++ b/testsuite/openshift/__init__.py @@ -58,6 +58,16 @@ def safe_apply(self): assert status, f"Unable to apply changes for APIObject with result: {result}" return result + def wait_for_ready(self): + """Waits until CR reports ready status""" + with timeout(90): + success, _, _ = self.self_selector().until_all( + success_func=lambda obj: len(obj.model.status.conditions) > 0 + and all(x.status == "True" for x in obj.model.status.conditions) + ) + assert success, f"{self.kind()} did got get ready in time" + self.refresh() + def __getitem__(self, name): return self.model.spec[name] diff --git a/testsuite/openshift/authorino.py b/testsuite/openshift/authorino.py index 71538837..85a43e9f 100644 --- a/testsuite/openshift/authorino.py +++ b/testsuite/openshift/authorino.py @@ -4,7 +4,7 @@ from dataclasses import dataclass from typing import Any, Optional, Dict, List -from openshift_client import selector, timeout +from openshift_client import selector from testsuite.lifecycle import LifecycleObject from testsuite.openshift import CustomResource @@ -86,16 +86,6 @@ def create_instance( with openshift.context: return cls(model) - def wait_for_ready(self): - """Waits until Authorino CR reports ready status""" - with timeout(90): - success, _, _ = self.self_selector().until_all( - success_func=lambda obj: len(obj.model.status.conditions) > 0 - and all(x.status == "True" for x in obj.model.status.conditions) - ) - assert success, "Authorino did got get ready in time" - self.refresh() - @property def deployment(self): """Returns Deployment object for this Authorino""" diff --git a/testsuite/openshift/kuadrant.py b/testsuite/openshift/kuadrant.py index 8230e6fc..d488a67b 100644 --- a/testsuite/openshift/kuadrant.py +++ b/testsuite/openshift/kuadrant.py @@ -2,7 +2,7 @@ import dataclasses -from openshift_client import selector, timeout +from openshift_client import selector from testsuite.openshift import CustomResource from testsuite.openshift.deployment import Deployment @@ -57,13 +57,3 @@ def limitador_deployment(self): """Returns Deployment object for this Authorino""" with self.context: return selector(f"deployment/{self.LIMITADOR}").object(cls=Deployment) - - def wait_for_ready(self): - """Waits until Kuadrant CR reports ready status""" - with timeout(90): - success, _, _ = self.self_selector().until_all( - success_func=lambda obj: len(obj.model.status.conditions) > 0 - and all(x.status == "True" for x in obj.model.status.conditions) - ) - assert success, "Kuadrant did got get ready in time" - self.refresh()