mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-30 06:46:31 +00:00
fix(web-app-docs): stop serving a deployed build the run did not stage
The site answers 202 while it builds a version, and 200 once a build exists. Whether that build matches what the version currently names was never asked at the serving gate: servable() only checks that an index.html is on disk. So the first request after a new snapshot got the previous build with 200, and the rebuild it triggered finished into a directory nobody was waiting for. For a release tag that cannot happen, and for latest it is a reasonable trade, since a visitor would rather read the previous page than a spinner. For deployed it is wrong by definition: the name means the working tree this run staged, so an earlier snapshot is not a stale answer but a different question's answer. The post-deploy test that reads the published page therefore validated the round before it, and reported a role broken whose page had already been fixed. The comparison already existed. _current() weighs built_ref against _wanted_ref, which resolves deployed to the snapshot digest, and the builder consults it to decide whether to rebuild. Only the server did not. outdated() exposes it for deployed alone and the serving branch now treats a mismatch as not yet servable, so the poll waits for the build it asked for. Measured on the stack while the previous round was live: the served page was written 16:44:41 from the older snapshot, its own source carried the newer content, and the correct build landed at 17:10:56, twenty-six minutes after the test had already read the stale one and failed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
13415bb23d
commit
77cb6251a1
3 files changed
+50
-1
No files matched your search
@@ -276,5 +276,38 @@ class TestBeforeTheFirstFetch(unittest.TestCase):
|
||||
self.assertIsNone(shelf.next_queued())
|
||||
|
||||
|
||||
class TestOutdated(unittest.TestCase):
|
||||
BUILT = "a" * 64
|
||||
STAGED = "b" * 64
|
||||
|
||||
def _shelf(self, td, built, staged):
|
||||
shelf = library.Library("unused", Path(td), 1, Path(td), Path(td) / "snapshot")
|
||||
patch.object(shelf, "refs", lambda: ("head", ())).start()
|
||||
patch.object(shelf, "servable", lambda version: True).start()
|
||||
patch.object(shelf, "built_ref", lambda version: built).start()
|
||||
patch.object(shelf, "snapshot_ref", lambda: staged).start()
|
||||
patch.object(shelf, "_language_index_is_current", lambda version: True).start()
|
||||
self.addCleanup(patch.stopall)
|
||||
return shelf
|
||||
|
||||
def test_a_deployed_build_of_an_older_snapshot_is_outdated(self) -> None:
|
||||
with TemporaryDirectory() as td:
|
||||
shelf = self._shelf(td, self.BUILT, self.STAGED)
|
||||
|
||||
self.assertTrue(shelf.outdated("deployed"))
|
||||
|
||||
def test_a_deployed_build_of_the_staged_snapshot_is_not(self) -> None:
|
||||
with TemporaryDirectory() as td:
|
||||
shelf = self._shelf(td, self.BUILT, self.BUILT)
|
||||
|
||||
self.assertFalse(shelf.outdated("deployed"))
|
||||
|
||||
def test_latest_may_serve_its_previous_build_while_rebuilding(self) -> None:
|
||||
with TemporaryDirectory() as td:
|
||||
shelf = self._shelf(td, self.BUILT, self.STAGED)
|
||||
|
||||
self.assertFalse(shelf.outdated("latest"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user