Skip to content

Commit

Permalink
Merge pull request #455 from jsmolar/tempo_tracing
Browse files Browse the repository at this point in the history
Update KuadrantCR sub-component deployment reference
  • Loading branch information
Jakub Smolar authored Jun 24, 2024
2 parents b107bb7 + 83a7764 commit a4a19f8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 13 deletions.
1 change: 1 addition & 0 deletions testsuite/openshift/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def safe_apply(self):
"""
result, status = self.modify_and_apply(lambda _: True, retries=2)
assert status, f"Unable to apply changes for APIObject with result: {result}"
self.refresh()
return result

def wait_for_ready(self):
Expand Down
3 changes: 2 additions & 1 deletion testsuite/openshift/authorino.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from testsuite.lifecycle import LifecycleObject
from testsuite.openshift import CustomResource
from testsuite.openshift.client import OpenShiftClient
from testsuite.openshift.deployment import Deployment
from testsuite.utils import asdict


Expand Down Expand Up @@ -90,7 +91,7 @@ def create_instance(
def deployment(self):
"""Returns Deployment object for this Authorino"""
with self.context:
return selector(f"deployment/{self.name()}").object()
return selector(f"deployment/{self.name()}").object(cls=Deployment)

@property
def metrics_service(self):
Expand Down
14 changes: 6 additions & 8 deletions testsuite/openshift/kuadrant.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ def __init__(self, kuadrant_cr, spec_name):
self.kuadrant_cr = kuadrant_cr
self.spec_name = spec_name

@property
def deployment(self):
"""Returns Deployment object for CR"""
with self.context:
return selector("deployment", labels={"app": self.spec_name}).object(cls=Deployment)

def __getitem__(self, name):
return self.kuadrant_cr.model.spec[self.spec_name][name]

Expand All @@ -40,8 +46,6 @@ def __getattr__(self, item):
class KuadrantCR(CustomResource):
"""Represents Kuadrant CR objects"""

LIMITADOR = "limitador-limitador"

@property
def authorino(self) -> KuadrantSection:
"""Returns spec.authorino from Kuadrant object"""
Expand All @@ -53,9 +57,3 @@ def limitador(self) -> KuadrantSection:
"""Returns spec.limitador from Kuadrant object"""
self.model.spec.setdefault("limitador", {})
return KuadrantSection(self, "limitador")

@property
def limitador_deployment(self):
"""Returns Deployment object for this Authorino"""
with self.context:
return selector(f"deployment/{self.LIMITADOR}").object(cls=Deployment)
16 changes: 16 additions & 0 deletions testsuite/openshift/limitador.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""Limitador CR object"""

from openshift_client import selector

from testsuite.openshift import CustomResource
from testsuite.openshift.deployment import Deployment


class LimitadorCR(CustomResource):
"""Represents Limitador CR objects"""

@property
def deployment(self) -> Deployment:
"""Returns Deployment object for this Limitador"""
with self.context:
return selector(f"deployment/{self.name()}").object(cls=Deployment)
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_replicas_field_to_reconcile(kuadrant):
kuadrant.wait_for_ready()

assert kuadrant.limitador["replicas"] == 2
assert kuadrant.limitador_deployment.model.spec["replicas"] == 2
assert kuadrant.limitador.deployment.model.spec["replicas"] == 2


def test_resource_requirements_field_to_reconcile(kuadrant):
Expand All @@ -57,7 +57,7 @@ def test_resource_requirements_field_to_reconcile(kuadrant):
kuadrant.wait_for_ready()

assert kuadrant.limitador["resourceRequirements"] == asdict(value)
assert kuadrant.limitador_deployment.model.spec.template.spec.containers[0]["resources"] == asdict(value)
assert kuadrant.limitador.deployment.model.spec.template.spec.containers[0]["resources"] == asdict(value)


@pytest.mark.xfail
Expand All @@ -79,7 +79,7 @@ def test_blank_fields_wont_reconcile(kuadrant):
kuadrant.safe_apply()
kuadrant.wait_for_ready()

assert kuadrant.limitador_deployment.model.spec.replicas == 3
assert kuadrant.limitador_deployment.model.spec.template.spec.containers[0]["resources"] == asdict(
assert kuadrant.limitador.deployment.model.spec.replicas == 3
assert kuadrant.limitador.deployment.model.spec.template.spec.containers[0]["resources"] == asdict(
ContainerResources(requests_cpu="250m", requests_memory="32Mi")
)

0 comments on commit a4a19f8

Please sign in to comment.