Skip to content
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,3 +782,10 @@ def gpu_count_on_cluster(nodes: list[Any]) -> int:
LOGGER.debug(f"Skipping non-integer allocatable for {key} on {node.name}: {val!r}")
continue
return total_gpus


@pytest.fixture(scope="session")
def original_user() -> str:
current_user = run_command(command=["oc", "whoami"])[1].strip()
Comment thread
mwaykole marked this conversation as resolved.
LOGGER.info(f"Original user: {current_user}")
return current_user
10 changes: 2 additions & 8 deletions tests/model_registry/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@
from pytest_testconfig import config as py_config
from model_registry.types import RegisteredModel

from tests.model_registry.rbac.utils import wait_for_oauth_openshift_deployment
from utilities.general import wait_for_oauth_openshift_deployment
from tests.model_registry.utils import (
generate_namespace_name,
get_rest_headers,
wait_for_default_resource_cleanedup,
get_byoidc_user_credentials,
)
Comment thread
SB159 marked this conversation as resolved.

from utilities.general import generate_random_name, wait_for_pods_running

from tests.model_registry.constants import (
Expand Down Expand Up @@ -541,13 +542,6 @@ def api_server_url(admin_client: DynamicClient) -> str:
return infrastructure.instance.status.apiServerURL


@pytest.fixture(scope="session")
def original_user() -> str:
current_user = run_command(command=["oc", "whoami"])[1].strip()
LOGGER.info(f"Original user: {current_user}")
return current_user


@pytest.fixture(scope="module")
def created_htpasswd_secret(
is_byoidc: bool, original_user: str, user_credentials_rbac: dict[str, str]
Expand Down
25 changes: 0 additions & 25 deletions tests/model_registry/rbac/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
from typing import Any, Dict, Generator, List

from kubernetes.dynamic import DynamicClient
from timeout_sampler import TimeoutSampler

from ocp_resources.deployment import Deployment
from ocp_resources.role import Role
from ocp_resources.role_binding import RoleBinding
from utilities.constants import Protocols
Expand Down Expand Up @@ -68,27 +64,6 @@ def assert_positive_mr_registry(
LOGGER.info("Client instantiated successfully after granting permissions.")


def wait_for_oauth_openshift_deployment() -> None:
deployment_obj = Deployment(name="oauth-openshift", namespace="openshift-authentication", ensure_exists=True)

_log = f"Wait for {deployment_obj.name} -> Type: Progressing -> Reason:"

def _wait_sampler(_reason: str) -> None:
sampler = TimeoutSampler(
wait_timeout=240,
sleep=5,
func=lambda: deployment_obj.instance.status.conditions,
)
for sample in sampler:
for _spl in sample:
if _spl.type == "Progressing" and _spl.reason == _reason:
return

for reason in ("ReplicaSetUpdated", "NewReplicaSetAvailable"):
LOGGER.info(f"{_log} {reason}")
_wait_sampler(_reason=reason)


def create_role_binding(
admin_client: DynamicClient,
model_registry_namespace: str,
Expand Down
Loading