Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,17 @@ def pytest_runtest_setup(item: Item) -> None:
"""
Performs the following actions:
1. Updates global config (`updated_global_config`)
2. Adds skip fixture for kserve if serverless or authorino operators are not installed.
3. Adds skip fixture for serverless if authorino/serverless/service mesh are not deployed.
2. Adds `fail_if_missing_dependent_operators` fixture for Serverless and model registry tests.
3. Adds fixtures to enable KServe/model mesh in DSC for model server tests.
"""

BASIC_LOGGER.info(f"\n{separator(symbol_='-', val=item.name)}")
BASIC_LOGGER.info(f"{separator(symbol_='-', val='SETUP')}")

if "model_registry" in pathlib.Path(item.path).parts or KServeDeploymentType.SERVERLESS.lower() in item.keywords:
item.fixturenames.insert(0, "fail_if_missing_dependent_operators")

if KServeDeploymentType.SERVERLESS.lower() in item.keywords:
item.fixturenames.insert(0, "skip_if_no_deployed_redhat_authorino_operator")
item.fixturenames.insert(0, "skip_if_no_deployed_openshift_serverless")
item.fixturenames.insert(0, "skip_if_no_deployed_openshift_service_mesh")
item.fixturenames.insert(0, "enabled_kserve_in_dsc")

elif KServeDeploymentType.RAW_DEPLOYMENT.lower() in item.keywords:
Expand Down
7 changes: 7 additions & 0 deletions docs/GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ By default, cluster sanity checks are run to make cluster ready for tests.
To skip cluster sanity checks, pass `--cluster-sanity-skip-check` to skip all tests.
To skip RHOAI/ODH-related tests (for example when running in upstream), pass `--cluster-sanity-skip-rhoai-check`.

### Check dependent operators
By default, `Serveless` (serverless-operator), `Authorino` (authorino-operator) and `Service Mesh` (servicemeshoperator) operators are checked to be installed when
running model registry or model server Serverless tests.
To check only specific operator, pass `--tc=dependent_operators:<operator_name>` to pytest.
For example, to check only `Serveless` and `Service Mesh` operators, pass `--tc=dependent_operators:serverless-operator,servicemeshoperator`.


### jira integration
To skip running tests which have open bugs, [pytest_jira](https://github.com/rhevm-qe-automation/pytest_jira) plugin is used.
To run tests with jira integration, you need to set `PYTEST_JIRA_URL` and `PYTEST_JIRA_TOKEN` environment variables.
Expand Down
25 changes: 25 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import shortuuid
import yaml
from _pytest.tmpdir import TempPathFactory
from ocp_resources.cluster_service_version import ClusterServiceVersion
from ocp_resources.config_map import ConfigMap
from ocp_resources.dsc_initialization import DSCInitialization
from ocp_resources.node import Node
Expand Down Expand Up @@ -478,3 +479,27 @@ def cluster_sanity_scope_session(
dsci_resource=dsci_resource,
junitxml_property=junitxml_plugin,
)


@pytest.fixture(scope="session")
def fail_if_missing_dependent_operators(admin_client: DynamicClient) -> None:
missing_operators: list[str] = []

for operator_name in py_config.get("dependent_operators", []).split(","):
LOGGER.info(f"Verifying if {operator_name} is installed")
for csv in ClusterServiceVersion.get(
dyn_client=admin_client,
namespace=py_config["applications_namespace"],
):
if csv.name.startswith(operator_name):
if csv.status == csv.Status.SUCCEEDED:
break

else:
missing_operators.append(operator_name)

else:
missing_operators.append(operator_name)

if missing_operators:
pytest.fail(f"Missing dependent operators: {missing_operators}")
1 change: 1 addition & 0 deletions tests/global_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
applications_namespace: str = "redhat-ods-applications" # overwritten in conftest.py if distribution is upstream
dsc_name: str = "default-dsc"
dsci_name: str = "default-dsci"
dependent_operators: str = "servicemeshoperator,authorino-operator,serverless-operator"

for _dir in dir():
val = locals()[_dir]
Expand Down
45 changes: 0 additions & 45 deletions tests/model_serving/model_server/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@
import yaml
from _pytest.fixtures import FixtureRequest
from kubernetes.dynamic import DynamicClient
from ocp_resources.authorino import Authorino
from ocp_resources.cluster_service_version import ClusterServiceVersion
from ocp_resources.config_map import ConfigMap
from ocp_resources.inference_service import InferenceService
from ocp_resources.namespace import Namespace
from ocp_resources.persistent_volume_claim import PersistentVolumeClaim
from ocp_resources.secret import Secret
from ocp_resources.service_account import ServiceAccount
from ocp_resources.service_mesh_control_plane import ServiceMeshControlPlane
from ocp_resources.serving_runtime import ServingRuntime
from ocp_resources.storage_class import StorageClass
from ocp_utilities.monitoring import Prometheus
from pytest_testconfig import config as py_config

from utilities.constants import (
KServeDeploymentType,
Expand All @@ -40,25 +36,6 @@
from utilities.serving_runtime import ServingRuntimeFromTemplate


@pytest.fixture(scope="package")
def skip_if_no_deployed_openshift_serverless(admin_client: DynamicClient) -> None:
name = "openshift-serverless"
csvs = list(
ClusterServiceVersion.get(
client=admin_client,
namespace=name,
label_selector=f"operators.coreos.com/serverless-operator.{name}",
)
)
if not csvs:
pytest.skip("OpenShift Serverless is not deployed")

csv = csvs[0]

if not (csv.exists and csv.status == csv.Status.SUCCEEDED):
pytest.skip("OpenShift Serverless is not deployed")


@pytest.fixture(scope="class")
def models_endpoint_s3_secret(
admin_client: DynamicClient,
Expand Down Expand Up @@ -189,28 +166,6 @@ def skip_if_no_nfs_storage_class(admin_client: DynamicClient) -> None:
pytest.skip(f"StorageClass {StorageClassName.NFS} is missing from the cluster")


@pytest.fixture(scope="package")
def skip_if_no_deployed_redhat_authorino_operator(admin_client: DynamicClient) -> None:
name = "authorino"
namespace = f"{py_config['applications_namespace']}-auth-provider"

if not Authorino(
client=admin_client,
name=name,
namespace=namespace,
).exists:
pytest.skip(f"Authorino {name} CR is missing from {namespace} namespace")


@pytest.fixture(scope="package")
def skip_if_no_deployed_openshift_service_mesh(admin_client: DynamicClient) -> None:
smcp = ServiceMeshControlPlane(client=admin_client, name="data-science-smcp", namespace="istio-system")
if not smcp or not smcp.exists:
pytest.skip("OpenShift service mesh operator is not deployed")

smcp.wait_for_condition(condition=smcp.Condition.READY, status="True")


@pytest.fixture(scope="class")
def http_s3_openvino_model_mesh_inference_service(
request: FixtureRequest,
Expand Down