Skip to content

Commit eed8950

Browse files
authored
Merge branch 'main' into update_client_mr_2
2 parents a9549d2 + e8b1ede commit eed8950

4 files changed

Lines changed: 41 additions & 15 deletions

File tree

tests/model_registry/conftest.py

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def updated_dsc_component_state_scope_session(
8585
resource_editor.update(backup_resources=True)
8686
wait_for_dsc_status_ready(dsc_resource=dsc_resource)
8787
# now delete the original namespace:
88-
original_namespace = Namespace(name=original_namespace_name, wait_for_resource=True)
88+
original_namespace = Namespace(client=admin_client, name=original_namespace_name, wait_for_resource=True)
8989
original_namespace.delete(wait=True)
9090
# Now enable it with the custom namespace
9191
with ResourceEditor(
@@ -102,7 +102,9 @@ def updated_dsc_component_state_scope_session(
102102
}
103103
}
104104
):
105-
namespace = Namespace(name=py_config["model_registry_namespace"], wait_for_resource=True)
105+
namespace = Namespace(
106+
client=admin_client, name=py_config["model_registry_namespace"], wait_for_resource=True
107+
)
106108
namespace.wait_for_status(status=Namespace.Status.ACTIVE)
107109
wait_for_pods_running(
108110
admin_client=admin_client,
@@ -200,7 +202,7 @@ def api_server_url(admin_client: DynamicClient) -> str:
200202

201203
@pytest.fixture(scope="module")
202204
def created_htpasswd_secret(
203-
is_byoidc: bool, original_user: str, user_credentials_rbac: dict[str, str]
205+
is_byoidc: bool, admin_client: DynamicClient, original_user: str, user_credentials_rbac: dict[str, str]
204206
) -> Generator[UserTestSession | None, None, None]:
205207
"""
206208
Session-scoped fixture that creates a test IDP user and cleans it up after all tests.
@@ -216,6 +218,7 @@ def created_htpasswd_secret(
216218
try:
217219
LOGGER.info(f"Creating secret {user_credentials_rbac['secret_name']} in openshift-config namespace")
218220
with Secret(
221+
client=admin_client,
219222
name=user_credentials_rbac["secret_name"],
220223
namespace="openshift-config",
221224
htpasswd=htpasswd_b64,
@@ -236,7 +239,7 @@ def updated_oauth_config(
236239
yield
237240
else:
238241
# Get current providers and add the new one
239-
oauth = OAuth(name="cluster")
242+
oauth = OAuth(client=admin_client, name="cluster")
240243
identity_providers = oauth.instance.spec.identityProviders
241244

242245
new_idp = {
@@ -291,7 +294,9 @@ def model_registry_instance(
291294
) -> Generator[list[Any], Any, Any]:
292295
param = getattr(request, "param", {})
293296
if pytestconfig.option.post_upgrade:
294-
mr_instance = ModelRegistry(name=MR_INSTANCE_NAME, namespace=model_registry_namespace, ensure_exists=True)
297+
mr_instance = ModelRegistry(
298+
client=admin_client, name=MR_INSTANCE_NAME, namespace=model_registry_namespace, ensure_exists=True
299+
)
295300
yield [mr_instance]
296301
mr_instance.delete(wait=True)
297302
else:
@@ -333,15 +338,33 @@ def model_registry_metadata_db_resources(
333338

334339
if pytestconfig.option.post_upgrade:
335340
resources = {
336-
Secret: [Secret(name=DB_RESOURCE_NAME, namespace=model_registry_namespace, ensure_exists=True)],
341+
Secret: [
342+
Secret(
343+
client=admin_client, name=DB_RESOURCE_NAME, namespace=model_registry_namespace, ensure_exists=True
344+
)
345+
],
337346
PersistentVolumeClaim: [
338-
PersistentVolumeClaim(name=DB_RESOURCE_NAME, namespace=model_registry_namespace, ensure_exists=True)
347+
PersistentVolumeClaim(
348+
client=admin_client, name=DB_RESOURCE_NAME, namespace=model_registry_namespace, ensure_exists=True
349+
)
350+
],
351+
Service: [
352+
Service(
353+
client=admin_client, name=DB_RESOURCE_NAME, namespace=model_registry_namespace, ensure_exists=True
354+
)
339355
],
340-
Service: [Service(name=DB_RESOURCE_NAME, namespace=model_registry_namespace, ensure_exists=True)],
341-
ConfigMap: [ConfigMap(name=DB_RESOURCE_NAME, namespace=model_registry_namespace, ensure_exists=True)]
356+
ConfigMap: [
357+
ConfigMap(
358+
client=admin_client, name=DB_RESOURCE_NAME, namespace=model_registry_namespace, ensure_exists=True
359+
)
360+
]
342361
if db_backend == "mariadb"
343362
else [],
344-
Deployment: [Deployment(name=DB_RESOURCE_NAME, namespace=model_registry_namespace, ensure_exists=True)],
363+
Deployment: [
364+
Deployment(
365+
client=admin_client, name=DB_RESOURCE_NAME, namespace=model_registry_namespace, ensure_exists=True
366+
)
367+
],
345368
}
346369
yield resources
347370
for kind in [Deployment, ConfigMap, Service, PersistentVolumeClaim, Secret]:

tests/model_registry/model_registry/upgrade/test_model_registry_upgrade.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def test_model_registry_storage_version(self, admin_client: DynamicClient):
109109
Steps:
110110
After upgrade check if the storedVersion for CRD contains v1beta1
111111
"""
112-
mr_crd = CustomResourceDefinition(name="modelregistries.modelregistry.opendatahub.io")
112+
mr_crd = CustomResourceDefinition(client=admin_client, name="modelregistries.modelregistry.opendatahub.io")
113113
assert mr_crd.exists
114114
expected_stored_version = "v1beta1"
115115
stored_version = mr_crd.instance.status.storedVersions

tests/model_registry/scc/conftest.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,20 @@ def skip_if_not_valid_check(request) -> None:
3232

3333

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

4242

4343
@pytest.fixture(scope="function")
44-
def deployment_model_registry_ns(request: FixtureRequest, model_registry_namespace: str) -> Deployment:
44+
def deployment_model_registry_ns(
45+
request: FixtureRequest, admin_client: DynamicClient, model_registry_namespace: str
46+
) -> Deployment:
4547
return Deployment(
48+
client=admin_client,
4649
name=request.param.get("deployment_name", MR_INSTANCE_NAME),
4750
namespace=model_registry_namespace,
4851
ensure_exists=True,

tests/model_registry/scc/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def get_pod_by_deployment_name(admin_client: DynamicClient, namespace: str, depl
9090
AssertionError: If exactly one pod is not found
9191
"""
9292
# First ensure the deployment exists
93-
deployment = Deployment(name=deployment_name, namespace=namespace, ensure_exists=True)
93+
deployment = Deployment(client=admin_client, name=deployment_name, namespace=namespace, ensure_exists=True)
9494
deployment_instance = deployment.instance
9595

9696
# Get pods using the deployment's label selector

0 commit comments

Comments
 (0)