|
4 | 4 | import yaml |
5 | 5 | from _pytest.fixtures import FixtureRequest |
6 | 6 | from kubernetes.dynamic import DynamicClient |
7 | | -from ocp_resources.authorino import Authorino |
8 | 7 | from ocp_resources.cluster_service_version import ClusterServiceVersion |
9 | 8 | from ocp_resources.config_map import ConfigMap |
10 | 9 | from ocp_resources.inference_service import InferenceService |
11 | 10 | from ocp_resources.namespace import Namespace |
12 | 11 | from ocp_resources.persistent_volume_claim import PersistentVolumeClaim |
13 | 12 | from ocp_resources.secret import Secret |
14 | 13 | from ocp_resources.service_account import ServiceAccount |
15 | | -from ocp_resources.service_mesh_control_plane import ServiceMeshControlPlane |
16 | 14 | from ocp_resources.serving_runtime import ServingRuntime |
17 | 15 | from ocp_resources.storage_class import StorageClass |
18 | 16 | from ocp_utilities.monitoring import Prometheus |
19 | 17 | from pytest_testconfig import config as py_config |
| 18 | +from simple_logger.logger import get_logger |
20 | 19 |
|
21 | 20 | from utilities.constants import ( |
22 | 21 | KServeDeploymentType, |
|
40 | 39 | from utilities.serving_runtime import ServingRuntimeFromTemplate |
41 | 40 |
|
42 | 41 |
|
43 | | -@pytest.fixture(scope="package") |
44 | | -def skip_if_no_deployed_openshift_serverless(admin_client: DynamicClient) -> None: |
45 | | - name = "openshift-serverless" |
46 | | - csvs = list( |
47 | | - ClusterServiceVersion.get( |
48 | | - client=admin_client, |
49 | | - namespace=name, |
50 | | - label_selector=f"operators.coreos.com/serverless-operator.{name}", |
51 | | - ) |
52 | | - ) |
53 | | - if not csvs: |
54 | | - pytest.skip("OpenShift Serverless is not deployed") |
55 | | - |
56 | | - csv = csvs[0] |
57 | | - |
58 | | - if not (csv.exists and csv.status == csv.Status.SUCCEEDED): |
59 | | - pytest.skip("OpenShift Serverless is not deployed") |
| 42 | +LOGGER = get_logger(name=__name__) |
60 | 43 |
|
61 | 44 |
|
62 | 45 | @pytest.fixture(scope="class") |
@@ -189,28 +172,6 @@ def skip_if_no_nfs_storage_class(admin_client: DynamicClient) -> None: |
189 | 172 | pytest.skip(f"StorageClass {StorageClassName.NFS} is missing from the cluster") |
190 | 173 |
|
191 | 174 |
|
192 | | -@pytest.fixture(scope="package") |
193 | | -def skip_if_no_deployed_redhat_authorino_operator(admin_client: DynamicClient) -> None: |
194 | | - name = "authorino" |
195 | | - namespace = f"{py_config['applications_namespace']}-auth-provider" |
196 | | - |
197 | | - if not Authorino( |
198 | | - client=admin_client, |
199 | | - name=name, |
200 | | - namespace=namespace, |
201 | | - ).exists: |
202 | | - pytest.skip(f"Authorino {name} CR is missing from {namespace} namespace") |
203 | | - |
204 | | - |
205 | | -@pytest.fixture(scope="package") |
206 | | -def skip_if_no_deployed_openshift_service_mesh(admin_client: DynamicClient) -> None: |
207 | | - smcp = ServiceMeshControlPlane(client=admin_client, name="data-science-smcp", namespace="istio-system") |
208 | | - if not smcp or not smcp.exists: |
209 | | - pytest.skip("OpenShift service mesh operator is not deployed") |
210 | | - |
211 | | - smcp.wait_for_condition(condition=smcp.Condition.READY, status="True") |
212 | | - |
213 | | - |
214 | 175 | @pytest.fixture(scope="class") |
215 | 176 | def http_s3_openvino_model_mesh_inference_service( |
216 | 177 | request: FixtureRequest, |
@@ -608,3 +569,32 @@ def unprivileged_s3_caikit_serverless_inference_service( |
608 | 569 | storage_path=request.param["model-dir"], |
609 | 570 | ) as isvc: |
610 | 571 | yield isvc |
| 572 | + |
| 573 | + |
| 574 | +@pytest.fixture(scope="package") |
| 575 | +def fail_if_missing_dependent_operators(admin_client: DynamicClient) -> None: |
| 576 | + missing_operators: list[str] = [] |
| 577 | + csvs = list( |
| 578 | + ClusterServiceVersion.get( |
| 579 | + dyn_client=admin_client, |
| 580 | + namespace=py_config["applications_namespace"], |
| 581 | + ) |
| 582 | + ) |
| 583 | + |
| 584 | + for operator_name in py_config.get("dependent_operators", []).split(","): |
| 585 | + LOGGER.info(f"Verifying if {operator_name} is installed") |
| 586 | + for csv in csvs: |
| 587 | + if csv.name.startswith(operator_name): |
| 588 | + if csv.status == csv.Status.SUCCEEDED: |
| 589 | + break |
| 590 | + |
| 591 | + else: |
| 592 | + missing_operators.append( |
| 593 | + f"Operator {operator_name} is installed but CSV is not in {csv.Status.SUCCEEDED} state" |
| 594 | + ) |
| 595 | + |
| 596 | + else: |
| 597 | + missing_operators.append(f"{operator_name} is not installed") |
| 598 | + |
| 599 | + if missing_operators: |
| 600 | + pytest.fail(str(missing_operators)) |
0 commit comments