Skip to content

The agent that grows with you

test(gateway): a tick drained during a restart drain leaves the committed tick queued

Teknium1acaa91b848e
diff --git a/tests/gateway/test_local_producer_admission.py b/tests/gateway/test_local_producer_admission.py
index ffeecc82409..572d8696a85 100644
--- a/tests/gateway/test_local_producer_admission.py
+++ b/tests/gateway/test_local_producer_admission.py
@@ -301,6 +301,21 @@ async def test_a_refused_replacement_leaves_the_earlier_tick_queued_and_the_fold
assert len(_automation_rows(messaging)) == 2
+async def test_a_tick_drained_during_a_restart_drain_leaves_the_committed_tick_queued(messaging):
+ """A restart's drain refuses the replacement (``runtime_draining``): the committed tick the
+ next owner runs stays queued, never cancelled for a replacement held only in memory."""
+ tick = lambda seq: messaging.event('heartbeat', **_tick_fields('proc_job', seq))
+ assert await _drain_one(messaging.runner, tick(1)) == 0
+ messaging.runner._draining = True
+ try:
+ assert await _drain_one(messaging.runner, tick(2)) == 1, 'a refused tick is requeued'
+ finally:
+ messaging.runner._draining = False
+ assert {key: (row['status'], row['outcome']) for key, row in _automation_rows(messaging).items()} == {
+ '["heartbeat","proc_job","proc_job-tick-1"]': ('queued', None)}
+
+
@pytest.mark.asyncio
async def test_a_tick_whose_replaced_tick_starts_first_is_admitted_with_only_its_own_output(messaging, monkeypatch):
authority = messaging.authority