1616 apply_mysql_args_and_volume_mounts ,
1717 add_mysql_certs_volumes_to_deployment ,
1818 wait_for_pods_running ,
19+ get_mr_standard_labels ,
20+ get_mysql_config ,
1921)
2022
2123from tests .model_registry .constants import (
22- DB_RESOURCES_NAME ,
24+ DB_RESOURCE_NAME ,
2325 CA_MOUNT_PATH ,
2426 CA_FILE_PATH ,
2527 CA_CONFIGMAP_NAME ,
2628 OAUTH_PROXY_CONFIG_DICT ,
27- MODEL_REGISTRY_STANDARD_LABELS ,
2829 SECURE_MR_NAME ,
2930)
3031from ocp_resources .resource import ResourceEditor
4546def registered_model_rest_api (
4647 request : pytest .FixtureRequest ,
4748 is_model_registry_oauth : bool ,
48- model_registry_rest_url : str ,
49+ model_registry_rest_url : list [ str ] ,
4950 model_registry_rest_headers : dict [str , str ],
5051) -> dict [str , Any ]:
5152 return register_model_rest_api (
52- model_registry_rest_url = model_registry_rest_url ,
53+ model_registry_rest_url = model_registry_rest_url [ 0 ] ,
5354 model_registry_rest_headers = model_registry_rest_headers ,
5455 data_dict = request .param ,
5556 )
@@ -58,7 +59,7 @@ def registered_model_rest_api(
5859@pytest .fixture ()
5960def updated_model_registry_resource (
6061 request : pytest .FixtureRequest ,
61- model_registry_rest_url : str ,
62+ model_registry_rest_url : list [ str ] ,
6263 model_registry_rest_headers : dict [str , str ],
6364 registered_model_rest_api : dict [str , Any ],
6465) -> dict [str , Any ]:
@@ -80,7 +81,7 @@ def updated_model_registry_resource(
8081 resource_id = registered_model_rest_api [resource_name ]["id" ]
8182 assert resource_id , f"Resource id not found: { registered_model_rest_api [resource_name ]} "
8283 return execute_model_registry_patch_command (
83- url = f"{ model_registry_rest_url } { MODEL_REGISTRY_BASE_URI } { api_name } /{ resource_id } " ,
84+ url = f"{ model_registry_rest_url [ 0 ] } { MODEL_REGISTRY_BASE_URI } { api_name } /{ resource_id } " ,
8485 headers = model_registry_rest_headers ,
8586 data_json = request .param ["data" ],
8687 )
@@ -119,7 +120,7 @@ def patch_invalid_ca(
119120
120121
121122@pytest .fixture (scope = "class" )
122- def mysql_template_with_ca (model_registry_db_secret : Secret ) -> dict [str , Any ]:
123+ def mysql_template_with_ca (model_registry_db_secret : list [ Secret ] ) -> dict [str , Any ]:
123124 """
124125 Patches the MySQL template with the CA file path and volume mount.
125126
@@ -130,8 +131,8 @@ def mysql_template_with_ca(model_registry_db_secret: Secret) -> dict[str, Any]:
130131 dict[str, Any]: The patched MySQL template
131132 """
132133 mysql_template = get_model_registry_deployment_template_dict (
133- secret_name = model_registry_db_secret .name ,
134- resource_name = DB_RESOURCES_NAME ,
134+ secret_name = model_registry_db_secret [ 0 ] .name ,
135+ resource_name = DB_RESOURCE_NAME ,
135136 )
136137 mysql_template ["spec" ]["containers" ][0 ]["args" ].append (f"--ssl-ca={ CA_FILE_PATH } " )
137138 mysql_template ["spec" ]["containers" ][0 ]["volumeMounts" ].append ({
@@ -145,33 +146,29 @@ def mysql_template_with_ca(model_registry_db_secret: Secret) -> dict[str, Any]:
145146
146147@pytest .fixture (scope = "class" )
147148def deploy_secure_mysql_and_mr (
149+ request : pytest .FixtureRequest ,
148150 admin_client : DynamicClient ,
149151 model_registry_namespace : str ,
150- model_registry_mysql_metadata_db : Deployment ,
151- model_registry_mysql_config : dict [str , Any ],
152+ model_registry_mysql_metadata_db : list [Deployment ],
152153 mysql_template_with_ca : dict [str , Any ],
153154 patch_mysql_deployment_with_ssl_ca : Deployment ,
154155) -> Generator [ModelRegistry , None , None ]:
155156 """
156157 Deploy a secure MySQL and Model Registry instance.
157-
158- Args:
159- model_registry_namespace: The namespace of the model registry
160- model_registry_db_secret: The secret for the model registry's MySQL database
161- model_registry_db_deployment: The deployment for the model registry's MySQL database
162- model_registry_mysql_config: The MySQL config dictionary
163- mysql_template_with_ca: The MySQL template with the CA file path and volume mount
164- patch_mysql_deployment_with_ssl_ca: The MySQL deployment with the CA file path and volume mount
165158 """
159+ param = getattr (request , "param" , {})
160+ mysql = get_mysql_config (base_name = DB_RESOURCE_NAME , namespace = model_registry_namespace )
161+ if "sslRootCertificateConfigMap" in param :
162+ mysql ["sslRootCertificateConfigMap" ] = param ["sslRootCertificateConfigMap" ]
166163 with ModelRegistry (
167164 name = SECURE_MR_NAME ,
168165 namespace = model_registry_namespace ,
169- label = MODEL_REGISTRY_STANDARD_LABELS ,
166+ label = get_mr_standard_labels ( resource_name = SECURE_MR_NAME ) ,
170167 grpc = {},
171168 rest = {},
172169 istio = None ,
173170 oauth_proxy = OAUTH_PROXY_CONFIG_DICT ,
174- mysql = model_registry_mysql_config ,
171+ mysql = mysql ,
175172 wait_for_resource = True ,
176173 ) as mr :
177174 mr .wait_for_condition (condition = "Available" , status = "True" )
@@ -216,7 +213,7 @@ def ca_configmap_for_test(
216213 Args:
217214 admin_client: The admin client to create the ConfigMap
218215 model_registry_namespace: The namespace of the model registry
219- mysql_ssl_secrets : The artifacts and secrets for the MySQL SSL connection
216+ mysql_ssl_artifact_paths : The artifacts and secrets for the MySQL SSL connection
220217
221218 Returns:
222219 Generator[ConfigMap, None, None]: A generator that yields the ConfigMap instance.
@@ -241,7 +238,7 @@ def patch_mysql_deployment_with_ssl_ca(
241238 request : pytest .FixtureRequest ,
242239 admin_client : DynamicClient ,
243240 model_registry_namespace : str ,
244- model_registry_db_deployment : Deployment ,
241+ model_registry_db_deployment : list [ Deployment ] ,
245242 mysql_ssl_secrets : dict [str , Any ],
246243) -> Generator [Deployment , Any , Any ]:
247244 """
@@ -251,11 +248,11 @@ def patch_mysql_deployment_with_ssl_ca(
251248
252249 if request .param .get ("ca_configmap_for_test" ):
253250 LOGGER .info ("Invoking ca_configmap_for_test fixture" )
254- request .getfixturevalue ("ca_configmap_for_test" ) # noqa: FCN001
251+ request .getfixturevalue (argname = "ca_configmap_for_test" )
255252 CA_CONFIGMAP_NAME = request .param .get ("ca_configmap_name" , "mysql-ca-configmap" )
256253 CA_MOUNT_PATH = request .param .get ("ca_mount_path" , "/etc/mysql/ssl" )
257254
258- deployment = model_registry_db_deployment .instance .to_dict ()
255+ deployment = model_registry_db_deployment [ 0 ] .instance .to_dict ()
259256 spec = deployment ["spec" ]["template" ]["spec" ]
260257 my_sql_container = next (container for container in spec ["containers" ] if container ["name" ] == "mysql" )
261258 assert my_sql_container is not None , "Mysql container not found"
@@ -266,9 +263,9 @@ def patch_mysql_deployment_with_ssl_ca(
266263 volumes = add_mysql_certs_volumes_to_deployment (spec = spec , ca_configmap_name = CA_CONFIGMAP_NAME )
267264
268265 patch = {"spec" : {"template" : {"spec" : {"volumes" : volumes , "containers" : [my_sql_container ]}}}}
269- with ResourceEditor (patches = {model_registry_db_deployment : patch }):
270- model_registry_db_deployment .wait_for_condition (condition = "Available" , status = "True" )
271- yield model_registry_db_deployment
266+ with ResourceEditor (patches = {model_registry_db_deployment [ 0 ] : patch }):
267+ model_registry_db_deployment [ 0 ] .wait_for_condition (condition = "Available" , status = "True" )
268+ yield model_registry_db_deployment [ 0 ]
272269
273270
274271@pytest .fixture (scope = "class" )
0 commit comments