diff --git a/changelog.d/render-cancel-test-wait.md b/changelog.d/render-cancel-test-wait.md new file mode 100644 index 00000000000..1b92f0aa003 --- /dev/null +++ b/changelog.d/render-cancel-test-wait.md @@ -0,0 +1,9 @@ +### Fixed + +- **Render cancellation test waits longer and fails clearly.** + `test_local_backend_kills_the_container_on_cancellation` waited at most 10 s + for both fake theme containers and then cancelled anyway, so a loaded runner + could fail with a misleading "only one container killed" assertion. It now + waits up to 25 s and raises a clear timeout error when the containers never + start. Written by Google Jules; the race could not be reproduced locally. + (#12449) diff --git a/tests/unit/agents/runtime/test_render.py b/tests/unit/agents/runtime/test_render.py index b8ae25ec22f..f1257a38107 100644 --- a/tests/unit/agents/runtime/test_render.py +++ b/tests/unit/agents/runtime/test_render.py @@ -866,10 +866,15 @@ async def test_local_backend_kills_the_container_on_cancellation(self, tmp_path: task = asyncio.create_task(backend.render(job(job_id="cancelme"))) # Cancel once both theme containers run: a fixed sleep lost the race on a loaded CI runner. - for _ in range(200): + for _ in range(500): if started.exists() and len(started.read_text().split()) == 2: break await asyncio.sleep(0.05) + else: + # Do not leave the render task and its fake containers to event-loop teardown. + task.cancel() + await asyncio.gather(task, return_exceptions=True) + raise RuntimeError("Timed out waiting for containers to start") task.cancel() with pytest.raises(asyncio.CancelledError): await task