Skip to content

Commit 511a338

Browse files
authored
[Mino] refactor minio and add model server minio tests (#206)
* Create size-labeler.yml * Delete .github/workflows/size-labeler.yml * model mesh - add auth tests * xx * feat: add gcs tests * feat: refactor minio * feat: refactor minio * feat: refactor minio * feat: add minio tests * fix: update readme * fix: TestGuardrails deploy * fix: add json file * ci: resolve conflicts * fix: fixture names * fix: fixture names * fix: update fixtre name
1 parent d0403ff commit 511a338

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+636
-210
lines changed

docs/GETTING_STARTED.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,12 @@ To run on ODH, pass `--tc=distribution:upstream` to pytest.
6666
To skip running tests which have open bugs, [pytest_jira](https://github.com/rhevm-qe-automation/pytest_jira) plugin is used.
6767
To run tests with jira integration, you need to set `PYTEST_JIRA_URL` and `PYTEST_JIRA_TOKEN` environment variables.
6868
To make a test with jira marker, add: `@pytest.mark.jira(jira_id="RHOAIENG-0000", run=False)` to the test.
69+
70+
71+
### Running containerized tests
72+
Save kubeconfig file to a local directory, for example: `$HOME/kubeconfig`
73+
To run tests in containerized environment:
74+
75+
```bash
76+
podman run -v $HOME:/mnt/host:Z -e KUBECONFIG=/mnt/host/kubeconfig quay.io/opendatahub/opendatahub-tests
77+
```

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ markers =
2020
modelmesh: Mark tests which are model mesh tests
2121
serverless: Mark tests which are serverless tests
2222
rawdeployment: Mark tests which are raw deployment tests
23+
minio: Mark tests which are using MinIO storage
2324

2425
addopts =
2526
-s

tests/conftest.py

Lines changed: 119 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
from typing import Any, Generator
77

88
import pytest
9+
import shortuuid
910
import yaml
1011
from _pytest.tmpdir import TempPathFactory
1112
from ocp_resources.config_map import ConfigMap
13+
from ocp_resources.pod import Pod
1214
from ocp_resources.secret import Secret
15+
from ocp_resources.service import Service
1316
from pyhelper_utils.shell import run_command
1417
from pytest import FixtureRequest, Config
1518
from kubernetes.dynamic import DynamicClient
@@ -21,14 +24,22 @@
2124
from simple_logger.logger import get_logger
2225

2326
from utilities.data_science_cluster_utils import update_components_in_dsc
27+
from utilities.general import get_s3_secret_dict
2428
from utilities.infra import (
2529
create_ns,
2630
get_dsci_applications_namespace,
2731
get_operator_distribution,
2832
login_with_user_password,
2933
get_openshift_token,
3034
)
31-
from utilities.constants import AcceleratorType, DscComponents
35+
from utilities.constants import (
36+
AcceleratorType,
37+
ApiGroups,
38+
DscComponents,
39+
Labels,
40+
MinIo,
41+
Protocols,
42+
)
3243
from utilities.infra import update_configmap_data
3344

3445

@@ -285,7 +296,9 @@ def updated_dsc_component_state(
285296

286297

287298
@pytest.fixture(scope="package")
288-
def enabled_modelmesh_in_dsc(dsc_resource: DataScienceCluster) -> Generator[DataScienceCluster, Any, Any]:
299+
def enabled_modelmesh_in_dsc(
300+
dsc_resource: DataScienceCluster,
301+
) -> Generator[DataScienceCluster, Any, Any]:
289302
with update_components_in_dsc(
290303
dsc=dsc_resource,
291304
components={DscComponents.MODELMESHSERVING: DscComponents.ManagementState.MANAGED},
@@ -305,7 +318,9 @@ def enabled_kserve_in_dsc(
305318

306319

307320
@pytest.fixture(scope="session")
308-
def cluster_monitoring_config(admin_client: DynamicClient) -> Generator[ConfigMap, Any, Any]:
321+
def cluster_monitoring_config(
322+
admin_client: DynamicClient,
323+
) -> Generator[ConfigMap, Any, Any]:
309324
data = {"config.yaml": yaml.dump({"enableUserWorkload": True})}
310325

311326
with update_configmap_data(
@@ -326,3 +341,104 @@ def unprivileged_model_namespace(
326341

327342
with create_ns(unprivileged_client=unprivileged_client, pytest_request=request) as ns:
328343
yield ns
344+
345+
346+
# MinIo
347+
@pytest.fixture(scope="class")
348+
def minio_namespace(admin_client: DynamicClient) -> Generator[Namespace, Any, Any]:
349+
with create_ns(
350+
name=f"{MinIo.Metadata.NAME}-{shortuuid.uuid().lower()}",
351+
admin_client=admin_client,
352+
) as ns:
353+
yield ns
354+
355+
356+
@pytest.fixture(scope="class")
357+
def minio_pod(
358+
request: FixtureRequest,
359+
admin_client: DynamicClient,
360+
minio_namespace: Namespace,
361+
) -> Generator[Pod, Any, Any]:
362+
pod_labels = {Labels.Openshift.APP: MinIo.Metadata.NAME}
363+
364+
if labels := request.param.get("labels"):
365+
pod_labels.update(labels)
366+
367+
with Pod(
368+
client=admin_client,
369+
name=MinIo.Metadata.NAME,
370+
namespace=minio_namespace.name,
371+
containers=[
372+
{
373+
"args": request.param.get("args"),
374+
"env": [
375+
{
376+
"name": MinIo.Credentials.ACCESS_KEY_NAME,
377+
"value": MinIo.Credentials.ACCESS_KEY_VALUE,
378+
},
379+
{
380+
"name": MinIo.Credentials.SECRET_KEY_NAME,
381+
"value": MinIo.Credentials.SECRET_KEY_VALUE,
382+
},
383+
],
384+
"image": request.param.get("image"),
385+
"name": MinIo.Metadata.NAME,
386+
}
387+
],
388+
label=pod_labels,
389+
annotations=request.param.get("annotations"),
390+
) as minio_pod:
391+
yield minio_pod
392+
393+
394+
@pytest.fixture(scope="class")
395+
def minio_service(admin_client: DynamicClient, minio_namespace: Namespace) -> Generator[Service, Any, Any]:
396+
with Service(
397+
client=admin_client,
398+
name=MinIo.Metadata.NAME,
399+
namespace=minio_namespace.name,
400+
ports=[
401+
{
402+
"name": f"{MinIo.Metadata.NAME}-client-port",
403+
"port": MinIo.Metadata.DEFAULT_PORT,
404+
"protocol": Protocols.TCP,
405+
"targetPort": MinIo.Metadata.DEFAULT_PORT,
406+
}
407+
],
408+
selector={
409+
Labels.Openshift.APP: MinIo.Metadata.NAME,
410+
},
411+
) as minio_service:
412+
yield minio_service
413+
414+
415+
@pytest.fixture(scope="class")
416+
def minio_data_connection(
417+
request: FixtureRequest,
418+
admin_client: DynamicClient,
419+
model_namespace: Namespace,
420+
minio_service: Service,
421+
) -> Generator[Secret, Any, Any]:
422+
data_dict = get_s3_secret_dict(
423+
aws_access_key=MinIo.Credentials.ACCESS_KEY_VALUE,
424+
aws_secret_access_key=MinIo.Credentials.SECRET_KEY_VALUE, # pragma: allowlist secret
425+
aws_s3_bucket=request.param["bucket"],
426+
aws_s3_endpoint=f"{Protocols.HTTP}://{minio_service.instance.spec.clusterIP}:{str(MinIo.Metadata.DEFAULT_PORT)}", # noqa: E501
427+
aws_s3_region="us-south",
428+
)
429+
430+
with Secret(
431+
client=admin_client,
432+
name="aws-connection-minio-data-connection",
433+
namespace=model_namespace.name,
434+
data_dict=data_dict,
435+
label={
436+
Labels.OpenDataHub.DASHBOARD: "true",
437+
Labels.OpenDataHubIo.MANAGED: "true",
438+
},
439+
annotations={
440+
f"{ApiGroups.OPENDATAHUB_IO}/connection-type": "s3",
441+
"openshift.io/display-name": "Minio Data Connection",
442+
},
443+
) as minio_secret:
444+
yield minio_secret

tests/model_explainability/conftest.py

Lines changed: 0 additions & 53 deletions
This file was deleted.

tests/model_explainability/constants.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)