test(agent): guard maintenance transitions separately
This commit is contained in:
1 parent
215f0754e2
commit
8075397a01
1 file changed
+16
-13
@@ -103,22 +103,25 @@ async def test_direct_turn_including_final_notification_stays_busy(agent, cancel
|
|||||||
agent.runtime_event_publisher.run_status_changed = notify
|
agent.runtime_event_publisher.run_status_changed = notify
|
||||||
task = asyncio.create_task(agent.process_direct("work"))
|
task = asyncio.create_task(agent.process_direct("work"))
|
||||||
try:
|
try:
|
||||||
|
# Guard each transition, not the total duration of startup and storage.
|
||||||
async with asyncio.timeout(3):
|
async with asyncio.timeout(3):
|
||||||
await entered.wait()
|
await entered.wait()
|
||||||
with pytest.raises(RuntimeBusyError):
|
with pytest.raises(RuntimeBusyError):
|
||||||
with agent.maintenance():
|
with agent.maintenance():
|
||||||
pytest.fail("active direct turn was missed")
|
pytest.fail("active direct turn was missed")
|
||||||
assert not agent.bus.admission.paused
|
assert not agent.bus.admission.paused
|
||||||
assert not task.done()
|
assert not task.done()
|
||||||
if cancel:
|
if cancel:
|
||||||
task.cancel()
|
task.cancel()
|
||||||
else:
|
else:
|
||||||
release.set()
|
release.set()
|
||||||
|
async with asyncio.timeout(3):
|
||||||
await notifying.wait()
|
await notifying.wait()
|
||||||
with pytest.raises(RuntimeBusyError):
|
with pytest.raises(RuntimeBusyError):
|
||||||
with agent.maintenance():
|
with agent.maintenance():
|
||||||
pytest.fail("final notification was missed")
|
pytest.fail("final notification was missed")
|
||||||
notified.set()
|
notified.set()
|
||||||
|
async with asyncio.timeout(3):
|
||||||
if cancel:
|
if cancel:
|
||||||
with pytest.raises(asyncio.CancelledError):
|
with pytest.raises(asyncio.CancelledError):
|
||||||
await task
|
await task
|
||||||
|
|||||||
Reference in new issue
Block a user