diff --git a/tests/model_registry/conftest.py b/tests/model_registry/conftest.py index 4f6304ae5..8f5d479e1 100644 --- a/tests/model_registry/conftest.py +++ b/tests/model_registry/conftest.py @@ -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( @@ -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, @@ -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]: """ Session-scoped fixture that creates a test IDP user and cleans it up after all tests. @@ -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, @@ -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 = { @@ -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: @@ -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]: diff --git a/tests/model_registry/model_registry/upgrade/test_model_registry_upgrade.py b/tests/model_registry/model_registry/upgrade/test_model_registry_upgrade.py index d7e8ef80d..b4c04259f 100644 --- a/tests/model_registry/model_registry/upgrade/test_model_registry_upgrade.py +++ b/tests/model_registry/model_registry/upgrade/test_model_registry_upgrade.py @@ -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 diff --git a/tests/model_registry/scc/conftest.py b/tests/model_registry/scc/conftest.py index b464b6166..d6f71584c 100644 --- a/tests/model_registry/scc/conftest.py +++ b/tests/model_registry/scc/conftest.py @@ -32,8 +32,8 @@ 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"), @@ -41,8 +41,11 @@ def model_registry_scc_namespace(model_registry_namespace: str): @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, diff --git a/tests/model_registry/scc/utils.py b/tests/model_registry/scc/utils.py index 23fa6d3f4..89d3793d5 100644 --- a/tests/model_registry/scc/utils.py +++ b/tests/model_registry/scc/utils.py @@ -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