diff --git a/tests/model_serving/model_server/operator/__init__.py b/tests/model_serving/model_server/operator/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/model_serving/model_server/operator/test_operator.py b/tests/model_serving/model_server/operator/test_operator.py new file mode 100644 index 0000000..d6d1fbf --- /dev/null +++ b/tests/model_serving/model_server/operator/test_operator.py @@ -0,0 +1,31 @@ +import pytest +from kubernetes.dynamic import DynamicClient +from ocp_resources.deployment import Deployment +from ocp_resources.exceptions import MissingResourceResError + +from utilities.constants import APPLICATIONS_NAMESPACE + + +@pytest.fixture(scope="class") +def odh_model_controller_deployment(admin_client: DynamicClient): + deployment = Deployment( + client=admin_client, + name="odh-model-controller", + namespace=APPLICATIONS_NAMESPACE, + ) + if deployment.exists: + return deployment + + raise MissingResourceResError(name=deployment.name) + + +class TestOperator: + @pytest.mark.smoke + def test_odh_model_controller_deployment(self, odh_model_controller_deployment): + # Check odh-model-controller deployment expected number of replicas + assert odh_model_controller_deployment.instance.spec.replicas == 1 + + @pytest.mark.smoke + def test_odh_model_controller_replicas(self, odh_model_controller_deployment): + # Check odh-model-controller deployment replicas are running + odh_model_controller_deployment.wait_for_replicas() diff --git a/utilities/constants.py b/utilities/constants.py new file mode 100644 index 0000000..b2662e9 --- /dev/null +++ b/utilities/constants.py @@ -0,0 +1 @@ +APPLICATIONS_NAMESPACE: str = "redhat-ods-applications" diff --git a/utilities/serving_runtime.py b/utilities/serving_runtime.py index 0aec586..b9776e7 100644 --- a/utilities/serving_runtime.py +++ b/utilities/serving_runtime.py @@ -4,6 +4,8 @@ from ocp_resources.serving_runtime import ServingRuntime from ocp_resources.template import Template +from utilities.constants import APPLICATIONS_NAMESPACE + class ServingRuntimeFromTemplate(ServingRuntime): def __init__(self, client: DynamicClient, name: str, namespace: str, template_name: str): @@ -18,7 +20,7 @@ def get_model_template(self) -> Template: template = Template( client=self.client, name=self.template_name, - namespace="redhat-ods-applications", + namespace=APPLICATIONS_NAMESPACE, ) if template.exists: return template