From 588d475a7b233ff76c81a986b3e9970a46a7f7d1 Mon Sep 17 00:00:00 2001 From: Edgar Arakelyan Date: Mon, 23 Nov 2026 22:34:22 -0800 Subject: [PATCH 1/4] test(computer): each live-site stop has a stand-in site, so one site refusing CI's runners doesn't fail the run Co-Authored-By: Claude Opus 5.5 --- .../computer/chromium_universe_test.py | 58 ++++++++++++------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/tst/integration/computer/chromium_universe_test.py b/tst/integration/computer/chromium_universe_test.py index 8537ed9a1..0e7027c02 100644 --- a/tst/integration/computer/chromium_universe_test.py +++ b/tst/integration/computer/chromium_universe_test.py @@ -1,6 +1,6 @@ """agentenv's chromium on the ubuntu-24.04 desktop, on the universe clock: its boot browser, never launched again, goes out through the computer's egress proxy by the base's policy and loads live sites it hasn't visited with the universe -182 days back, 730 days on and six years on, and right after a jump back; and X runs no screensaver. Needs Docker, the +400 days back, 730 days on and six years on, and right after a jump back; and X runs no screensaver. Needs Docker, the local registry on localhost:5000, and the internet.""" import asyncio @@ -8,6 +8,7 @@ import re import subprocess import time +import warnings import pytest from agentenv_protocol import client as protocol_v1 @@ -27,27 +28,38 @@ DAY = 86400 #: Live sites the browser hasn't visited, each with its page's title, opened in turn with the universe that many days -#: from now: the last right after the jump back. None is behind a bot challenge, as Cloudflare's "Just a moment..." -#: meets CI's browsers at example.com now. Each date is outside any certificate valid today, whose life is at most 398 -#: days, so the egress proxy re-signs every site. -STOPS = [(-400, "https://www.python.org/", "Welcome to Python.org"), - (730, "https://www.gnu.org/", "The GNU Operating System and the Free Software Movement"), - (6 * 365, "https://www.kernel.org/", "The Linux Kernel Archives"), (-400, "https://www.wikipedia.org/", "Wikipedia")] +#: from now: the last right after the jump back. Each stop has a second site that stands in when the first doesn't load, +#: as a site refuses CI's runners for a while now and then (gnu.org did). None is behind a bot challenge, as +#: Cloudflare's "Just a moment..." meets CI's browsers at example.com now. Each date is outside any certificate valid +#: today, whose life is at most 398 days, so the egress proxy re-signs every site. +STOPS = [(-400, [("https://www.python.org/", "Welcome to Python.org"), + ("https://www.postgresql.org/", "PostgreSQL: The world's most advanced open source database")]), + (730, [("https://www.openbsd.org/", "OpenBSD"), ("https://www.netbsd.org/", "The NetBSD Project")]), + (6 * 365, [("https://www.kernel.org/", "The Linux Kernel Archives"), + ("https://www.ruby-lang.org/en/", "Ruby Programming Language")]), + (-400, [("https://www.wikipedia.org/", "Wikipedia"), ("https://www.freebsd.org/", "The FreeBSD Project")])] #: How long a page may take to load before its tab counts as not loaded. LOAD_S = 45 POLICY = "/etc/opt/chrome_for_testing/policies/managed/agentenv-egress.json" -async def _loaded(ok, url: str, title: str) -> str: - """The title of the active tab once it's ``title`` after navigating to ``url``, else the tabs it last saw.""" - await ok("navigate", {"url": url}) - tabs, deadline = [], time.monotonic() + LOAD_S - while time.monotonic() < deadline: - tabs = (await ok("tabs/list", method="GET"))["tabs"] - if (active := next((tab for tab in tabs if tab["active"]), None)) and active["title"] == title: - return title - await asyncio.sleep(0.5) - return json.dumps(tabs) +async def _first_loaded(call, ok, sites: list[tuple[str, str]]) -> tuple[str | None, list[str]]: + """The first of ``sites`` whose title the active tab shows within ``LOAD_S`` of navigating to it, and why each one + before it didn't; None when none did.""" + missed = [] + for url, title in sites: + response = await call("navigate", {"url": url}) + if response.status_code != 200: + missed.append(f"{url}: {response.status_code} {response.text}") + continue + tabs, deadline = [], time.monotonic() + LOAD_S + while time.monotonic() < deadline: + tabs = (await ok("tabs/list", method="GET"))["tabs"] + if (active := next((tab for tab in tabs if tab["active"]), None)) and active["title"] == title: + return url, missed + await asyncio.sleep(0.5) + missed.append(f"{url}: {json.dumps(tabs)}") + return None, missed def _egress_rows(deployed) -> list[dict]: @@ -64,14 +76,14 @@ async def test_its_boot_browser_loads_live_sites_at_any_universe_date_and_x_neve context = TaskStepContext(deployed_envs=[deployed]) try: card = await _app(deployed, WELL_KNOWN_PATH, "chromium") - _, ok = _client(deployed, lambda op: f"{deployed.environment_url}/svc/chromium" + call, ok = _client(deployed, lambda op: f"{deployed.environment_url}/svc/chromium" f"{protocol_v1.find_extension_method(card, BROWSER, op)['endpoint']}") booted = await _browser_process(deployed) clock, loaded = UniverseClock(deployed), [] - for days, url, title in STOPS: + for days, sites in STOPS: clock.set(time.time() + days * DAY, 1) await asyncio.sleep(2) # each program maps the page the next time it reads the clock, within a second - loaded.append(await _loaded(ok, url, title)) + loaded.append(await _first_loaded(call, ok, sites)) still = await _browser_process(deployed) rows = _egress_rows(deployed) xset = (await inside.run(deployed, ["xset", "q"], timeout_s=30))["stdout"] @@ -79,9 +91,11 @@ async def test_its_boot_browser_loads_live_sites_at_any_universe_date_and_x_neve finally: report = await teardown_run(context) - assert loaded == [title for _, _, title in STOPS], loaded + assert all(url for url, _ in loaded), loaded + if stood_in := [missed for _, missed in loaded if missed]: + warnings.warn(f"a stand-in site loaded: {stood_in}") assert still["pid"] == booted["pid"] - hosts = {url.split("/")[2] for _, url, _ in STOPS} + hosts = {url.split("/")[2] for url, _ in loaded} intercepted = {row["host"] for row in rows if row.get("host") in hosts and row.get("mode") == "intercept"} assert intercepted == hosts, [row for row in rows if row.get("host") in hosts][-8:] assert re.search(r"Screen Saver:.*?timeout:\s+0\b", xset, re.S), xset From cb323ccb9ebab3e41d2a81e3ad8ec428f3efc736 Mon Sep 17 00:00:00 2001 From: Edgar Arakelyan Date: Mon, 23 Nov 2026 22:34:22 -0800 Subject: [PATCH 2/4] test(computer): (to revert) a first site that never loads, to show the stand-in in CI Co-Authored-By: Claude Opus 5.5 --- tst/integration/computer/chromium_universe_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tst/integration/computer/chromium_universe_test.py b/tst/integration/computer/chromium_universe_test.py index 0e7027c02..242f2992d 100644 --- a/tst/integration/computer/chromium_universe_test.py +++ b/tst/integration/computer/chromium_universe_test.py @@ -32,7 +32,7 @@ #: as a site refuses CI's runners for a while now and then (gnu.org did). None is behind a bot challenge, as #: Cloudflare's "Just a moment..." meets CI's browsers at example.com now. Each date is outside any certificate valid #: today, whose life is at most 398 days, so the egress proxy re-signs every site. -STOPS = [(-400, [("https://www.python.org/", "Welcome to Python.org"), +STOPS = [(-400, [("https://unreachable.invalid/", "never loads"), ("https://www.python.org/", "Welcome to Python.org"), ("https://www.postgresql.org/", "PostgreSQL: The world's most advanced open source database")]), (730, [("https://www.openbsd.org/", "OpenBSD"), ("https://www.netbsd.org/", "The NetBSD Project")]), (6 * 365, [("https://www.kernel.org/", "The Linux Kernel Archives"), From e48983755e9cae77da86a3dbf8a4c1777397ca48 Mon Sep 17 00:00:00 2001 From: Edgar Arakelyan Date: Mon, 23 Nov 2026 22:48:20 -0800 Subject: [PATCH 3/4] test(computer): drop the unreachable first site that showed the stand-in in CI Co-Authored-By: Claude Opus 5.5 --- tst/integration/computer/chromium_universe_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tst/integration/computer/chromium_universe_test.py b/tst/integration/computer/chromium_universe_test.py index 242f2992d..0e7027c02 100644 --- a/tst/integration/computer/chromium_universe_test.py +++ b/tst/integration/computer/chromium_universe_test.py @@ -32,7 +32,7 @@ #: as a site refuses CI's runners for a while now and then (gnu.org did). None is behind a bot challenge, as #: Cloudflare's "Just a moment..." meets CI's browsers at example.com now. Each date is outside any certificate valid #: today, whose life is at most 398 days, so the egress proxy re-signs every site. -STOPS = [(-400, [("https://unreachable.invalid/", "never loads"), ("https://www.python.org/", "Welcome to Python.org"), +STOPS = [(-400, [("https://www.python.org/", "Welcome to Python.org"), ("https://www.postgresql.org/", "PostgreSQL: The world's most advanced open source database")]), (730, [("https://www.openbsd.org/", "OpenBSD"), ("https://www.netbsd.org/", "The NetBSD Project")]), (6 * 365, [("https://www.kernel.org/", "The Linux Kernel Archives"), From 71a3ddc7f8bb07f986aff9acec44a89cb9867ce2 Mon Sep 17 00:00:00 2001 From: Edgar Arakelyan Date: Mon, 23 Nov 2026 23:04:49 -0800 Subject: [PATCH 4/4] test(computers): the clock panel's redraw gaps allow a late start of the recording xfconf-query Co-Authored-By: Claude Opus 5.5 --- tst/unit/env/envs/test_computer_clock_panel.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tst/unit/env/envs/test_computer_clock_panel.py b/tst/unit/env/envs/test_computer_clock_panel.py index a89249ff0..918c73a29 100644 --- a/tst/unit/env/envs/test_computer_clock_panel.py +++ b/tst/unit/env/envs/test_computer_clock_panel.py @@ -58,6 +58,9 @@ SET = ["-c", "xfce4-panel", "-p", TIMEZONE, "-n", "-t", "string", "-s", ZONE] RESET = ["-c", "xfce4-panel", "-p", TIMEZONE, "-r"] MINUTE = 60.0 +#: How late a redraw's first recorded call may start under load: the fake xfconf-query records when its interpreter +#: is up, so one that starts late shortens the gap after it, though the panel spaced the redraws a second apart. +START_LAG_S = 0.4 @pytest.fixture @@ -191,7 +194,7 @@ def test_at_another_rate_it_redraws_at_every_universe_minute_at_most_once_a_seco time.sleep(2.0) gaps = [b - a for a, b in zip(fast[1:], fast[2:])] - assert all(0.95 <= gap <= 1.6 for gap in gaps), gaps + assert all(1 - START_LAG_S <= gap <= 1.6 for gap in gaps), gaps assert len(panel.redraws()) == len(frozen)