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
1 change: 0 additions & 1 deletion tests/model_registry/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ def model_registry_instance_rest_endpoint(admin_client: DynamicClient, model_reg
@pytest.fixture(scope="session")
def updated_dsc_component_state_scope_session(
pytestconfig: Config,
request: FixtureRequest,
admin_client: DynamicClient,
) -> Generator[DataScienceCluster, Any, Any]:
dsc_resource = get_data_science_cluster(client=admin_client)
Expand Down
4 changes: 2 additions & 2 deletions tests/model_registry/rbac/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,9 @@ def model_registry_instance_parametrized(
"""Create Model Registry instance parametrized"""
with ExitStack() as stack:
model_registry_instances = []
for param in request.param:
mr_instances = [stack.enter_context(ModelRegistry(**param)) for param in request.param]
for mr_instance in mr_instances:
# Common parameters for both ModelRegistry classes
Comment on lines +345 to 347
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add teardown=teardown_resources to ModelRegistry contexts to avoid leaks

Other parametrized fixtures pass teardown; missing it here may leave MR instances behind.

-        mr_instances = [stack.enter_context(ModelRegistry(**param)) for param in request.param]
+        mr_instances = [
+            stack.enter_context(ModelRegistry(**param, teardown=teardown_resources))
+            for param in request.param
+        ]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
mr_instances = [stack.enter_context(ModelRegistry(**param)) for param in request.param]
for mr_instance in mr_instances:
# Common parameters for both ModelRegistry classes
mr_instances = [
stack.enter_context(ModelRegistry(**param, teardown=teardown_resources))
for param in request.param
]
for mr_instance in mr_instances:
# Common parameters for both ModelRegistry classes
🤖 Prompt for AI Agents
In tests/model_registry/rbac/conftest.py around lines 345 to 347, the
ModelRegistry instances are created via
stack.enter_context(ModelRegistry(**param)) but omit the
teardown=teardown_resources argument which can leak resources; update the
context creation to pass teardown=teardown_resources to each ModelRegistry
invocation (e.g. stack.enter_context(ModelRegistry(...,
teardown=teardown_resources))) so the fixture tears down MR instances properly.

mr_instance = stack.enter_context(ModelRegistry(**param)) # noqa: FCN001
mr_instance.wait_for_condition(condition="Available", status="True")
mr_instance.wait_for_condition(condition="OAuthProxyAvailable", status="True")
model_registry_instances.append(mr_instance)
Expand Down
2 changes: 0 additions & 2 deletions tests/model_registry/rbac/multiple_instance_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
)

ns_name = py_config["model_registry_namespace"]
ns_params = {"ns_name": ns_name}

resource_names = [f"{DB_BASE_RESOURCES_NAME}{index}" for index in range(0, NUM_MR_INSTANCES)]

Expand Down Expand Up @@ -92,7 +91,6 @@
# Add this complete set of parameters as a pytest.param tuple to the list.
MR_MULTIPROJECT_TEST_SCENARIO_PARAMS = [
pytest.param(
ns_params, # updated_dsc_component_state_parametrized (expects dict)
db_secret_params,
db_pvc_params,
db_service_params,
Expand Down
1 change: 0 additions & 1 deletion tests/model_registry/rbac/test_mr_rbac.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ class TestUserMultiProjectPermission:

@pytest.mark.parametrize(
(
"updated_dsc_component_state_scope_session, "
"db_secret_parametrized, "
"db_pvc_parametrized, "
"db_service_parametrized, "
Expand Down
9 changes: 9 additions & 0 deletions tests/model_registry/rest_api/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ def patch_mysql_deployment_with_ssl_ca(

patch = {"spec": {"template": {"spec": {"volumes": volumes, "containers": [my_sql_container]}}}}
with ResourceEditor(patches={model_registry_db_deployments[0]: patch}):
wait_for_pods_running(
admin_client=admin_client, namespace_name=model_registry_namespace, number_of_consecutive_checks=3
)
model_registry_db_deployments[0].wait_for_condition(condition="Available", status="True")
yield model_registry_db_deployments[0]

Expand Down Expand Up @@ -323,6 +326,12 @@ def mysql_ssl_secrets(
"server_cert_secret": server_cert_secret,
"server_key_secret": server_key_secret,
}
if ca_secret.exists:
ca_secret.delete(wait=True)
if server_cert_secret.exists:
server_cert_secret.delete(wait=True)
if server_key_secret.exists:
server_key_secret.delete(wait=True)


@pytest.fixture(scope="function")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
LOGGER = get_logger(name=__name__)


@pytest.mark.usefixtures("updated_dsc_component_state_scope_session", "model_registry_instance")
class TestModelRegistryWithSecureDB:
"""
Test suite for validating Model Registry functionality with a secure MySQL database connection (SSL/TLS).
Expand Down Expand Up @@ -42,7 +41,6 @@ class TestModelRegistryWithSecureDB:
"patch_mysql_deployment_with_ssl_ca",
"patch_invalid_ca",
)
@pytest.mark.sanity
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove the sanity tag?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add it back.

def test_register_model_with_invalid_ca(
self: Self,
admin_client: DynamicClient,
Expand Down Expand Up @@ -88,7 +86,10 @@ def test_register_model_with_invalid_ca(
indirect=True,
)
@pytest.mark.usefixtures(
"deploy_secure_mysql_and_mr", "ca_configmap_for_test", "patch_mysql_deployment_with_ssl_ca"
"model_registry_metadata_db_resources",
"deploy_secure_mysql_and_mr",
"ca_configmap_for_test",
"patch_mysql_deployment_with_ssl_ca",
)
@pytest.mark.smoke
def test_register_model_with_valid_ca(
Expand Down