Skip to content

Commit 5b9ee20

Browse files
committed
Merge remote-tracking branch 'upstream/main' into add_ossm
2 parents d0e7a38 + 3421741 commit 5b9ee20

File tree

19 files changed

+833
-166
lines changed

19 files changed

+833
-166
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ repos:
1919
- id: check-toml
2020

2121
- repo: https://github.com/PyCQA/flake8
22-
rev: "7.2.0"
22+
rev: "7.3.0"
2323
hooks:
2424
- id: flake8
2525
args: [--config=.flake8]
@@ -35,7 +35,7 @@ repos:
3535
- id: detect-secrets
3636

3737
- repo: https://github.com/astral-sh/ruff-pre-commit
38-
rev: v0.11.13
38+
rev: v0.12.0
3939
hooks:
4040
- id: ruff
4141
- id: ruff-format
@@ -54,7 +54,7 @@ repos:
5454
- id: gitleaks
5555

5656
- repo: https://github.com/pre-commit/mirrors-mypy
57-
rev: v1.16.0
57+
rev: v1.16.1
5858
hooks:
5959
- id: mypy
6060
additional_dependencies: ["types-PyYAML", "types-requests"]

conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
collect_rhoai_must_gather,
3333
get_base_dir,
3434
)
35-
3635
from kubernetes.dynamic import DynamicClient
3736
from utilities.infra import get_operator_distribution, get_dsci_applications_namespace, get_data_science_cluster
3837
from ocp_resources.resource import get_client
3938

39+
4040
LOGGER = logging.getLogger(name=__name__)
4141
BASIC_LOGGER = logging.getLogger(name="basic")
4242

tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
Protocols,
4545
)
4646
from utilities.infra import update_configmap_data
47+
from utilities.logger import RedactedString
4748
from utilities.minio import create_minio_data_connection_secret
4849
from utilities.operator_utils import get_csv_related_images
4950

@@ -68,7 +69,7 @@ def tests_tmp_dir(request: FixtureRequest, tmp_path_factory: TempPathFactory) ->
6869

6970
@pytest.fixture(scope="session")
7071
def current_client_token(admin_client: DynamicClient) -> str:
71-
return get_openshift_token()
72+
return RedactedString(value=get_openshift_token())
7273

7374

7475
@pytest.fixture(scope="session")

tests/model_explainability/guardrails/test_guardrails.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323

2424

2525
@pytest.mark.parametrize(
26-
"model_namespace",
26+
"model_namespace, minio_pod, minio_data_connection",
2727
[
2828
pytest.param(
2929
{"name": "test-guardrails-image"},
30+
MinIo.PodConfig.QWEN_MINIO_CONFIG,
31+
{"bucket": "llms"},
3032
)
3133
],
3234
indirect=True,

tests/model_explainability/guardrails/utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def get_chat_payload(content: str) -> Dict[str, Any]:
1818
"messages": [
1919
{"role": "user", "content": content},
2020
],
21-
"temperature": "0.0",
2221
}
2322

2423

tests/model_explainability/trustyai_service/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
create_isvc_getter_service_account,
5151
create_isvc_getter_token_secret,
5252
)
53+
from utilities.logger import RedactedString
5354
from utilities.operator_utils import get_cluster_service_version
5455

5556
from utilities.constants import Timeout, KServeDeploymentType, Labels
@@ -369,4 +370,4 @@ def isvc_getter_token_secret(
369370

370371
@pytest.fixture(scope="class")
371372
def isvc_getter_token(isvc_getter_service_account: ServiceAccount, isvc_getter_token_secret: Secret) -> str:
372-
return create_inference_token(model_service_account=isvc_getter_service_account)
373+
return RedactedString(value=create_inference_token(model_service_account=isvc_getter_service_account))

tests/model_registry/conftest.py

Lines changed: 23 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@
4747
from utilities.constants import Protocols, DscComponents
4848
from model_registry import ModelRegistry as ModelRegistryClient
4949
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
5250
from utilities.general import wait_for_pods_by_labels
5351

5452
LOGGER = get_logger(name=__name__)
@@ -182,16 +180,36 @@ def model_registry_instance(
182180

183181
@pytest.fixture(scope="class")
184182
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,
186186
) -> 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 = {
188202
"host": f"{model_registry_db_deployment.name}.{model_registry_db_deployment.namespace}.svc.cluster.local",
189203
"database": model_registry_db_secret.string_data["database-name"],
190204
"passwordSecret": {"key": "database-password", "name": model_registry_db_deployment.name},
191-
"port": 3306,
205+
"port": param.get("port", 3306),
192206
"skipDBCreation": False,
193207
"username": model_registry_db_secret.string_data["database-user"],
194208
}
209+
if "sslRootCertificateConfigMap" in param:
210+
config["sslRootCertificateConfigMap"] = param["sslRootCertificateConfigMap"]
211+
212+
return config
195213

196214

197215
@pytest.fixture(scope="class")
@@ -362,47 +380,6 @@ def model_registry_instance_pod(admin_client: DynamicClient) -> Generator[Pod, A
362380
)[0]
363381

364382

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-
406383
@pytest.fixture(scope="class")
407384
def is_model_registry_oauth(request: FixtureRequest) -> bool:
408385
return getattr(request, "param", {}).get("use_oauth_proxy", True)

tests/model_registry/constants.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class ModelRegistryEndpoints:
2626
},
2727
}
2828
MR_INSTANCE_NAME: str = "model-registry"
29+
SECURE_MR_NAME: str = "secure-db-mr"
2930
ISTIO_CONFIG_DICT: dict[str, Any] = {
3031
"gateway": {"grpc": {"tls": {}}, "rest": {"tls": {}}},
3132
}
@@ -48,6 +49,11 @@ class ModelRegistryEndpoints:
4849
f"{Resource.ApiGroup.TEMPLATE_OPENSHIFT_IO}/expose-password": "'{.data[''database-password'']}'",
4950
f"{Resource.ApiGroup.TEMPLATE_OPENSHIFT_IO}/expose-username": "'{.data[''database-user'']}'",
5051
}
52+
53+
CA_CONFIGMAP_NAME = "odh-trusted-ca-bundle"
54+
CA_MOUNT_PATH = "/etc/pki/ca-trust/extracted/pem"
55+
CA_FILE_PATH = f"{CA_MOUNT_PATH}/ca-bundle.crt"
56+
5157
MODEL_REGISTRY_STANDARD_LABELS = {
5258
Annotations.KubernetesIo.NAME: MR_INSTANCE_NAME,
5359
Annotations.KubernetesIo.INSTANCE: MR_INSTANCE_NAME,

0 commit comments

Comments
 (0)