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
2 changes: 1 addition & 1 deletion tests/model_registry/model_catalog/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def enabled_model_catalog_config_map(
admin_client: DynamicClient,
model_registry_namespace: str,
current_client_token: str,
) -> ConfigMap:
) -> Generator[ConfigMap, None, None]:
"""
Enable all catalogs in the default model catalog configmap
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def model_registry_db_deployment_negative_test(
model_registry_db_service_for_negative_tests: Service,
) -> Generator[Deployment, Any, Any]:
with Deployment(
client=admin_client,
name=DB_RESOURCES_NAME_NEGATIVE,
namespace=model_registry_namespace_for_negative_tests.name,
annotations={
Expand Down Expand Up @@ -168,9 +169,9 @@ def model_registry_db_instance_pod(admin_client: DynamicClient) -> Generator[Pod


@pytest.fixture()
def delete_mr_deployment() -> None:
def delete_mr_deployment(admin_client: DynamicClient) -> None:
"""Delete the model registry deployment"""
mr_deployment = Deployment(
name=MR_INSTANCE_NAME, namespace=py_config["model_registry_namespace"], ensure_exists=True
client=admin_client, name=MR_INSTANCE_NAME, namespace=py_config["model_registry_namespace"], ensure_exists=True
)
mr_deployment.delete(wait=True)
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
DB_RESOURCE_NAME,
)
from kubernetes.dynamic.exceptions import ForbiddenError
from kubernetes.dynamic import DynamicClient


LOGGER = get_logger(name=__name__)
Expand All @@ -30,6 +31,7 @@ class TestModelRegistryCreationNegative:
@pytest.mark.sanity
def test_registering_model_negative(
self: Self,
admin_client: DynamicClient,
current_client_token: str,
model_registry_namespace_for_negative_tests: Namespace,
updated_dsc_component_state_scope_session: DataScienceCluster,
Expand All @@ -50,6 +52,7 @@ def test_registering_model_negative(
match=f"namespace must be {py_config['model_registry_namespace']}",
):
with ModelRegistry(
client=admin_client,
name=MR_INSTANCE_NAME,
namespace=model_registry_namespace_for_negative_tests.name,
label={
Expand Down
18 changes: 13 additions & 5 deletions tests/model_registry/model_registry/rbac/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,16 @@ def created_role_binding_user(
# RESOURCE FIXTURES PARMETRIZED
# =============================================================================
@pytest.fixture(scope="class")
def db_secret_parametrized(request: FixtureRequest, teardown_resources: bool) -> Generator[List[Secret], Any, Any]:
def db_secret_parametrized(
request: FixtureRequest, admin_client: DynamicClient, teardown_resources: bool
) -> Generator[List[Secret], Any, Any]:
"""Create DB Secret parametrized"""
with ExitStack() as stack:
secrets = [
stack.enter_context(
Secret(
**param,
client=admin_client,
teardown=teardown_resources,
)
)
Expand All @@ -156,14 +159,15 @@ def db_secret_parametrized(request: FixtureRequest, teardown_resources: bool) ->

@pytest.fixture(scope="class")
def db_pvc_parametrized(
request: FixtureRequest, teardown_resources: bool
request: FixtureRequest, admin_client: DynamicClient, teardown_resources: bool
) -> Generator[List[PersistentVolumeClaim], Any, Any]:
"""Create DB PVC parametrized"""
with ExitStack() as stack:
pvc = [
stack.enter_context(
PersistentVolumeClaim(
**param,
client=admin_client,
teardown=teardown_resources,
)
)
Expand All @@ -173,13 +177,16 @@ def db_pvc_parametrized(


@pytest.fixture(scope="class")
def db_service_parametrized(request: FixtureRequest, teardown_resources: bool) -> Generator[List[Service], Any, Any]:
def db_service_parametrized(
request: FixtureRequest, admin_client: DynamicClient, teardown_resources: bool
) -> Generator[List[Service], Any, Any]:
"""Create DB Service parametrized"""
with ExitStack() as stack:
services = [
stack.enter_context(
Service(
**param,
client=admin_client,
teardown=teardown_resources,
)
)
Expand All @@ -190,14 +197,15 @@ def db_service_parametrized(request: FixtureRequest, teardown_resources: bool) -

@pytest.fixture(scope="class")
def db_deployment_parametrized(
request: FixtureRequest, teardown_resources: bool
request: FixtureRequest, admin_client: DynamicClient, teardown_resources: bool
) -> Generator[List[Deployment], Any, Any]:
"""Create DB Deployment parametrized"""
with ExitStack() as stack:
deployments = [
stack.enter_context(
Deployment(
**param,
client=admin_client,
teardown=teardown_resources,
)
)
Expand All @@ -217,7 +225,7 @@ def model_registry_instance_parametrized(
"""Create Model Registry instance parametrized"""
with ExitStack() as stack:
model_registry_instances = []
mr_instances = [stack.enter_context(ModelRegistry(**param)) for param in request.param]
mr_instances = [stack.enter_context(ModelRegistry(**param, client=admin_client)) for param in request.param]
for mr_instance in mr_instances:
# Common parameters for both ModelRegistry classes
mr_instance.wait_for_condition(condition="Available", status="True")
Expand Down
8 changes: 6 additions & 2 deletions tests/model_registry/model_registry/rest_api/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def deploy_secure_mysql_and_mr(
if "sslRootCertificateConfigMap" in param:
mysql["sslRootCertificateConfigMap"] = param["sslRootCertificateConfigMap"]
with ModelRegistry(
client=admin_client,
name=SECURE_MR_NAME,
namespace=model_registry_namespace,
label=get_mr_standard_labels(resource_name=SECURE_MR_NAME),
Expand Down Expand Up @@ -361,12 +362,15 @@ def skip_if_not_default_db(request):

@pytest.fixture()
def model_registry_default_postgres_deployment_match_label(
model_registry_namespace: str, model_registry_instance: list[ModelRegistry]
model_registry_namespace: str, admin_client: DynamicClient, model_registry_instance: list[ModelRegistry]
) -> dict[str, str]:
"""
Returns the matchLabels from the default postgres deployment for filtering pods.
"""
deployment = Deployment(
namespace=model_registry_namespace, name=f"{model_registry_instance[0].name}-postgres", ensure_exists=True
client=admin_client,
namespace=model_registry_namespace,
name=f"{model_registry_instance[0].name}-postgres",
ensure_exists=True,
)
return deployment.instance.spec.selector.matchLabels
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,11 @@ def test_default_postgres_db_pod_log(

def test_model_registry_validate_api_version(
self: Self,
model_registry_instance,
admin_client: DynamicClient,
model_registry_instance: list[ModelRegistry],
):
api_version = ModelRegistry(
client=admin_client,
name=model_registry_instance[0].name,
namespace=model_registry_instance[0].namespace,
ensure_exists=True,
Expand All @@ -181,7 +183,7 @@ def test_model_registry_validate_api_version(

def test_model_registry_validate_kuberbacproxy_enabled(
self: Self,
model_registry_instance,
model_registry_instance: list[ModelRegistry],
):
model_registry_instance_spec = model_registry_instance[0].instance.spec
LOGGER.info(f"Validating that MR is using kubeRBAC proxy {model_registry_instance_spec}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,17 @@
class TestModelRegistryMultipleInstances:
@pytest.mark.smoke
def test_validate_multiple_model_registry(
self: Self, model_registry_instance: list[ModelRegistry], model_registry_namespace: str
self: Self,
admin_client: DynamicClient,
model_registry_instance: list[ModelRegistry],
model_registry_namespace: str,
):
for num in range(0, NUM_RESOURCES["num_resources"]):
mr = ModelRegistry(
name=f"{MR_INSTANCE_BASE_NAME}{num}", namespace=model_registry_namespace, ensure_exists=True
client=admin_client,
name=f"{MR_INSTANCE_BASE_NAME}{num}",
namespace=model_registry_namespace,
ensure_exists=True,
)
LOGGER.info(f"{mr.name} found")

Expand Down