Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ By default, cluster sanity checks are run to make cluster ready for tests.
To skip cluster sanity checks, pass `--cluster-sanity-skip-check` to skip all tests.
To skip RHOAI/ODH-related tests (for example when running in upstream), pass `--cluster-sanity-skip-rhoai-check`.

### Running tests with admin client instead of unprivileged client
To run tests with admin client only, pass `--tc=use_unprivileged_client:False` to pytest.


### jira integration
To skip running tests which have open bugs, [pytest_jira](https://github.com/rhevm-qe-automation/pytest_jira) plugin is used.
To run tests with jira integration, you need to set `PYTEST_JIRA_URL` and `PYTEST_JIRA_TOKEN` environment variables.
Expand Down
38 changes: 12 additions & 26 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

from utilities.data_science_cluster_utils import update_components_in_dsc
from utilities.exceptions import ClusterLoginError
from utilities.general import get_s3_secret_dict
from utilities.infra import (
verify_cluster_sanity,
create_ns,
Expand All @@ -35,14 +34,13 @@
)
from utilities.constants import (
AcceleratorType,
ApiGroups,
DscComponents,
Labels,
MinIo,
Protocols,
)
from utilities.infra import update_configmap_data

from utilities.minio import create_minio_data_connection_secret

LOGGER = get_logger(name=__name__)

Expand Down Expand Up @@ -111,7 +109,7 @@ def model_namespace(
ns.clean_up()
else:
with create_ns(
admin_client=admin_client,
client=admin_client,
pytest_request=request,
teardown=teardown_resources,
) as ns:
Expand Down Expand Up @@ -275,6 +273,10 @@ def unprivileged_client(
"""
Provides none privileged API client. If non_admin_user_password is None, then it will raise.
"""
if not py_config.get("use_unprivileged_client"):
LOGGER.warning("Unprivileged client is not enabled, using admin client")
yield admin_client

if non_admin_user_password is None:
raise ValueError("Unprivileged user not provisioned")

Expand Down Expand Up @@ -380,7 +382,7 @@ def unprivileged_model_namespace(
def minio_namespace(admin_client: DynamicClient) -> Generator[Namespace, Any, Any]:
with create_ns(
name=f"{MinIo.Metadata.NAME}-{shortuuid.uuid().lower()}",
admin_client=admin_client,
client=admin_client,
) as ns:
yield ns

Expand Down Expand Up @@ -451,29 +453,13 @@ def minio_data_connection(
model_namespace: Namespace,
minio_service: Service,
) -> Generator[Secret, Any, Any]:
data_dict = get_s3_secret_dict(
aws_access_key=MinIo.Credentials.ACCESS_KEY_VALUE,
aws_secret_access_key=MinIo.Credentials.SECRET_KEY_VALUE, # pragma: allowlist secret
with create_minio_data_connection_secret(
minio_service=minio_service,
model_namespace=model_namespace.name,
aws_s3_bucket=request.param["bucket"],
aws_s3_endpoint=f"{Protocols.HTTP}://{minio_service.instance.spec.clusterIP}:{str(MinIo.Metadata.DEFAULT_PORT)}", # noqa: E501
aws_s3_region="us-south",
)

with Secret(
client=admin_client,
name="aws-connection-minio-data-connection",
namespace=model_namespace.name,
data_dict=data_dict,
label={
Labels.OpenDataHub.DASHBOARD: "true",
Labels.OpenDataHubIo.MANAGED: "true",
},
annotations={
f"{ApiGroups.OPENDATAHUB_IO}/connection-type": "s3",
"openshift.io/display-name": "Minio Data Connection",
},
) as minio_secret:
yield minio_secret
) as secret:
yield secret


@pytest.fixture(scope="session")
Expand Down
2 changes: 2 additions & 0 deletions tests/global_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
dsc_name: str = "default-dsc"
dsci_name: str = "default-dsci"

use_unprivileged_client: bool = True

for _dir in dir():
val = locals()[_dir]
if type(val) not in [bool, list, dict, str, int]:
Expand Down
2 changes: 1 addition & 1 deletion tests/model_registry/negative_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def model_registry_namespace_for_negative_tests(
) -> Generator[Namespace, Any, Any]:
with create_ns(
name=request.param.get("namespace_name", CUSTOM_NEGATIVE_NS),
admin_client=admin_client,
client=admin_client,
) as ns:
yield ns

Expand Down
Loading