Skip to content

Commit

Permalink
Add wait_for_ready to Deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
pehala committed Jan 9, 2024
1 parent 61b3683 commit cb8cedc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 7 additions & 0 deletions testsuite/openshift/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from testsuite.openshift import OpenShiftObject, Selector
from testsuite.utils import asdict

import openshift as oc


class Deployment(OpenShiftObject):
"""Kubernetes Deployment object"""
Expand Down Expand Up @@ -40,3 +42,8 @@ def create_instance(
}

return cls(model, context=openshift.context)

def wait_for_ready(self, timeout=90):
with oc.timeout(timeout):
success, _, _ = self.self_selector().until_all(success_func=lambda obj: "readyReplicas" in obj.model.status)
assert success, f"Deployment {self.name()} did not get ready in time"
4 changes: 1 addition & 3 deletions testsuite/openshift/httpbin.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def commit(self):
labels={"app": self.label},
)
self.deployment.commit()
self.deployment.wait_for_ready()

self.service = Service.create_instance(
self.openshift,
Expand All @@ -52,9 +53,6 @@ def commit(self):
)
self.service.commit()

with self.openshift.context:
assert self.openshift.is_ready(self.deployment.self_selector()), "Httpbin wasn't ready in time"

def delete(self):
with self.openshift.context:
if self.service:
Expand Down

0 comments on commit cb8cedc

Please sign in to comment.