33import pytest
44from pytest_testconfig import config as py_config
55
6-
6+ from simple_logger . logger import get_logger
77from tests .workbenches .utils import get_username
88
99from kubernetes .dynamic import DynamicClient
1313from ocp_resources .persistent_volume_claim import PersistentVolumeClaim
1414from ocp_resources .route import Route
1515from ocp_resources .notebook import Notebook
16- from ocp_resources .cluster_operator import ClusterOperator
17-
16+ from ocp_resources .config_imageregistry_operator_openshift_io import Config
1817
19- from utilities .constants import Labels , Timeout
18+ from utilities .constants import Labels
2019from utilities import constants
2120from utilities .constants import INTERNAL_IMAGE_REGISTRY_PATH
2221
22+ LOGGER = get_logger (name = __name__ )
23+
2324
2425@pytest .fixture (scope = "function" )
2526def users_persistent_volume_claim (
@@ -40,21 +41,20 @@ def users_persistent_volume_claim(
4041@pytest .fixture (scope = "function" )
4142def internal_image_registry (
4243 admin_client : DynamicClient ,
43- ) -> Generator [ClusterOperator | None , None , None ]:
44+ ) -> Generator [bool , None , None ]:
45+ """Check if internal image registry is available by checking the imageregistry config managementState"""
4446 try :
45- image_registry = ClusterOperator (
46- client = admin_client ,
47- name = "image-registry" ,
48- ensure_exists = True ,
49- )
50- image_registry .wait_for_condition (
51- condition = ClusterOperator .Condition .AVAILABLE ,
52- status = ClusterOperator .Condition .Status .TRUE ,
53- timeout = Timeout .TIMEOUT_30SEC ,
54- )
55- yield image_registry
56- except ResourceNotFoundError :
57- yield None
47+ # Access the imageregistry.operator.openshift.io/v1 Config resource named "cluster"
48+ config_instance = Config (client = admin_client , name = "cluster" )
49+
50+ management_state = config_instance .instance .spec .get ("managementState" , "" ).lower ()
51+ is_available = management_state == "managed"
52+
53+ LOGGER .info (f"Image registry management state: { management_state } , available: { is_available } " )
54+ yield is_available
55+ except (ResourceNotFoundError , Exception ) as e :
56+ LOGGER .warning (f"Failed to check image registry config: { e } " )
57+ yield False
5858
5959
6060@pytest .fixture (scope = "function" )
@@ -68,7 +68,7 @@ def minimal_image() -> Generator[str, None, None]:
6868def default_notebook (
6969 request : pytest .FixtureRequest ,
7070 admin_client : DynamicClient ,
71- internal_image_registry : ClusterOperator | None ,
71+ internal_image_registry : bool ,
7272 minimal_image : str ,
7373) -> Generator [Notebook , None , None ]:
7474 """Returns a new Notebook CR for a given namespace, name, and image"""
0 commit comments