test(cleanup_sweeper): assert provider.terminate called for dead-daemon sessions

Greptile P1 regression coverage: dead-daemon sweep must route through
_terminate_session_internal so provider.terminate gets called. Without
this assertion the regression silently returned (NoopVMProvider would
still mark rows correctly via update_many).
This commit is contained in:
Ishaan Jaffer 2026-05-06 15:51:58 -07:00
parent a0015e8564
commit 79642036e6
No known key found for this signature in database

View file

@ -65,6 +65,7 @@ async def test_sweeper_marks_dead_daemon_sessions_error(
headers={"Authorization": "Bearer k"},
json={"agent_id": a["id"], "repos": []},
).json()
sid = sess["id"]
row = fake_prisma_client.db.litellm_agentsession.rows[0]
row.status = SESSION_STATUS_READY
@ -75,6 +76,13 @@ async def test_sweeper_marks_dead_daemon_sessions_error(
summary = await run_cleanup_pass(fake_prisma_client)
assert summary["dead_daemon_sessions"] == 1
assert row.status == SESSION_STATUS_ERROR
# Greptile P1: dead-daemon sweep MUST go through
# ``_terminate_session_internal`` so the VM provider is notified.
# Otherwise EC2 instances orphan once a real provider replaces
# ``NoopVMProvider``.
assert any(
c["session_id"] == sid for c in noop_provider.terminate_calls
), "provider.terminate was never called for the dead-daemon session"
@pytest.mark.asyncio