|
47 | 47 | from utilities.constants import Protocols, DscComponents |
48 | 48 | from model_registry import ModelRegistry as ModelRegistryClient |
49 | 49 | from semver import Version |
50 | | -from utilities.infra import get_product_version |
51 | | -from utilities.operator_utils import get_cluster_service_version, validate_operator_subscription_channel |
52 | 50 | from utilities.general import wait_for_pods_by_labels |
53 | 51 |
|
54 | 52 | LOGGER = get_logger(name=__name__) |
@@ -182,16 +180,36 @@ def model_registry_instance( |
182 | 180 |
|
183 | 181 | @pytest.fixture(scope="class") |
184 | 182 | def model_registry_mysql_config( |
185 | | - model_registry_db_deployment: Deployment, model_registry_db_secret: Secret |
| 183 | + request: FixtureRequest, |
| 184 | + model_registry_db_deployment: Deployment, |
| 185 | + model_registry_db_secret: Secret, |
186 | 186 | ) -> dict[str, Any]: |
187 | | - return { |
| 187 | + """ |
| 188 | + Fixture to build the MySQL config dictionary for Model Registry. |
| 189 | + Expects request.param to be a dict. If 'sslRootCertificateConfigMap' is not present, it defaults to None. |
| 190 | + If 'sslRootCertificateConfigMap' is present, it will be used to configure the MySQL connection. |
| 191 | +
|
| 192 | + Args: |
| 193 | + request: The pytest request object |
| 194 | + model_registry_db_deployment: The model registry db deployment |
| 195 | + model_registry_db_secret: The model registry db secret |
| 196 | +
|
| 197 | + Returns: |
| 198 | + dict[str, Any]: The MySQL config dictionary |
| 199 | + """ |
| 200 | + param = request.param if hasattr(request, "param") else {} |
| 201 | + config = { |
188 | 202 | "host": f"{model_registry_db_deployment.name}.{model_registry_db_deployment.namespace}.svc.cluster.local", |
189 | 203 | "database": model_registry_db_secret.string_data["database-name"], |
190 | 204 | "passwordSecret": {"key": "database-password", "name": model_registry_db_deployment.name}, |
191 | | - "port": 3306, |
| 205 | + "port": param.get("port", 3306), |
192 | 206 | "skipDBCreation": False, |
193 | 207 | "username": model_registry_db_secret.string_data["database-user"], |
194 | 208 | } |
| 209 | + if "sslRootCertificateConfigMap" in param: |
| 210 | + config["sslRootCertificateConfigMap"] = param["sslRootCertificateConfigMap"] |
| 211 | + |
| 212 | + return config |
195 | 213 |
|
196 | 214 |
|
197 | 215 | @pytest.fixture(scope="class") |
@@ -362,47 +380,6 @@ def model_registry_instance_pod(admin_client: DynamicClient) -> Generator[Pod, A |
362 | 380 | )[0] |
363 | 381 |
|
364 | 382 |
|
365 | | -@pytest.fixture(scope="package", autouse=True) |
366 | | -def validate_authorino_operator_version_channel(admin_client: DynamicClient) -> None: |
367 | | - """Check if Authorino operator is installed with required version and channel. |
368 | | -
|
369 | | - This fixture is automatically used for all tests in the model_registry directory. |
370 | | - It verifies that: |
371 | | - 1. For OpenShift AI: The product version is >= 2.20 |
372 | | - 2. The Authorino operator is installed |
373 | | - 3. The Authorino operator is using the required channel (stable) |
374 | | - 4. The Authorino operator is at least version 1.2.1 |
375 | | - """ |
376 | | - distribution = py_config["distribution"] |
377 | | - if distribution == "upstream": |
378 | | - # TODO: figure out minimum version for ODH |
379 | | - LOGGER.info(f"Skipping Authorino operator check for {distribution} distribution") |
380 | | - return |
381 | | - # Only check product version for OpenShift AI |
382 | | - if distribution == "downstream": |
383 | | - product_version = get_product_version(admin_client=admin_client) |
384 | | - if product_version < MIN_MR_VERSION: |
385 | | - LOGGER.info( |
386 | | - "Skipping Authorino operator check - product version " |
387 | | - f"{product_version} is below required {MIN_MR_VERSION}" |
388 | | - ) |
389 | | - return |
390 | | - operator_name = "authorino-operator" |
391 | | - # Find the CSV for the operator |
392 | | - authorino_csv = get_cluster_service_version( |
393 | | - client=admin_client, prefix=operator_name, namespace=py_config["applications_namespace"] |
394 | | - ) |
395 | | - current_authorino_version = authorino_csv.instance.spec.version |
396 | | - if Version.parse(version="1.2.1") > Version.parse(version=current_authorino_version): |
397 | | - pytest.exit( |
398 | | - f"Authorino operator is not at least version 1.2.1. Current version: {current_authorino_version}" |
399 | | - ) |
400 | | - |
401 | | - validate_operator_subscription_channel( |
402 | | - client=admin_client, namespace="openshift-operators", operator_name=operator_name, channel_name="stable" |
403 | | - ) |
404 | | - |
405 | | - |
406 | 383 | @pytest.fixture(scope="class") |
407 | 384 | def is_model_registry_oauth(request: FixtureRequest) -> bool: |
408 | 385 | return getattr(request, "param", {}).get("use_oauth_proxy", True) |
|
0 commit comments