diff --git a/roles/web-app-docs/files/python/infinito_docs/build_queue.py b/roles/web-app-docs/files/python/infinito_docs/build_queue.py index 8456c8ad5c..b5aae2311a 100644 --- a/roles/web-app-docs/files/python/infinito_docs/build_queue.py +++ b/roles/web-app-docs/files/python/infinito_docs/build_queue.py @@ -44,7 +44,10 @@ class Queue: lane.mkdir(parents=True, exist_ok=True) if background and (self.queue / marker).exists(): return - (lane / marker).touch(exist_ok=True) + queued = lane / marker + if queued.exists(): + return + queued.touch() def _dequeue(self, marker): """Drop ``marker`` from both lanes. diff --git a/tests/unit/python/roles/web-app-docs/files/infinito_docs/test_build_queue.py b/tests/unit/python/roles/web-app-docs/files/infinito_docs/test_build_queue.py index e72097a64c..79c3461ad5 100644 --- a/tests/unit/python/roles/web-app-docs/files/infinito_docs/test_build_queue.py +++ b/tests/unit/python/roles/web-app-docs/files/infinito_docs/test_build_queue.py @@ -109,6 +109,19 @@ class TestDrain(QueueFixture, unittest.TestCase): self.assertEqual(self.library.next_queued(), "latest:de") + def test_polling_does_not_send_the_awaited_build_to_the_back(self) -> None: + """The visitor polls every 30s, and each poll re-requests. Refreshing + the marker's mtime would make waiting for a build prevent it.""" + self.library._dequeue("latest") + self._serve("latest") + self._index("latest", ["de"]) + self.library.request("latest", "de") + self.library.request("v14.2.0") + + self.library.request("latest", "de") + + self.assertEqual(self.library.next_queued(), "latest:de") + def test_the_background_lane_is_drained_once_the_front_is_empty(self) -> None: self.library._dequeue("latest") self._serve("latest")