3131from ocp_resources .resource import get_client
3232from pytest_testconfig import config as py_config
3333from simple_logger .logger import get_logger
34+ import json
3435
3536from ocp_utilities .operators import uninstall_operator , install_operator
3637from utilities .certificates_utils import create_ca_bundle_file
@@ -110,7 +111,7 @@ def model_namespace(
110111 ns .clean_up ()
111112 else :
112113 with create_ns (
113- client = admin_client ,
114+ admin_client = admin_client ,
114115 pytest_request = request ,
115116 teardown = teardown_resources ,
116117 ) as ns :
@@ -139,6 +140,28 @@ def aws_secret_access_key(pytestconfig: Config) -> str:
139140 return secret_access_key
140141
141142
143+ @pytest .fixture (scope = "session" )
144+ def registry_pull_secret (pytestconfig : Config ) -> str :
145+ registry_pull_secret = pytestconfig .option .registry_pull_secret
146+ if not registry_pull_secret :
147+ raise ValueError (
148+ "Registry pull secret is not set. "
149+ "Either pass with `--registry_pull_secret` or set `OCI_REGISTRY_PULL_SECRET` environment variable"
150+ )
151+ return registry_pull_secret
152+
153+
154+ @pytest .fixture (scope = "session" )
155+ def registry_host (pytestconfig : pytest .Config ) -> str | None :
156+ registry_host = pytestconfig .option .registry_host
157+ if not registry_host :
158+ raise ValueError (
159+ "Registry host for OCI images is not set. "
160+ "Either pass with `--registry_host` or set `REGISTRY_HOST` environment variable"
161+ )
162+ return registry_host
163+
164+
142165@pytest .fixture (scope = "session" )
143166def valid_aws_config (aws_access_key_id : str , aws_secret_access_key : str ) -> tuple [str , str ]:
144167 return aws_access_key_id , aws_secret_access_key
@@ -177,6 +200,40 @@ def ci_s3_bucket_endpoint(pytestconfig: pytest.Config) -> str:
177200 return ci_bucket_endpoint
178201
179202
203+ @pytest .fixture (scope = "session" )
204+ def serving_argument (pytestconfig : pytest .Config , modelcar_yaml_config : dict [str , Any ] | None ) -> list [str ]:
205+ if modelcar_yaml_config :
206+ arg = modelcar_yaml_config .get ("serving_argument" , [])
207+ return arg if isinstance (arg , list ) else [arg ]
208+
209+ raw_arg = pytestconfig .option .serving_argument
210+ try :
211+ return json .loads (raw_arg )
212+ except json .JSONDecodeError :
213+ raise ValueError (
214+ "Serving arguments should be a valid JSON list. "
215+ "Either pass with `--serving-argument` or set it correctly in modelcar.yaml"
216+ )
217+
218+
219+ @pytest .fixture (scope = "session" )
220+ def modelcar_yaml_config (pytestconfig : pytest .Config ) -> dict [str , Any ] | None :
221+ """
222+ Fixture to get the path to the modelcar.yaml file.
223+ """
224+ config_path = pytestconfig .option .model_car_yaml_path
225+ if not config_path :
226+ return None
227+ with open (config_path , "r" ) as file :
228+ try :
229+ modelcar_yaml = yaml .safe_load (file )
230+ if not isinstance (modelcar_yaml , dict ):
231+ raise ValueError ("modelcar.yaml should contain a dictionary." )
232+ return modelcar_yaml
233+ except yaml .YAMLError as e :
234+ raise ValueError (f"Error parsing modelcar.yaml: { e } " ) from e
235+
236+
180237@pytest .fixture (scope = "session" )
181238def models_s3_bucket_name (pytestconfig : pytest .Config ) -> str :
182239 models_bucket = pytestconfig .option .models_s3_bucket_name
@@ -407,12 +464,12 @@ def cluster_monitoring_config(
407464
408465@pytest .fixture (scope = "class" )
409466def unprivileged_model_namespace (
410- request : FixtureRequest , unprivileged_client : DynamicClient
467+ request : FixtureRequest , admin_client : DynamicClient , unprivileged_client : DynamicClient
411468) -> Generator [Namespace , Any , Any ]:
412469 if request .param .get ("modelmesh-enabled" ):
413470 request .getfixturevalue (argname = "enabled_modelmesh_in_dsc" )
414471
415- with create_ns (unprivileged_client = unprivileged_client , pytest_request = request ) as ns :
472+ with create_ns (admin_client = admin_client , unprivileged_client = unprivileged_client , pytest_request = request ) as ns :
416473 yield ns
417474
418475
@@ -421,7 +478,7 @@ def unprivileged_model_namespace(
421478def minio_namespace (admin_client : DynamicClient ) -> Generator [Namespace , Any , Any ]:
422479 with create_ns (
423480 name = f"{ MinIo .Metadata .NAME } -{ shortuuid .uuid ().lower ()} " ,
424- client = admin_client ,
481+ admin_client = admin_client ,
425482 ) as ns :
426483 yield ns
427484
0 commit comments