From ff89a02067c24671fea03d70e842eefddae8dcff Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 1 Oct 2026 11:32:08 +0200 Subject: [PATCH] fix(web-app-docs): take the builds nobody waits for off the awaited path On a cold container the docs Playwright suite triggers four serial Sphinx builds and waits for the last one. test-languages.js polls /deployed/de/ for 200 and got 202 for 55.6 minutes in job 110003713825 of run 36745666606, after which the suite budget expired and five further specs never ran. The suite has never passed on a first attempt; it used to go green only on the harness retry, which 7127c6b96b removed for budget timeouts, so a structural overrun became a red job. Measured cost per build, from run 36558500327 where the whole queue drained on a kept stack: container up 12:15:52, the spec green at 13:21:41 answering on its first poll, next container start only at 13:30:45. Four builds in 65 minutes 49 seconds, so at most 16.5 minutes each - not the sixty to ninety minutes 40688e4ded estimated. Three of the four builds were none of the test's business. fetch() queued latest in the foreground although nothing waits on it at startup, and _refresh_stale_sites did the same for every servable version; both now use the background lane, which is what its own docstring describes. test-front-page.js reached GET /latest/, and reaching an unbuilt version queues its build - it now asserts the redirect from the Location header without following it, and checks the same page shape against /deployed/, which is built anyway. The release tag that test-on-demand-build.js clicks stays, and now runs behind the awaited work instead of in front of it. The translation could only be queued after its base finished, because the 202 branch returns before _translation is reachable, so it always sorted behind whatever the sibling specs had queued meanwhile. The 202 branch now carries the language segment along, admitted by translatable(), which answers from the snapshot catalog on disk before any build; build_language still re-checks the written index. Moving a version into the background lane exposed that status() read only the foreground one, so a waiting version would have been reported as missing rather than queued to the versions overview and to /api/versions. is_queued() now covers both lanes, mirroring _dequeue, which always removed from both. Two of the five unit failures this change first produced disappeared on that fix alone, which is what shows they pinned real behaviour; the three that pinned the lane itself were rewritten to assert the behaviour instead. Co-Authored-By: Claude Opus 5 (1M context) --- .../files/playwright/test-front-page.js | 26 ++++++++++++------- .../files/python/infinito_docs/build_queue.py | 17 +++++++++--- .../files/python/infinito_docs/library.py | 25 +++++++++++++++--- .../files/python/infinito_docs/server.py | 2 ++ .../files/infinito_docs/test_build_queue.py | 6 +++-- .../files/infinito_docs/test_library.py | 3 ++- 6 files changed, 60 insertions(+), 19 deletions(-) diff --git a/roles/web-app-docs/files/playwright/test-front-page.js b/roles/web-app-docs/files/playwright/test-front-page.js index 0db4636e0d..7317b915e6 100644 --- a/roles/web-app-docs/files/playwright/test-front-page.js +++ b/roles/web-app-docs/files/playwright/test-front-page.js @@ -1,27 +1,33 @@ const { test, expect } = require("@playwright/test"); const { resolveTimeout } = require("./timeouts"); -const { expectHstsWhenTls, gotoOnion } = require("./personas"); +const { expectHstsWhenTls } = require("./personas"); exports.register = function (shared) { - test("docs front page opens the latest commit under canonical domain with TLS", async ({ page }) => { - const response = await gotoOnion(page, `${shared.appBaseUrl}/`); - expect(response, "Expected docs response").toBeTruthy(); - expect(response.status(), "Expected docs front page status < 400").toBeLessThan(400); + test("docs front page opens the latest commit under canonical domain with TLS", async ({ request }) => { + const response = await request.get(`${shared.appBaseUrl}/`, { + maxRedirects: 0, + failOnStatusCode: false, + timeout: resolveTimeout(30_000), + }); + expect(response.status(), "Expected the front page to redirect").toBe(302); expect( response.url().includes(shared.canonicalDomain), `Expected canonical domain "${shared.canonicalDomain}" to back the docs URL`, ).toBe(true); - expect(new URL(response.url()).pathname, "Expected the front page to open the latest commit").toBe("/latest/"); + expect(response.headers()["location"], "Expected the front page to open the latest commit").toBe("/latest/"); expectHstsWhenTls(response.headers(), shared.appBaseUrl, "docs"); }); - test("latest commit is either the built Sphinx site or its running build", async ({ request }) => { - const response = await request.get(`${shared.appBaseUrl}/latest/`, { timeout: resolveTimeout(30_000) }); + test("the deployed working tree is either the built Sphinx site or its running build", async ({ request }) => { + const response = await request.get(`${shared.appBaseUrl}/deployed/`, { + failOnStatusCode: false, + timeout: resolveTimeout(30_000), + }); const body = await response.text(); expect([200, 202], "Expected the built site or the build page").toContain(response.status()); const built = response.status() === 200; - expect(body, "Expected the Sphinx site or the build page of the latest commit").toContain( - built ? 'data-current="latest"' : 'data-build="latest"', + expect(body, "Expected the Sphinx site or the build page of the deployed working tree").toContain( + built ? 'data-current="deployed"' : 'data-build="deployed"', ); expect(body, "Expected the project title or a progress bar").toContain(built ? "Infinito.Nexus" : " None: - self.assertIn("latest", self._queued()) + def test_the_fetch_queues_latest_behind_what_a_visitor_waits_for(self) -> None: + self.assertEqual(self._queued(), []) + self.assertIn("latest", self._queued("background")) + self.assertEqual(self.library.next_queued(), "latest") def test_a_current_version_is_not_queued_again(self) -> None: self.library._dequeue("latest") diff --git a/tests/unit/python/roles/web-app-docs/files/infinito_docs/test_library.py b/tests/unit/python/roles/web-app-docs/files/infinito_docs/test_library.py index d24e75a6a3..6f1d1f75cf 100644 --- a/tests/unit/python/roles/web-app-docs/files/infinito_docs/test_library.py +++ b/tests/unit/python/roles/web-app-docs/files/infinito_docs/test_library.py @@ -169,7 +169,7 @@ class TestLibrary(LibraryFixture): self.library.fetch() self.assertTrue( - (self.library.queue / "v1.0.0").exists(), + self.library.is_queued("v1.0.0"), "a tag is built on demand and then never revisited, so nothing else " "would ever notice its index predates the split", ) @@ -218,6 +218,7 @@ class TestLibrary(LibraryFixture): self.assertFalse((self.library.queue / "v9.9.9").exists()) def test_queue_is_served_oldest_request_first(self) -> None: + self.library.request("latest") self.library.request("v1.0.0") self.library.request("v1.2.0") os.utime(self.library.queue / "latest", (3000, 3000))