From 45eca2ef46d028bebb752fadb30d0904268b963a Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Mon, 16 Nov 2026 01:15:10 -0500 Subject: [PATCH] test(e2e): share the reference build through reference_support move_versions_test built the pinned reference daemon itself and pointed a peer at it inline. reference_support.py now owns both: reference() builds or finds the cached build, and run_reference() points a test daemon's next boot at the reference daemon and CLI, so another mixed-version scenario can restart a home on the older build without copying the plumbing. --- test/e2e/move_versions_test.py | 20 ++------------------ test/e2e/reference_support.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 test/e2e/reference_support.py diff --git a/test/e2e/move_versions_test.py b/test/e2e/move_versions_test.py index 1c1768c78..abfe781e0 100644 --- a/test/e2e/move_versions_test.py +++ b/test/e2e/move_versions_test.py @@ -17,7 +17,6 @@ session (see robot-docs/workspaces.md, "Moves between versions"). move_test covers the check against a target of this build. """ -import functools import hashlib import hmac import json @@ -25,7 +24,6 @@ import os import shlex import shutil import sqlite3 -import subprocess import tempfile import unittest import urllib.error @@ -47,7 +45,6 @@ from _transfer_support import ( ) from harness import ( OFFLINE, - ROOT, Provider, fresh_prompt, operation_id, @@ -55,6 +52,7 @@ from harness import ( python, text, ) +from reference_support import run_reference FAKE_SSH = """#!/bin/sh query= @@ -82,17 +80,6 @@ HOOK = "deploys" DELIVERY = b'{"status":"deployed"}' -@functools.cache -def reference(): - """The reference build's directory, built on first use.""" - built = subprocess.run( - [str(ROOT / "test/reference-daemon.sh")], text=True, capture_output=True - ) - if built.returncode: - raise RuntimeError("building the reference daemon failed:\n" + built.stderr) - return Path(built.stdout.strip().splitlines()[-1]) - - def body(daemon, path, payload=None, *, method=None, headers=None): with daemon.api(path, payload, method=method, headers=headers) as response: return json.load(response) @@ -115,7 +102,6 @@ class MixedVersionMoves(unittest.TestCase): self.addCleanup(shutil.rmtree, self.root, True) self.hosts = self.root / "hosts" self.hosts.mkdir() - build = reference() def prepare(daemon): config = { @@ -138,9 +124,7 @@ class MixedVersionMoves(unittest.TestCase): def prepare_reference(daemon): prepare(daemon) - daemon.env["ALBEDO_DAEMON"] = str(build / "daemon" / "albedo-daemon") - daemon.env["ALBEDO_TEST_CLI"] = str(build / "albedo") - daemon.env["ALBEDO_ROOT"] = str(build / "src") + run_reference(daemon) self.current = peer_daemon("versions-current", prepare) self.reference = peer_daemon("versions-reference", prepare_reference) diff --git a/test/e2e/reference_support.py b/test/e2e/reference_support.py new file mode 100644 index 000000000..e38f60e97 --- /dev/null +++ b/test/e2e/reference_support.py @@ -0,0 +1,31 @@ +"""The reference build that mixed-version scenarios run beside this checkout. + +test/reference-daemon.sh pins, builds, and caches it; robot-docs/testing.md +("Mixed-version moves") says when to bump the pin. +""" + +import functools +import subprocess +from pathlib import Path + +from harness import ROOT + + +@functools.cache +def reference(): + """The reference build's directory, built on first use.""" + built = subprocess.run( + [str(ROOT / "test/reference-daemon.sh")], text=True, capture_output=True + ) + if built.returncode: + raise RuntimeError("building the reference daemon failed:\n" + built.stderr) + return Path(built.stdout.strip().splitlines()[-1]) + + +def run_reference(daemon): + """Point `daemon`'s environment at the reference daemon and its CLI, so + its next boot runs the older build on the same home.""" + build = reference() + daemon.env["ALBEDO_DAEMON"] = str(build / "daemon" / "albedo-daemon") + daemon.env["ALBEDO_TEST_CLI"] = str(build / "albedo") + daemon.env["ALBEDO_ROOT"] = str(build / "src") -- knotmirror 0.0.1