test(gui): drive the current six-step installer instead of the removed UI

The graphical harness still assumed a step-0 welcome, an ERASE field, a
confirmation checkbox, a full-name field and separate passphrase prompts
that were all removed. Update it to the current product:

- navigate with a state-based _goto_step() instead of counting
  Return/Ctrl+Right from a step that no longer exists;
- drive the real account fields (username, computer name, password,
  confirm) with the default single-password encryption, leaving the
  hidden passphrase fields alone;
- trigger the direct "Install now" action and drop the ERASE/confirm
  assertions, while still exercising duplicate submission;
- report stage, elapsed time and the last state on an install timeout;
- boot with the single-password disk passphrase (user password) and fall
  back to the separate passphrase, instead of always using LUKS_PW;
- remove the dead SESSION_SETTLE knob.
This commit is contained in:
Phoebus 2026-09-23 06:16:30 -07:00
parent 12f264a0e9
commit a510efdea2

View file

@ -14,7 +14,8 @@ Modes:
opencode: drive the OpenCode AI step through the real graphical UI and opencode: drive the OpenCode AI step through the real graphical UI and
validate a model response and proposal. validate a model response and proposal.
gui-install: complete a full installation through the visible wizard (AI gui-install: complete a full installation through the visible wizard (AI
connection, disk, account, ERASE, install) on a disposable disk. connection, disk, account, direct "Install now", install) on a
disposable disk.
install : boot, log in on serial, fetch a non-interactive config and 0600 install : boot, log in on serial, fetch a non-interactive config and 0600
secrets over QEMU user networking, run the deterministic install secrets over QEMU user networking, run the deterministic install
with the static binary, scan the log for a secret leak, power off. with the static binary, scan the log for a secret leak, power off.
@ -57,11 +58,12 @@ LIVE_PW = os.environ.get("LIVE_PASSWORD", "phoebus")
USER = os.environ.get("USERNAME", "phoebus") USER = os.environ.get("USERNAME", "phoebus")
USER_PW = os.environ.get("USER_PASSWORD", "phoebus-user-test") USER_PW = os.environ.get("USER_PASSWORD", "phoebus-user-test")
LUKS_PW = os.environ.get("LUKS_PASSPHRASE", "phoebus-luks-test") LUKS_PW = os.environ.get("LUKS_PASSPHRASE", "phoebus-luks-test")
USER_NAME = os.environ.get("USER_USERNAME", USER)
HOST_NAME = os.environ.get("HOST_NAME", "phoebus-vm")
MEM = os.environ.get("VM_MEM", "8192") MEM = os.environ.get("VM_MEM", "8192")
SMP = os.environ.get("VM_SMP", "8") SMP = os.environ.get("VM_SMP", "8")
BOOT_TIMEOUT = int(os.environ.get("BOOT_TIMEOUT", "900")) BOOT_TIMEOUT = int(os.environ.get("BOOT_TIMEOUT", "900"))
INSTALL_TIMEOUT = int(os.environ.get("INSTALL_TIMEOUT", "10800")) INSTALL_TIMEOUT = int(os.environ.get("INSTALL_TIMEOUT", "10800"))
SESSION_SETTLE = int(os.environ.get("SESSION_SETTLE", "20"))
BACKEND_SETTLE = int(os.environ.get("BACKEND_SETTLE", "30")) BACKEND_SETTLE = int(os.environ.get("BACKEND_SETTLE", "30"))
# OpenCode GUI-driving knobs (test-only). The wizard focuses the first AI # OpenCode GUI-driving knobs (test-only). The wizard focuses the first AI
# provider chip when the AI step opens, so three Tabs reach the OpenCode chip. # provider chip when the AI step opens, so three Tabs reach the OpenCode chip.
@ -499,12 +501,16 @@ class Driver:
f"n1={n1} n2={n2}", f"n1={n1} n2={n2}",
) )
# Keyboard-walk the wizard, capturing each step. The welcome step's # The installer opens directly on step 1 (language and keyboard): the
# primary action is focused, so Return starts the journey; Ctrl+Right # duplicate step-0 welcome was removed. Capture it and walk with
# then advances through the deterministic steps. # Ctrl+Right from the frontend's own state, not a keystroke count.
self.sendkey("ret") at_language = self._goto_step(1)
time.sleep(2) self.results.assert_true(
self.shot("03-language", "language and keyboard", "Return on Get started", "language-step-reached",
at_language is not None and at_language["step"] == 1,
f"the wizard did not open on the language step: {at_language}",
)
self.shot("03-language", "language and keyboard", "installer opened",
"the language and keyboard step is shown") "the language and keyboard step is shown")
# Regression: the suggestion list supports arrow-key navigation and # Regression: the suggestion list supports arrow-key navigation and
# Enter selection, with the value stored being the identifier. # Enter selection, with the value stored being the identifier.
@ -526,13 +532,16 @@ class Driver:
) )
self.shot("03b-locale-selected", "locale selected", "Down then Enter", self.shot("03b-locale-selected", "locale selected", "Down then Enter",
"the highlighted locale is selected") "the highlighted locale is selected")
for slug, state in [ for slug, label, target in [
("04-network", "network and prerequisites"), ("04-network", "network and prerequisites", 2),
("05-ai-model", "AI model connection"), ("05-ai-model", "AI model connection", 3),
]: ]:
self.sendkey("ctrl-right") reached = self._goto_step(target)
time.sleep(2) self.results.assert_true(
self.shot(slug, state, "Ctrl+Right", "next wizard step") f"{slug}-reached", reached is not None and reached["step"] == target,
f"did not reach {label}: {reached}",
)
self.shot(slug, label, "Ctrl+Right", "next wizard step")
if not self._installer_alive(): if not self._installer_alive():
self.results.fail("installer-survived-navigation", f"crashed at {slug}") self.results.fail("installer-survived-navigation", f"crashed at {slug}")
return return
@ -655,6 +664,36 @@ class Driver:
time.sleep(2) time.sleep(2)
return None return None
def _goto_step(self, target: int, *, timeout: int = 90) -> dict | None:
"""Advance to a wizard step using the frontend's own state.
The installer now starts directly on step 1 (the duplicate step-0
welcome was removed), so counting keystrokes is brittle. Poll the
secret-free state line and advance with Ctrl+Right until the step is
reached: a state-based wait, not a fixed number of keypresses.
"""
state = self._frontend_state()
if state is not None and state["step"] >= target:
return state
deadline = time.monotonic() + timeout
while time.monotonic() < deadline:
self.sendkey("ctrl-right")
time.sleep(1.5)
state = self._frontend_state()
if state is not None and state["step"] >= target:
return state
return state
def _install_progress(self) -> str:
"""A short, secret-free description of the current install state."""
state = self._frontend_state()
if state is None:
return "no frontend state line available"
return (
f"step={state['step']} phase={state['phase']} "
f"aiConnected={state['aiConnected']}"
)
def do_opencode(self) -> None: def do_opencode(self) -> None:
"""Drive the OpenCode AI step through the real graphical UI. """Drive the OpenCode AI step through the real graphical UI.
@ -706,19 +745,13 @@ class Driver:
"CLOSED", timeout=30, label="close-welcome", "CLOSED", timeout=30, label="close-welcome",
) )
# Navigate to the AI step (welcome -> language -> network -> AI). # Navigate to the AI step from step 1 (language -> network -> AI).
self.sendkey("ret") state = self._goto_step(3)
time.sleep(2)
self.sendkey("ctrl-right")
time.sleep(2)
self.sendkey("ctrl-right")
time.sleep(2)
state = self._frontend_state()
self.results.assert_true( self.results.assert_true(
"ai-step-reached", state is not None and state["step"] == 3, "ai-step-reached", state is not None and state["step"] == 3,
f"frontend state: {state}", f"frontend state: {state}",
) )
self.shot("oc-01-ai", "AI step", "Return + Ctrl+Right twice", "the AI model step is shown") self.shot("oc-01-ai", "AI step", "Ctrl+Right to step 3", "the AI model step is shown")
# Select the "OpenCode agent" chip with the keyboard. The AI step opens # Select the "OpenCode agent" chip with the keyboard. The AI step opens
# with the first provider chip focused. # with the first provider chip focused.
@ -890,8 +923,9 @@ class Driver:
`appliance-guest-gui.sh` installs non-interactively, which does not `appliance-guest-gui.sh` installs non-interactively, which does not
prove the graphical journey. This mode presses the real controls: it prove the graphical journey. This mode presses the real controls: it
connects OpenCode through the UI, accepts the reviewed AI changes, connects OpenCode through the UI, accepts the reviewed AI changes,
selects a disk, sets the account, types ERASE, installs, and checks the selects a disk, sets the account, triggers the direct "Install now"
frontend reports completion. The disk must be a disposable qcow2. action, and checks the frontend reports completion. The disk must be a
disposable qcow2.
""" """
if not self.disks: if not self.disks:
self.results.blocked("gui-install-disk", "no writable disk configured") self.results.blocked("gui-install-disk", "no writable disk configured")
@ -908,8 +942,8 @@ class Driver:
self.set_wayland() self.set_wayland()
# Preseed the wizard defaults so the run is bounded (safe kernel, no # Preseed the wizard defaults so the run is bounded (safe kernel, no
# desktop) while the wizard, validation, AI gate and ERASE confirmation # desktop) while the wizard, validation, AI gate and the direct
# remain the real graphical path. # "Install now" authorization remain the real graphical path.
self.shell( self.shell(
f"curl -fsSL {SERVE_URL}/test.conf -o /tmp/gui-install.conf && " f"curl -fsSL {SERVE_URL}/test.conf -o /tmp/gui-install.conf && "
"sudo -n install -D -m 0644 /tmp/gui-install.conf /etc/phoebus/install.conf && " "sudo -n install -D -m 0644 /tmp/gui-install.conf /etc/phoebus/install.conf && "
@ -949,17 +983,11 @@ class Driver:
"CLOSED", timeout=30, label="close-welcome", "CLOSED", timeout=30, label="close-welcome",
) )
# Welcome -> language -> network -> AI. # The installer opens on step 1; advance to the AI step.
self.sendkey("ret") state = self._goto_step(3)
time.sleep(2)
self.sendkey("ctrl-right")
time.sleep(2)
self.sendkey("ctrl-right")
time.sleep(3)
state = self._frontend_state()
self.results.assert_true("gui-install-ai-step", state is not None and state["step"] == 3, self.results.assert_true("gui-install-ai-step", state is not None and state["step"] == 3,
f"AI step not reached: {state}") f"AI step not reached: {state}")
self.shot("gi-01-ai", "AI step", "Return, Ctrl+Right twice", "AI connection step") self.shot("gi-01-ai", "AI step", "Ctrl+Right to step 3", "AI connection step")
# Select OpenCode and connect through the UI. # Select OpenCode and connect through the UI.
for _ in range(OC_TAB_TO_CHIP): for _ in range(OC_TAB_TO_CHIP):
@ -994,8 +1022,7 @@ class Driver:
self.shot("gi-02-ai-reviewed", "AI reviewed", "Accept changes", "review accepted") self.shot("gi-02-ai-reviewed", "AI reviewed", "Accept changes", "review accepted")
# Destination disk: pick the first selectable disk. # Destination disk: pick the first selectable disk.
self.sendkey("ctrl-right") self._goto_step(4)
time.sleep(3)
self.sendkey("tab") self.sendkey("tab")
time.sleep(0.5) time.sleep(0.5)
self.sendkey("ret") self.sendkey("ret")
@ -1041,59 +1068,66 @@ class Driver:
f"the disk selection did not survive backtracking: {state}", f"the disk selection did not survive backtracking: {state}",
) )
# Account and encryption. # Account and encryption. The current product has a single Username
self.sendkey("ctrl-right") # field, a Computer name, Password and Confirm password; the
time.sleep(2) # "Use same password to encrypt disk" toggle is on by default, so the
state = self._frontend_state() # separate LUKS passphrase fields are hidden and must not be driven.
state = self._goto_step(5)
self.results.assert_true("gui-install-account-step", state is not None and state["step"] == 5, self.results.assert_true("gui-install-account-step", state is not None and state["step"] == 5,
f"account step not reached: {state}") f"account step not reached: {state}")
self._tabs(3) # full name -> username -> computer name -> password # Focus opens on Username.
self._gui_type(USER_NAME)
self._tabs(1) # -> Computer name
self._gui_type(HOST_NAME)
self._tabs(1) # -> Password
self._gui_type(USER_PW) self._gui_type(USER_PW)
self._tabs(2) # reveal -> confirm password self._tabs(1) # -> Confirm password
self._gui_type(USER_PW) self._gui_type(USER_PW)
self._tabs(2) # reveal -> passphrase
self._gui_type(LUKS_PW)
self._tabs(2) # reveal -> confirm passphrase
self._gui_type(LUKS_PW)
self.shot("gi-04-account", "account and encryption", "typed credentials", self.shot("gi-04-account", "account and encryption", "typed credentials",
"password and passphrase entered") "username, computer name and matching password entered")
# Review and ERASE. The review step focuses the ERASE field. # Review. The product now uses a direct "Install now" action: typing
self.sendkey("ctrl-right") # ERASE and the confirmation checkbox were intentionally removed, and
time.sleep(4) # Ctrl+Right on the review step runs exactly that action. The backend
state = self._frontend_state() # still enforces approval binding and disk revalidation.
state = self._goto_step(6)
self.results.assert_true("gui-install-review-step", state is not None and state["step"] == 6, self.results.assert_true("gui-install-review-step", state is not None and state["step"] == 6,
f"review step not reached: {state}") f"review step not reached: {state}")
self.shot("gi-05-review", "review and confirmation", "review shown", self.shot("gi-05-review", "review and confirmation", "review shown",
"backend facts, plan and ERASE confirmation") "backend facts and the installation plan")
self._gui_type("ERASE") self.sendkey("ctrl-right") # Install now
self.sendkey("tab") # the confirmation toggle started = time.monotonic()
time.sleep(0.4)
confirmed = self._frontend_state()
# The toggle responds to Return and Space; QEMU names Space `spc`.
for key in ("ret", "spc"):
if confirmed is not None and confirmed["confirm"]:
break
self.sendkey(key)
time.sleep(0.5)
confirmed = self._frontend_state()
if confirmed is None or not confirmed["confirm"]:
self.results.fail(
"gui-install-erase-confirmed",
f"the confirmation toggle was not ticked: {confirmed}",
)
return
self.results.pass_("gui-install-erase-confirmed")
self.sendkey("ctrl-right") # authorize and install
self.shot("gi-06-installing", "installing", "Ctrl+Right on review", self.shot("gi-06-installing", "installing", "Ctrl+Right on review",
"the installation has started") "the installation has started")
# Approval replay: once the install is underway, submitting the review
# again must not crash the installer or regress it to a failure. The
# backend binds the authorization to the reviewed plan; the frontend
# must survive a repeated action.
underway = self.wait_state(
lambda s: s["phase"] in ("installing", "done", "failed"), timeout=180
)
if underway is not None:
self.sendkey("ctrl-right")
time.sleep(3)
replay = self._frontend_state()
self.results.assert_true(
"gui-install-replay-safe",
replay is not None and replay["phase"] != "failed" and self._installer_alive(),
f"re-submitting the review was not handled safely: {replay}",
)
done = self.wait_state( done = self.wait_state(
lambda s: s["phase"] in ("done", "failed"), lambda s: s["phase"] in ("done", "failed"),
timeout=INSTALL_TIMEOUT, timeout=INSTALL_TIMEOUT,
) )
if done is None: if done is None:
self.results.fail("gui-install-completes", "the wizard did not report completion") elapsed = int(time.monotonic() - started)
self.results.fail(
"gui-install-completes",
f"the wizard did not report completion after {elapsed}s "
f"({self._install_progress()})",
)
return return
self.results.assert_true( self.results.assert_true(
"gui-install-completes", done["phase"] == "done", "gui-install-completes", done["phase"] == "done",
@ -1211,7 +1245,20 @@ class Driver:
assert self.child is not None assert self.child is not None
idx = self.expect([r"[Pp]assphrase", r"login:"], timeout=BOOT_TIMEOUT, label="boot-prompt") idx = self.expect([r"[Pp]assphrase", r"login:"], timeout=BOOT_TIMEOUT, label="boot-prompt")
if idx == 0: if idx == 0:
self.child.sendline(LUKS_PW) # `gui-install` uses the default single-password encryption, so the
# disk passphrase is the user password; the non-interactive
# `install` journey sets a separate one. Try both, in that order,
# and let cryptsetup's immediate re-prompt disambiguate without
# consuming the login prompt on success.
override = os.environ.get("BOOT_PASSPHRASE")
candidates = [override] if override else [USER_PW, LUKS_PW]
self.child.sendline(candidates[0])
for candidate in candidates[1:]:
try:
self.child.expect(r"[Pp]assphrase", timeout=15)
self.child.sendline(candidate)
except (pexpect.TIMEOUT, pexpect.EOF):
break # accepted; the system is booting
logged_in = False logged_in = False
for _ in range(5): for _ in range(5):
try: try: