Skip to content

Commit 4c8b808

Browse files
SB159dbasunag
andauthored
tests(maas-billing): add user creation for tests (#843)
* User creation for e2e test * Addressed review comments * Updated utils * Updated helpers * Address review comments for MaaS RBAC tests * maas-billing: updated user creation process * maas-billing: updated conftest * maas-billing: refactor RBAC fixtures * maas-billing: address review comment remaining) * maas-billing: address review comments --------- Co-authored-by: Debarati Basu-Nag <dbasunag@redhat.com>
1 parent bb234f7 commit 4c8b808

File tree

7 files changed

+558
-49
lines changed

7 files changed

+558
-49
lines changed

tests/conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,3 +782,10 @@ def gpu_count_on_cluster(nodes: list[Any]) -> int:
782782
LOGGER.debug(f"Skipping non-integer allocatable for {key} on {node.name}: {val!r}")
783783
continue
784784
return total_gpus
785+
786+
787+
@pytest.fixture(scope="session")
788+
def original_user() -> str:
789+
current_user = run_command(command=["oc", "whoami"])[1].strip()
790+
LOGGER.info(f"Original user: {current_user}")
791+
return current_user

tests/model_registry/conftest.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@
3434
from pytest_testconfig import config as py_config
3535
from model_registry.types import RegisteredModel
3636

37-
from tests.model_registry.rbac.utils import wait_for_oauth_openshift_deployment
37+
from utilities.general import wait_for_oauth_openshift_deployment
3838
from tests.model_registry.utils import (
3939
generate_namespace_name,
4040
get_rest_headers,
4141
wait_for_default_resource_cleanedup,
4242
get_byoidc_user_credentials,
4343
)
44+
4445
from utilities.general import generate_random_name, wait_for_pods_running
4546

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

543544

544-
@pytest.fixture(scope="session")
545-
def original_user() -> str:
546-
current_user = run_command(command=["oc", "whoami"])[1].strip()
547-
LOGGER.info(f"Original user: {current_user}")
548-
return current_user
549-
550-
551545
@pytest.fixture(scope="module")
552546
def created_htpasswd_secret(
553547
is_byoidc: bool, original_user: str, user_credentials_rbac: dict[str, str]

tests/model_registry/rbac/utils.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
from typing import Any, Dict, Generator, List
2-
32
from kubernetes.dynamic import DynamicClient
4-
from timeout_sampler import TimeoutSampler
5-
6-
from ocp_resources.deployment import Deployment
73
from ocp_resources.role import Role
84
from ocp_resources.role_binding import RoleBinding
95
from utilities.constants import Protocols
@@ -68,27 +64,6 @@ def assert_positive_mr_registry(
6864
LOGGER.info("Client instantiated successfully after granting permissions.")
6965

7066

71-
def wait_for_oauth_openshift_deployment() -> None:
72-
deployment_obj = Deployment(name="oauth-openshift", namespace="openshift-authentication", ensure_exists=True)
73-
74-
_log = f"Wait for {deployment_obj.name} -> Type: Progressing -> Reason:"
75-
76-
def _wait_sampler(_reason: str) -> None:
77-
sampler = TimeoutSampler(
78-
wait_timeout=240,
79-
sleep=5,
80-
func=lambda: deployment_obj.instance.status.conditions,
81-
)
82-
for sample in sampler:
83-
for _spl in sample:
84-
if _spl.type == "Progressing" and _spl.reason == _reason:
85-
return
86-
87-
for reason in ("ReplicaSetUpdated", "NewReplicaSetAvailable"):
88-
LOGGER.info(f"{_log} {reason}")
89-
_wait_sampler(_reason=reason)
90-
91-
9267
def create_role_binding(
9368
admin_client: DynamicClient,
9469
model_registry_namespace: str,

0 commit comments

Comments
 (0)