|
| 1 | +""" |
| 2 | +Tests to verify that all Model Registry component images (operator and instance container images) |
| 3 | +meet the requirements: |
| 4 | +1. Images are hosted in registry.redhat.io |
| 5 | +2. Images use sha256 digest instead of tags |
| 6 | +3. Images are listed in the CSV's relatedImages section |
| 7 | +""" |
| 8 | + |
1 | 9 | import pytest |
2 | 10 | from typing import Self, Set |
3 | 11 | from simple_logger.logger import get_logger |
4 | 12 | from kubernetes.dynamic import DynamicClient |
5 | 13 |
|
6 | | -from utilities.general import ( |
7 | | - validate_container_images, |
8 | | -) |
| 14 | +from tests.model_registry.constants import MR_INSTANCE_NAME, MR_POSTGRES_DEPLOYMENT_NAME_STR, MR_OPERATOR_NAME |
| 15 | +from tests.model_registry.image_validation.utils import validate_images |
| 16 | +from utilities.constants import Labels |
9 | 17 | from ocp_resources.pod import Pod |
10 | | -from tests.model_registry.utils import get_model_catalog_pod |
| 18 | +from pytest_testconfig import config as py_config |
11 | 19 |
|
12 | 20 | LOGGER = get_logger(name=__name__) |
| 21 | +pytestmark = [pytest.mark.downstream_only, pytest.mark.skip_must_gather, pytest.mark.smoke] |
13 | 22 |
|
14 | 23 |
|
| 24 | +class TestAIHubResourcesImages: |
| 25 | + @pytest.mark.parametrize( |
| 26 | + "resource_pods", |
| 27 | + [ |
| 28 | + pytest.param( |
| 29 | + {"namespace": py_config["model_registry_namespace"], "label_selector": "component=model-catalog"}, |
| 30 | + marks=pytest.mark.smoke, |
| 31 | + id="test_model_catalog_pods_images", |
| 32 | + ), |
| 33 | + pytest.param( |
| 34 | + { |
| 35 | + "namespace": py_config["applications_namespace"], |
| 36 | + "label_selector": f"{Labels.OpenDataHubIo.NAME}={MR_OPERATOR_NAME}", |
| 37 | + }, |
| 38 | + marks=pytest.mark.smoke, |
| 39 | + id="test_model_registry_operator_pods_images", |
| 40 | + ), |
| 41 | + ], |
| 42 | + indirect=True, |
| 43 | + ) |
| 44 | + def test_verify_pod_images( |
| 45 | + self: Self, |
| 46 | + admin_client: DynamicClient, |
| 47 | + resource_pods: list[Pod], |
| 48 | + related_images_refs: Set[str], |
| 49 | + ): |
| 50 | + validate_images(pods_to_validate=resource_pods, related_images_refs=related_images_refs) |
| 51 | + |
| 52 | + |
| 53 | +@pytest.mark.parametrize( |
| 54 | + "model_registry_metadata_db_resources, model_registry_instance, model_registry_instance_pods_by_label", |
| 55 | + [ |
| 56 | + pytest.param({}, {}, {"label_selectors": [f"app={MR_INSTANCE_NAME}"]}), |
| 57 | + pytest.param( |
| 58 | + {"db_name": "default"}, |
| 59 | + {"db_name": "default"}, |
| 60 | + {"label_selectors": [f"app={MR_INSTANCE_NAME}", f"app={MR_POSTGRES_DEPLOYMENT_NAME_STR}"]}, |
| 61 | + ), |
| 62 | + ], |
| 63 | + indirect=True, |
| 64 | +) |
15 | 65 | @pytest.mark.usefixtures( |
16 | 66 | "updated_dsc_component_state_scope_session", |
17 | | - "model_registry_namespace", |
18 | 67 | "model_registry_metadata_db_resources", |
19 | 68 | "model_registry_instance", |
| 69 | + "model_registry_instance_pods_by_label", |
20 | 70 | ) |
21 | | -@pytest.mark.downstream_only |
22 | 71 | class TestModelRegistryImages: |
23 | | - """ |
24 | | - Tests to verify that all Model Registry component images (operator and instance container images) |
25 | | - meet the requirements: |
26 | | - 1. Images are hosted in registry.redhat.io |
27 | | - 2. Images use sha256 digest instead of tags |
28 | | - 3. Images are listed in the CSV's relatedImages section |
29 | | - """ |
30 | | - |
31 | | - @pytest.mark.smoke |
32 | | - @pytest.mark.skip_must_gather |
33 | | - def test_verify_model_registry_images( |
| 72 | + def test_verify_model_registry_pod_images( |
34 | 73 | self: Self, |
35 | 74 | admin_client: DynamicClient, |
36 | | - model_registry_operator_pod: Pod, |
37 | | - model_registry_instance_pod_by_label: Pod, |
38 | | - model_registry_namespace: str, |
| 75 | + model_registry_instance_pods_by_label: list[Pod], |
39 | 76 | related_images_refs: Set[str], |
40 | 77 | ): |
41 | | - model_catalog_pod = get_model_catalog_pod( |
42 | | - client=admin_client, model_registry_namespace=model_registry_namespace |
43 | | - )[0] |
44 | | - validation_errors = [] |
45 | | - for pod in [model_registry_operator_pod, model_registry_instance_pod_by_label, model_catalog_pod]: |
46 | | - validation_errors.extend( |
47 | | - validate_container_images( |
48 | | - pod=pod, valid_image_refs=related_images_refs, skip_patterns=["openshift-service-mesh"] |
49 | | - ) |
50 | | - ) |
51 | | - |
52 | | - if validation_errors: |
53 | | - pytest.fail("\n".join(validation_errors)) |
| 78 | + validate_images(pods_to_validate=model_registry_instance_pods_by_label, related_images_refs=related_images_refs) |
0 commit comments