test(e2e): cover model deletion removing it from the catalog (#34006)

This commit is contained in:
Yassin Kortam 2026-07-20 15:36:15 -07:00 • committed by GitHub
parent 9ac6cc7bee
commit 61b906f9b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 35 additions and 0 deletions

View file

@ -22,6 +22,7 @@ from models import (
KeyListResponse,
KeyRegenerateBody,
KeyUpdateBody,
ModelDeleteBody,
OrgDeleteBody,
OrgInfoParams,
OrgInfoResponse,
@ -99,6 +100,18 @@ class ManagementClient:
)
)
def delete_model_strict(self, model_id: str) -> None:
"""Strict delete for the act phase of a test: a failed delete is a hard
failure, unlike the warn-only ProxyClient.delete_model used at teardown."""
_ = unwrap(
self.proxy.transport.post(
"/model/delete",
headers=self.proxy.transport.master,
json=ModelDeleteBody(id=model_id),
response_type=NoBody,
)
)
def block_key(self, key: str) -> None:
_ = unwrap(
self.proxy.transport.post(

View file

@ -439,6 +439,28 @@ class TestModelRoutes:
"after /model/update",
)
@pytest.mark.covers("mgmt.model.delete.persists")
def test_delete_removes_from_model_info_catalog(
self, client: ManagementClient, resources: ResourceManager
) -> None:
"""The teardown's deferred delete fires again on the already-deleted model by
design: it is the safety net if this test fails before the in-body delete, and
a repeat /model/delete is a warn-only no-op the teardown absorbs."""
model_name = f"e2e-mgmt-model-{unique_marker()}"
model_id = client.proxy.create_model(model_name, LiteLLMParamsBody(model="openai/gpt-5.5", api_key="dummy"))
resources.defer(lambda: client.proxy.delete_model(model_id))
assert model_name in [entry.model_name for entry in client.proxy.model_info()], (
f"{model_name} absent from /model/info right after /model/new; cannot prove deletion removes it"
)
client.delete_model_strict(model_id)
def absent() -> bool | None:
return True if model_name not in [entry.model_name for entry in client.proxy.model_info()] else None
_ = _poll(client, absent, f"{model_name} still present in /model/info after /model/delete at the deadline")
@pytest.mark.covers("mgmt.model.add.persists")
def test_new_persists_to_model_info_catalog(
self, client: ManagementClient, resources: ResourceManager