Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
43 changes: 33 additions & 10 deletions tests/model_registry/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def updated_dsc_component_state_scope_session(
resource_editor.update(backup_resources=True)
wait_for_dsc_status_ready(dsc_resource=dsc_resource)
# now delete the original namespace:
original_namespace = Namespace(name=original_namespace_name, wait_for_resource=True)
original_namespace = Namespace(client=admin_client, name=original_namespace_name, wait_for_resource=True)
original_namespace.delete(wait=True)
# Now enable it with the custom namespace
with ResourceEditor(
Expand All @@ -102,7 +102,9 @@ def updated_dsc_component_state_scope_session(
}
}
):
namespace = Namespace(name=py_config["model_registry_namespace"], wait_for_resource=True)
namespace = Namespace(
client=admin_client, name=py_config["model_registry_namespace"], wait_for_resource=True
)
namespace.wait_for_status(status=Namespace.Status.ACTIVE)
wait_for_pods_running(
admin_client=admin_client,
Expand Down Expand Up @@ -200,7 +202,7 @@ def api_server_url(admin_client: DynamicClient) -> str:

@pytest.fixture(scope="module")
def created_htpasswd_secret(
is_byoidc: bool, original_user: str, user_credentials_rbac: dict[str, str]
is_byoidc: bool, admin_client: DynamicClient, original_user: str, user_credentials_rbac: dict[str, str]
) -> Generator[UserTestSession | None, None, None]:
Comment thread
dbasunag marked this conversation as resolved.
"""
Session-scoped fixture that creates a test IDP user and cleans it up after all tests.
Expand All @@ -216,6 +218,7 @@ def created_htpasswd_secret(
try:
LOGGER.info(f"Creating secret {user_credentials_rbac['secret_name']} in openshift-config namespace")
with Secret(
client=admin_client,
name=user_credentials_rbac["secret_name"],
namespace="openshift-config",
htpasswd=htpasswd_b64,
Expand All @@ -236,7 +239,7 @@ def updated_oauth_config(
yield
else:
# Get current providers and add the new one
oauth = OAuth(name="cluster")
oauth = OAuth(client=admin_client, name="cluster")
identity_providers = oauth.instance.spec.identityProviders

new_idp = {
Expand Down Expand Up @@ -291,7 +294,9 @@ def model_registry_instance(
) -> Generator[list[Any], Any, Any]:
param = getattr(request, "param", {})
if pytestconfig.option.post_upgrade:
mr_instance = ModelRegistry(name=MR_INSTANCE_NAME, namespace=model_registry_namespace, ensure_exists=True)
mr_instance = ModelRegistry(
client=admin_client, name=MR_INSTANCE_NAME, namespace=model_registry_namespace, ensure_exists=True
)
yield [mr_instance]
mr_instance.delete(wait=True)
else:
Expand Down Expand Up @@ -333,15 +338,33 @@ def model_registry_metadata_db_resources(

if pytestconfig.option.post_upgrade:
resources = {
Secret: [Secret(name=DB_RESOURCE_NAME, namespace=model_registry_namespace, ensure_exists=True)],
Secret: [
Secret(
client=admin_client, name=DB_RESOURCE_NAME, namespace=model_registry_namespace, ensure_exists=True
)
],
PersistentVolumeClaim: [
PersistentVolumeClaim(name=DB_RESOURCE_NAME, namespace=model_registry_namespace, ensure_exists=True)
PersistentVolumeClaim(
client=admin_client, name=DB_RESOURCE_NAME, namespace=model_registry_namespace, ensure_exists=True
)
],
Service: [
Service(
client=admin_client, name=DB_RESOURCE_NAME, namespace=model_registry_namespace, ensure_exists=True
)
],
Service: [Service(name=DB_RESOURCE_NAME, namespace=model_registry_namespace, ensure_exists=True)],
ConfigMap: [ConfigMap(name=DB_RESOURCE_NAME, namespace=model_registry_namespace, ensure_exists=True)]
ConfigMap: [
ConfigMap(
client=admin_client, name=DB_RESOURCE_NAME, namespace=model_registry_namespace, ensure_exists=True
)
]
if db_backend == "mariadb"
else [],
Deployment: [Deployment(name=DB_RESOURCE_NAME, namespace=model_registry_namespace, ensure_exists=True)],
Deployment: [
Deployment(
client=admin_client, name=DB_RESOURCE_NAME, namespace=model_registry_namespace, ensure_exists=True
)
],
}
yield resources
for kind in [Deployment, ConfigMap, Service, PersistentVolumeClaim, Secret]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def test_model_registry_storage_version(self, admin_client: DynamicClient):
Steps:
After upgrade check if the storedVersion for CRD contains v1beta1
"""
mr_crd = CustomResourceDefinition(name="modelregistries.modelregistry.opendatahub.io")
mr_crd = CustomResourceDefinition(client=admin_client, name="modelregistries.modelregistry.opendatahub.io")
assert mr_crd.exists
expected_stored_version = "v1beta1"
stored_version = mr_crd.instance.status.storedVersions
Expand Down
9 changes: 6 additions & 3 deletions tests/model_registry/scc/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,20 @@ def skip_if_not_valid_check(request) -> None:


@pytest.fixture(scope="class")
def model_registry_scc_namespace(model_registry_namespace: str):
mr_annotations = Namespace(name=model_registry_namespace).instance.metadata.annotations
def model_registry_scc_namespace(admin_client: DynamicClient, model_registry_namespace: str):
mr_annotations = Namespace(client=admin_client, name=model_registry_namespace).instance.metadata.annotations
return {
"seLinuxOptions": mr_annotations.get("openshift.io/sa.scc.mcs"),
"uid-range": mr_annotations.get("openshift.io/sa.scc.uid-range"),
}


@pytest.fixture(scope="function")
def deployment_model_registry_ns(request: FixtureRequest, model_registry_namespace: str) -> Deployment:
def deployment_model_registry_ns(
request: FixtureRequest, admin_client: DynamicClient, model_registry_namespace: str
) -> Deployment:
return Deployment(
client=admin_client,
name=request.param.get("deployment_name", MR_INSTANCE_NAME),
namespace=model_registry_namespace,
ensure_exists=True,
Expand Down
2 changes: 1 addition & 1 deletion tests/model_registry/scc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def get_pod_by_deployment_name(admin_client: DynamicClient, namespace: str, depl
AssertionError: If exactly one pod is not found
"""
# First ensure the deployment exists
deployment = Deployment(name=deployment_name, namespace=namespace, ensure_exists=True)
deployment = Deployment(client=admin_client, name=deployment_name, namespace=namespace, ensure_exists=True)
deployment_instance = deployment.instance

# Get pods using the deployment's label selector
Expand Down