@@ -460,6 +460,55 @@ def model_registry_instance_pod(admin_client: DynamicClient) -> Generator[Pod, A
460460 )[0 ]
461461
462462
463+ @pytest .fixture ()
464+ def model_registry_db_instance_pod (admin_client : DynamicClient ) -> Generator [Pod , Any , Any ]:
465+ """Get the model registry instance pod."""
466+ yield wait_for_pods_by_labels (
467+ admin_client = admin_client ,
468+ namespace = py_config ["model_registry_namespace" ],
469+ label_selector = f"name={ DB_RESOURCES_NAME } " ,
470+ expected_num_pods = 1 ,
471+ )[0 ]
472+
473+
474+ @pytest .fixture ()
475+ def set_mr_db_dirty (model_registry_db_instance_pod : Pod ) -> int :
476+ """Set the model registry database dirty and return the latest migration version"""
477+ output = model_registry_db_instance_pod .execute (
478+ command = [
479+ "mysql" ,
480+ "-u" ,
481+ MODEL_REGISTRY_DB_SECRET_STR_DATA ["database-user" ],
482+ f"-p{ MODEL_REGISTRY_DB_SECRET_STR_DATA ['database-password' ]} " ,
483+ "-e" ,
484+ "SELECT version FROM schema_migrations ORDER BY version DESC LIMIT 1;" ,
485+ MODEL_REGISTRY_DB_SECRET_STR_DATA ["database-name" ],
486+ ]
487+ )
488+ latest_migration_version = int (output .strip ().split ()[1 ])
489+ model_registry_db_instance_pod .execute (
490+ command = [
491+ "mysql" ,
492+ "-u" ,
493+ MODEL_REGISTRY_DB_SECRET_STR_DATA ["database-user" ],
494+ f"-p{ MODEL_REGISTRY_DB_SECRET_STR_DATA ['database-password' ]} " ,
495+ "-e" ,
496+ f"UPDATE schema_migrations SET dirty = 1 WHERE version = { latest_migration_version } ;" ,
497+ MODEL_REGISTRY_DB_SECRET_STR_DATA ["database-name" ],
498+ ]
499+ )
500+ return latest_migration_version
501+
502+
503+ @pytest .fixture ()
504+ def delete_mr_deployment () -> None :
505+ """Delete the model registry deployment"""
506+ mr_deployment = Deployment (
507+ name = MR_INSTANCE_NAME , namespace = py_config ["model_registry_namespace" ], ensure_exists = True
508+ )
509+ mr_deployment .delete (wait = True )
510+
511+
463512@pytest .fixture (scope = "class" )
464513def is_model_registry_oauth (request : FixtureRequest ) -> bool :
465514 return getattr (request , "param" , {}).get ("use_oauth_proxy" , True )
0 commit comments