ci: the A/A of the network and host oracles is clean, from the evidence of run 44946411675
Network oracle (5,580 leaves differed between the published engine and itself): - the ad frame's origin travels as a URL parameter (a=http%3A..%3A<port>) and the slow frame holds id=sf<token><i>: the normaliser now turns the encoded port into the role of its server and drops the token (the index stays), so a request has the same key in every run (5,532 leaves); - the lab cuts the journey into steps when the driver moves on, and what the browser does on its own (a connection, a second lookup of a name once its 30 s are over) landed in whichever step was current: the CONNECTs and the DNS questions are one summary of the whole journey, the requests and datagrams stay in their step; - the HTTP/3 datagrams are summed over the walk (a visit leaves packets in flight for the next one: 12+8 and 13+7); - the "ERROR in the transcript" scan no longer names the text a page answered (steps/14/extra/error is the sign-in page's own message); - ci/ab-network-volatile.json: the counts of connections (the pool's) and the ECH GREASE AEAD (random per connection), each with the run that proved it. Host oracle: a volatile list of its own (ci/ab-host-volatile.json), applied in the A/A and in the A/B, per system, stale when it matches no leaf, and a leaf that vanishes is not noise unless the entry says so: the live tab-process count and one lazily mapped font on Linux, the job's total process count on Windows. The three oracles' launches use a cache folder of their own (XDG_CACHE_HOME on Linux, the wrapper's cache pinned), so they leave no fontconfig cache of the bundle in the user's folders for the fontconfig test's cold launch.
This commit is contained in:
1 parent
5e18bdc03f
commit
1791f7ea68
11 files changed
+536
-36
No files matched your search
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"format": "ab-host-volatile/1",
|
||||
"about": "The leaves of the host footprint that differ between two launches of ONE engine (the A/A of scripts/ci_ab_host.py). Each entry: `os`, `leaf` (fnmatch over the leaf names: proc.<kind>, mod.<kind>:<path>, spawn.<label>, short.*), `reason` (why that leaf is noise, with the numbers of the run), `aa_run` (the A/A run that proved it) and, only when the leaf may be missing on one side, `absent_ok`. It is applied in the A/A and in the A/B. Born from the evidence of the A/A, never written ahead of it. It may only shrink: an entry that matches no leaf of a run is red as stale.",
|
||||
"entries": [
|
||||
{
|
||||
"os": "linux",
|
||||
"leaf": "proc.tab/isForBrowser",
|
||||
"reason": "How many content processes are alive when the tree is read follows timers of the engine (a process with no frame left is closed after a grace period, a spare is started after a delay), and the wait for a quiet tree (eight equal readings, two seconds) can end before or after one of them. Seed 6: 7 in the first run (the tree changed during the wait, 15 readings) and 8 in the second (9 readings); the other nine launches of the two runs read 8. The processes the tree ever made are compared by strace (spawn.*), and they were equal in all ten launches: 4 Web Content, 4 Isolated Web Co, 1 Privileged Cont, 1 WebExtensions.",
|
||||
"aa_run": "44946411675 (linux)"
|
||||
},
|
||||
{
|
||||
"os": "linux",
|
||||
"leaf": "mod.parent:<app>/fonts/tahoma7_04.ttf",
|
||||
"absent_ok": true,
|
||||
"reason": "The parent maps the fonts of the bundle it is asked for: 8 files in nine of the ten launches and 7 in seed 6 of the first run, without tahoma7_04.ttf, which the tab processes of that launch did map. It is the same launch in which the tree read 7 tab processes (proc.tab/isForBrowser above): that launch took another path through the process allocation. The other seven fonts the parent maps stay compared.",
|
||||
"aa_run": "44946411675 (linux)"
|
||||
},
|
||||
{
|
||||
"os": "windows",
|
||||
"leaf": "short.job_total_processes",
|
||||
"reason": "The job has held 15 processes in eight of the ten launches and 16 in two (seed 6 of the first run, seed 63 of the second): one more content process started and was gone before the snapshot (the polling saw 11 tab processes in those launches, 10 in the others). ActiveProcesses is 13 in all ten, TotalTerminatedProcesses 0, and the kinds alive (proc.*) are equal. One short-lived process more or less in a launch is this noise; a different NAME of a short-lived child is not (it would be a new leaf).",
|
||||
"aa_run": "44946411675 (windows)"
|
||||
},
|
||||
{
|
||||
"os": "windows",
|
||||
"leaf": "short.wmi.firefox.exe",
|
||||
"reason": "The same fact read by the WMI trace of process starts: 16 in the same two launches and 15 in the others, equal to the job's TotalProcesses in all ten.",
|
||||
"aa_run": "44946411675 (windows)"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,5 +1,31 @@
|
||||
{
|
||||
"format": "ab-network-volatile/1",
|
||||
"about": "The leaves of the network transcript that differ between two runs of ONE engine (the A/A of scripts/ci_ab_network.py). Each entry: `pattern` (fnmatch over the leaf path seeds/<seed>/<category>/...), `reason` (why that leaf is noise), `aa_run` (the A/A run that proved it). Born from the evidence of the A/A, never written ahead of it. It may only shrink: an entry that matches no leaf of a run is red as stale.",
|
||||
"entries": []
|
||||
"entries": [
|
||||
{
|
||||
"pattern": "seeds/*/journey/connects/counts/*",
|
||||
"reason": "How many TCP connections the browser opens to each destination of the journey (the DoH, the two origins) is the connection pool's: parallel and speculative connections, keep-alive connections that close and reopen, DoH connections. The set of destinations and the order they were first reached stay compared (journey/connects/order). Totals of the two runs: Linux DoH 226 and 225, origin A 14 and 13, origin O 20 and 12; Windows DoH 222 and 230, A 23 and 15, O 22 and 14.",
|
||||
"aa_run": "44946411675 (linux, windows)"
|
||||
},
|
||||
{
|
||||
"pattern": "seeds/*/lab/launch/connects/counts/*",
|
||||
"reason": "The connections to the DoH at start-up, before any page: 2 and 1 on Linux, 1 and 2 on Windows, between the two runs. Same pool as above; the destination (lab/launch/connects/order) stays compared.",
|
||||
"aa_run": "44946411675 (linux, windows)"
|
||||
},
|
||||
{
|
||||
"pattern": "seeds/*/webrtc/connects/counts/*",
|
||||
"reason": "The connections to the DoH during the WebRTC page: 14 and 25 between the two Windows runs. Same pool; the destinations of the page (webrtc/connects/order) stay compared.",
|
||||
"aa_run": "44946411675 (windows)"
|
||||
},
|
||||
{
|
||||
"pattern": "seeds/*/https/*/v*/connections/*/tls/extensions/encrypted_client_hello/aead",
|
||||
"reason": "The engine sends an ECH extension with no real configuration (GREASE) and its TLS library picks the AEAD of the HPKE suite at random for each connection, 1 (AES-128-GCM) or 3 (ChaCha20-Poly1305): on Windows the h2 connection of the first visit read 1 in one run and 3 in the other, the first h1 connection 3 and 1, both values inside one run. The rest of the extension (type, kdf, enc and payload lengths) stays compared.",
|
||||
"aa_run": "44946411675 (windows)"
|
||||
},
|
||||
{
|
||||
"pattern": "seeds/*/h3/v*/connections/*/tls/extensions/encrypted_client_hello/aead",
|
||||
"reason": "The same ECH GREASE on the HTTP/3 connection: 1 in one run and 3 in the other, on Linux and on Windows.",
|
||||
"aa_run": "44946411675 (linux, windows)"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -19,5 +19,5 @@
|
||||
{"id": "wrapper.e2e.securitystate", "giro": "G2", "os": ["linux", "windows"], "min_tests": 4, "exact": true, "tests": ["tests/test_security_state_engine_e2e.py"], "marker": "e2e", "needs_root": false, "note": "The security state the core declares, against the engine: the engine launched directly in its generate mode makes what it is given (the contract's result, security_state/ with the bytes of the full filter and of the delta, the core's own validation of it); a normal launch declares no pref of the mode and re-imports nothing; a certificate that Mozilla's CRLite test data say is revoked in a delta is refused at the first navigation (SEC_ERROR_REVOKED_CERTIFICATE) while a valid one loads, and the revoked one loads when the ready directory has no data; a ready directory with no or an empty security_state/ starts. Certificates made on the run (a fresh root trusted in cert9.db by the engine's own xpcshell, Mozilla's default test key as the key of CN=int), servers on loopback, no network. Red on firefox-67 (no generate mode)."},
|
||||
{"id": "wrapper.e2e.ab_oracle", "giro": "G2", "os": ["linux", "windows"], "min_tests": 1, "exact": true, "tests": ["tests/test_ab_oracle_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Same seed, same bytes: the engine published as firefox-68 against the candidate, on one machine, with the same core and wrapper, after the control: the published engine against ITSELF (the A/A; a difference is a broken control, exit 2, and the A/B is not run). On a pull request (no candidate: INVPW_BINARY_PATH is the published engine, no INVISIBLE_SEAL_FILE) the A/A is the whole test, on the first two seeds of the candidate set, and saves both dumps and the diff under $AB_ORACLE_OUT or $RUNNER_TEMP/invpw-evidence/ab-oracle. scripts/ci_ab_oracle.py runs the host gate's dump (scripts/ci_host_gate.py dump: the persona seeds of ci/persona-seeds.json, each at its own DPR with nothing pinned, the whole page of scripts/host_gate; the `candidate` set of 5 seeds that reach every webgl renderer and every DPR, or with AB_ORACLE_SEED_SET=final and AB_ORACLE_SHARD=i/n the 20 seeds that reach every value of every dimension split over n jobs) twice, once with the firefox-68 binary (the release's seal.json, then the core's own download.ensure_binary under that seal: the archive's sha256 is checked against the seal) and once with the candidate binary of the leg under its own seal, and compares every leaf of every visit: the only differences allowed are the `noise` entries of scripts/host_gate/exceptions.json and the diag. keys; anything else is red with the leaf, the two values and the seed; fewer leaves than the host gate's reference holds (16439 per visit; a DPR the reference does not record is held to the least of those it does) is red. The files (dump-68.json, dump-68-again.json, diff-a-a.json and, with a candidate, dump-candidate.json and diff.json) are the artifact ab-oracle-<os> of the leg. 1 = the one test; the comparator's own cases (51, the A/A's among them) are in tests/test_ab_oracle.py, the persona seeds' (15) in tests/test_persona_cover.py, in the rows of the whole unit suite. Needs the engine's binary (INVPW_BINARY_PATH) and, for the A/B, the candidate's seal (INVISIBLE_SEAL_FILE) and the network (the release assets of firefox-68). The engine of the candidate must accept the core of the leg and the 68 engine must accept it too: a core that declares something the published engine refuses is a red of this suite, not of the engine."},
|
||||
{"id": "wrapper.e2e.ab_network", "giro": "G2", "os": ["linux", "windows"], "min_tests": 1, "exact": true, "tests": ["tests/test_ab_network_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Network A/B oracle: the P4 journey, HTTPS h1/h2 (ClientHello, h2 frames, header order), HTTP/3 (transport parameters, H3 SETTINGS), WebRTC through the coherent SOCKS5 lab gateway, DNS through the fake DoH, and an idle launch; transcripts compared leaf by leaf, direct connections red on either side. A/A first (the published engine twice: a difference is a broken control; ci/ab-network-volatile.json holds the leaves the A/A proved volatile, and may only shrink), then the published engine against the candidate. Without a candidate (a PR's e2e) the A/A alone."},
|
||||
{"id": "wrapper.e2e.ab_host", "giro": "G2", "os": ["linux", "windows"], "min_tests": 1, "exact": true, "tests": ["tests/test_ab_host_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Host-footprint A/B oracle: after the same journey, the multiset of process kinds (-contentproc type, sandboxingKind, isForBrowser) and the mapped modules per kind (Windows memory_maps, Linux /proc maps), plus the children that came and went from launch (Linux strace; Windows Job accounting and the process-start trace). A/A first, then the published engine against the candidate; the one declared difference (Linux glxtest, gone on the 69) is in ci/ab-host-expected.json, a list that may only shrink. Without a candidate (a PR's e2e) the A/A alone."}
|
||||
{"id": "wrapper.e2e.ab_host", "giro": "G2", "os": ["linux", "windows"], "min_tests": 1, "exact": true, "tests": ["tests/test_ab_host_e2e.py"], "marker": "e2e", "needs_root": false, "note": "Host-footprint A/B oracle: after the same journey, the multiset of process kinds (-contentproc type, sandboxingKind, isForBrowser) and the mapped modules per kind (Windows memory_maps, Linux /proc maps), plus the children that came and went from launch (Linux strace; Windows Job accounting and the process-start trace). A/A first, then the published engine against the candidate; the one declared difference (Linux glxtest, gone on the 69) is in ci/ab-host-expected.json, a list that may only shrink; the leaves two launches of the same engine disagree on are in ci/ab-host-volatile.json, which also may only shrink. Without a candidate (a PR's e2e) the A/A alone."}
|
||||
]
|
||||
+64
-8
@@ -27,12 +27,19 @@ stable, the A/B says nothing).
|
||||
|
||||
Declared differences (ci/ab-host-expected.json) are applied to the A/B only, never to the A/A, and one that does not show
|
||||
is red as stale. Nothing here reads the clock for a verdict.
|
||||
|
||||
The leaves that differ between two launches of ONE engine are the noise (ci/ab-host-volatile.json), and they are born from
|
||||
the A/A: each entry names the leaf, the system, the reason and the run that proved it. A volatile leaf is excused in the A/A
|
||||
and in the A/B alike (it is noise of the engine, not of the candidate), only for the system it is declared for; unless the
|
||||
entry says `absent_ok`, the leaf must still be present on both sides, so that a kind or a counter that vanishes is not noise.
|
||||
An entry that matches no leaf of the run is red as stale.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import codecs
|
||||
import collections
|
||||
import fnmatch
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
@@ -54,6 +61,8 @@ import ci_host_gate as gate # noqa: E402 (SEEDS)
|
||||
FORMAT = "ab-host/1"
|
||||
EXPECTED_FORMAT = "ab-host-expected/1"
|
||||
EXPECTED_FILE = ROOT / "ci" / "ab-host-expected.json"
|
||||
VOLATILE_FORMAT = "ab-host-volatile/1"
|
||||
VOLATILE_FILE = ROOT / "ci" / "ab-host-volatile.json"
|
||||
SEEDS_FILE = ROOT / "ci" / "persona-seeds.json"
|
||||
#: The steps of the journey (tests/fakeweb/profile_p4.py STEPS, by method name).
|
||||
JOURNEY = (("open home", "s1_open_home"),
|
||||
@@ -608,6 +617,30 @@ def load_expected(path: Path = EXPECTED_FILE) -> list:
|
||||
return document["differences"]
|
||||
|
||||
|
||||
def load_volatile(path: Path = VOLATILE_FILE) -> list:
|
||||
"""The entries of the volatile list: each `{"os", "leaf", "reason", "aa_run"}` and, when the leaf may be absent on one side, `"absent_ok": true`. `leaf` is a
|
||||
pattern (`fnmatch`) over the leaf names of `leaves_of`. A malformed list is an error, not an empty one."""
|
||||
document = json.loads(Path(path).read_text(encoding="utf-8"))
|
||||
if document.get("format") != VOLATILE_FORMAT:
|
||||
raise SystemExit("%s: format %r, not %r" % (path, document.get("format"), VOLATILE_FORMAT))
|
||||
entries = document.get("entries")
|
||||
if not isinstance(entries, list):
|
||||
raise SystemExit("%s: `entries` is not a list" % path)
|
||||
seen = set()
|
||||
for entry in entries:
|
||||
if entry.get("os") not in ("linux", "windows"):
|
||||
raise SystemExit("%s: every entry needs an os, linux or windows (%r)" % (path, entry))
|
||||
for field in ("leaf", "reason", "aa_run"):
|
||||
if not isinstance(entry.get(field), str) or not entry[field].strip():
|
||||
raise SystemExit("%s: every entry needs a non-empty %s (%r)" % (path, field, entry))
|
||||
if not isinstance(entry.get("absent_ok", False), bool):
|
||||
raise SystemExit("%s: absent_ok is true or false (%r)" % (path, entry))
|
||||
if (entry["os"], entry["leaf"]) in seen:
|
||||
raise SystemExit("%s: the leaf %r is listed twice for %s" % (path, entry["leaf"], entry["os"]))
|
||||
seen.add((entry["os"], entry["leaf"]))
|
||||
return entries
|
||||
|
||||
|
||||
def _declared_covers(entry: dict, diff: dict) -> bool:
|
||||
"""A declared difference covers a difference of `spawn.<name>` that is the published engine having it (count >= 1) and the
|
||||
candidate not having it."""
|
||||
@@ -618,15 +651,17 @@ def _declared_covers(entry: dict, diff: dict) -> bool:
|
||||
|
||||
|
||||
def judge(a: dict, b: dict, expected: list | None = None, a_a: bool = False, platform: str | None = None,
|
||||
floors: dict | None = None) -> dict:
|
||||
floors: dict | None = None, volatile: list | None = None) -> dict:
|
||||
"""The verdict on two footprints (the document `run` writes). `expected` is the declared differences, applied only when `a_a`
|
||||
is false. Returns {"verdict", "problems", "differences", "declared", "leaves": {seed: {category: n}}, "mode"}."""
|
||||
is false; `volatile` is the noise of the engine (`load_volatile`), applied in both modes. Returns {"verdict", "problems",
|
||||
"differences", "declared", "excused", "volatile", "leaves": {seed: {category: n}}, "mode"}."""
|
||||
floors = FLOORS if floors is None else floors
|
||||
platform = platform or a.get("platform") or sys.platform
|
||||
os_name = "windows" if platform == "win32" else "linux"
|
||||
seeds_a = {s["seed"]: s for s in a.get("seeds", [])}
|
||||
seeds_b = {s["seed"]: s for s in b.get("seeds", [])}
|
||||
problems, differences, declared, counts = [], [], [], {}
|
||||
every_leaf: set = set()
|
||||
for side, fp, seeds in (("A", a, seeds_a), ("B", b, seeds_b)):
|
||||
for message in fp.get("problems", []):
|
||||
problems.append("side %s: %s" % (side, message))
|
||||
@@ -634,6 +669,7 @@ def judge(a: dict, b: dict, expected: list | None = None, a_a: bool = False, pla
|
||||
problems.append("the two footprints have different seeds: A %s, B %s" % (sorted(seeds_a), sorted(seeds_b)))
|
||||
for seed in sorted(set(seeds_a) & set(seeds_b)):
|
||||
la, lb = leaves_of(seeds_a[seed]), leaves_of(seeds_b[seed])
|
||||
every_leaf |= set(la) | set(lb)
|
||||
for side, fp in (("A", seeds_a[seed]), ("B", seeds_b[seed])):
|
||||
for u in fp.get("unreadable", []):
|
||||
problems.append("seed %s side %s: the modules of a process cannot be read: %s" % (seed, side, u))
|
||||
@@ -664,11 +700,25 @@ def judge(a: dict, b: dict, expected: list | None = None, a_a: bool = False, pla
|
||||
for d in hit:
|
||||
differences.remove(d)
|
||||
declared.append(dict(d, id=entry.get("id")))
|
||||
excused, used = [], []
|
||||
for entry in (e for e in volatile or [] if e["os"] == os_name):
|
||||
matching = sorted(leaf for leaf in every_leaf if fnmatch.fnmatchcase(leaf, entry["leaf"]))
|
||||
if not matching:
|
||||
stale.append({"id": entry["leaf"]})
|
||||
problems.append("the volatile entry %r (%s) matches no leaf of either footprint: it is stale, remove it" % (entry["leaf"], entry["aa_run"]))
|
||||
continue
|
||||
covered = [d for d in differences if fnmatch.fnmatchcase(d["leaf"], entry["leaf"])
|
||||
and (entry.get("absent_ok") or (d["a"] != MISSING and d["b"] != MISSING))]
|
||||
for d in covered:
|
||||
differences.remove(d)
|
||||
excused.append(dict(d, aa_run=entry["aa_run"]))
|
||||
used.append({"leaf": entry["leaf"], "leaves": len(matching), "differing": len(covered)})
|
||||
for d in differences:
|
||||
problems.append("seed %s %s: A %s | B %s" % (d["seed"], d["leaf"], json.dumps(d["a"], sort_keys=True)[:160],
|
||||
json.dumps(d["b"], sort_keys=True)[:160]))
|
||||
return {"format": FORMAT, "mode": "a-a" if a_a else "a-b", "verdict": "red" if problems else "green", "problems": problems,
|
||||
"differences": differences, "declared": declared, "stale": [e.get("id") for e in stale], "leaves": counts}
|
||||
"differences": differences, "declared": declared, "excused": excused, "volatile": used,
|
||||
"stale": [e.get("id") for e in stale], "leaves": counts}
|
||||
|
||||
|
||||
def print_report(report: dict, a_name: str, b_name: str) -> None:
|
||||
@@ -679,6 +729,9 @@ def print_report(report: dict, a_name: str, b_name: str) -> None:
|
||||
b_name, json.dumps(d["b"], sort_keys=True)[:160]))
|
||||
for d in report["declared"]:
|
||||
print("DECLARED seed %s %s (%s)" % (d["seed"], d["leaf"], d["id"]))
|
||||
for d in report.get("excused", []):
|
||||
print("VOLATILE seed %s %s: %s %s | %s %s (run %s)" % (d["seed"], d["leaf"], a_name, json.dumps(d["a"], sort_keys=True)[:160], b_name,
|
||||
json.dumps(d["b"], sort_keys=True)[:160], d["aa_run"]))
|
||||
n = len(report["differences"])
|
||||
for p in report["problems"][:len(report["problems"]) - n]:
|
||||
print("FAIL " + p)
|
||||
@@ -849,13 +902,14 @@ def run_subprocess(binary: str, seal: Path | None, leg: str, out: Path, label: s
|
||||
cmd = [sys.executable, "-u", str(Path(__file__).resolve()), "run", binary, "--leg", leg, "--out", str(out), "--label", label,
|
||||
"--seeds", ",".join(str(s) for s in seeds), "--strace", strace]
|
||||
try:
|
||||
return subprocess.run(cmd, env=env, timeout=RUN_TIMEOUT_S).returncode
|
||||
with tempfile.TemporaryDirectory(prefix="ab-host-cache-") as cache:
|
||||
return subprocess.run(cmd, env=oracle.own_cache_env(env, cache), timeout=RUN_TIMEOUT_S).returncode
|
||||
except subprocess.TimeoutExpired:
|
||||
return 124
|
||||
|
||||
|
||||
def ab(candidate: str | None, candidate_seal: Path | None, leg: str, out: Path, engine_tag: str, seeds: list, strace: str,
|
||||
published: tuple | None = None, expected_file: Path = EXPECTED_FILE) -> int:
|
||||
published: tuple | None = None, expected_file: Path = EXPECTED_FILE, volatile_file: Path = VOLATILE_FILE) -> int:
|
||||
"""A/A first (the published engine twice), then, with a candidate, the published engine against it. 0 green, 1 the A/B is red,
|
||||
2 the control is broken."""
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
@@ -879,7 +933,8 @@ def ab(candidate: str | None, candidate_seal: Path | None, leg: str, out: Path,
|
||||
print("\n".join("FAIL " + f for f in failed))
|
||||
return 2
|
||||
first, again = (read_json(out / runs[0][1]), read_json(out / runs[1][1]))
|
||||
control = judge(first, again, a_a=True)
|
||||
volatile = load_volatile(volatile_file)
|
||||
control = judge(first, again, a_a=True, volatile=volatile)
|
||||
write_json(out / "diff-a-a.json", control)
|
||||
print("--- A/A: %s against itself" % engine_tag)
|
||||
print_report(control, engine_tag, engine_tag + " again")
|
||||
@@ -889,7 +944,7 @@ def ab(candidate: str | None, candidate_seal: Path | None, leg: str, out: Path,
|
||||
if not candidate:
|
||||
return 0
|
||||
expected = load_expected(expected_file)
|
||||
report = judge(first, read_json(out / runs[2][1]), expected=expected, a_a=False)
|
||||
report = judge(first, read_json(out / runs[2][1]), expected=expected, a_a=False, volatile=volatile)
|
||||
write_json(out / "diff.json", report)
|
||||
print("--- A/B: %s against the candidate" % engine_tag)
|
||||
print_report(report, engine_tag, oracle.CANDIDATE)
|
||||
@@ -914,6 +969,7 @@ def main(argv=None) -> int:
|
||||
c.add_argument("--out", type=Path)
|
||||
c.add_argument("--a-a", action="store_true", help="the control: no declared difference is applied; a difference is a broken control (exit 2)")
|
||||
c.add_argument("--expected", type=Path, default=EXPECTED_FILE)
|
||||
c.add_argument("--volatile", type=Path, default=VOLATILE_FILE)
|
||||
x = sub.add_parser("ab", help="A/A, then with a candidate the published engine against it")
|
||||
x.add_argument("candidate", nargs="?")
|
||||
x.add_argument("--candidate-seal", type=Path, default=os.environ.get("INVISIBLE_SEAL_FILE"))
|
||||
@@ -927,7 +983,7 @@ def main(argv=None) -> int:
|
||||
args = ap.parse_args(argv)
|
||||
if args.cmd == "compare":
|
||||
a, b = read_json(args.a), read_json(args.b)
|
||||
report = judge(a, b, expected=None if args.a_a else load_expected(args.expected), a_a=args.a_a)
|
||||
report = judge(a, b, expected=None if args.a_a else load_expected(args.expected), a_a=args.a_a, volatile=load_volatile(args.volatile))
|
||||
if args.out:
|
||||
write_json(args.out, report)
|
||||
print_report(report, a.get("engine", "A"), b.get("engine", "B"))
|
||||
|
||||
@@ -17,8 +17,9 @@ datagram log are the transcript's hosts and UDP path), the fake DoH behind it (e
|
||||
* one WebRTC page (STUN and TURN by address through the relay): the candidates, normalised, the SDP, the datagrams the relay carried;
|
||||
* IDLE launches (no action): the destinations of a browser that does nothing, each up to an event the lab drives (see IDLE below).
|
||||
|
||||
THE NORMALISATION. A port of the lab becomes the role of its server (``A``, ``O``, ``page``, ``h1``, ``h2``, ``h3``, ``witness``); the random token of a page of the journey
|
||||
and the values of a cookie are dropped. ci/ab-network-volatile.json lists the leaves that differ between two runs of ONE engine: each entry has the pattern of the leaf
|
||||
THE NORMALISATION. A port of the lab becomes the role of its server (``A``, ``O``, ``page``, ``h1``, ``h2``, ``h3``, ``witness``), written plainly (``:41039``) or inside a URL
|
||||
parameter (``%3A41039``); the random token of a page of the journey (``tok=``, the ids ``lp``, ``park``, ``kapark`` and ``sf``, which the page draws at every load) and the values of a
|
||||
cookie are dropped. ci/ab-network-volatile.json lists the leaves that differ between two runs of ONE engine: each entry has the pattern of the leaf
|
||||
path, the reason, and the A/A run that proved it. The list is born from the A/A (``ab --a-a``, ``compare --a-a``), never written ahead of it, and it may only shrink: an
|
||||
entry that matches no leaf of a run is red as stale.
|
||||
|
||||
@@ -233,6 +234,10 @@ def print_report(report: Dict[str, Any], control: bool) -> None:
|
||||
_PORT = re.compile(r":(\d{2,5})(?!\d)")
|
||||
_TOKEN = re.compile(r"(?P<p>[?&]tok=)[A-Za-z0-9]+")
|
||||
_PAGE_ID = re.compile(r"(?P<p>[?&]id=(?:lp|park|kapark))[a-z0-9]{4,8}")
|
||||
#: The id of the held requests of the slow frame is ``sf`` + the page's random token + the index of the request (tests/fakeweb/journey_site.py, JFRAME_JS "slow"): the token goes, the index stays.
|
||||
_FRAME_ID = re.compile(r"(?P<p>[?&]id=sf)[a-z0-9]{1,10}(?P<i>\d)(?![a-z0-9])")
|
||||
#: A port written inside a value that is itself a URL parameter: ``a=http%3A%2F%2Fjourney-a.test%3A41039`` (encodeURIComponent of the origin the ad frame is told to open).
|
||||
_ENCODED_PORT = re.compile(r"%3[Aa](\d{2,5})(?!\d)")
|
||||
|
||||
|
||||
class Normalizer:
|
||||
@@ -247,8 +252,14 @@ class Normalizer:
|
||||
role = self.roles.get(int(m.group(1)))
|
||||
return ":" + role if role else m.group(0)
|
||||
|
||||
def encoded_port(m: "re.Match[str]") -> str:
|
||||
role = self.roles.get(int(m.group(1)))
|
||||
return "%3A" + role if role else m.group(0)
|
||||
|
||||
value = _PORT.sub(port, value)
|
||||
value = _ENCODED_PORT.sub(encoded_port, value)
|
||||
value = _TOKEN.sub(lambda m: m.group("p") + "<TOK>", value)
|
||||
value = _FRAME_ID.sub(lambda m: m.group("p") + "<TOK>" + m.group("i"), value)
|
||||
return _PAGE_ID.sub(lambda m: m.group("p") + "<TOK>", value)
|
||||
|
||||
def header(self, name: str, value: str) -> str:
|
||||
@@ -392,6 +403,12 @@ def parse_seeds(text: Optional[str]) -> Tuple[int, ...]:
|
||||
return tuple(int(s) for s in text.split(",") if s.strip()) if text else default_seeds()
|
||||
|
||||
|
||||
def transcript_errors(seeds: Dict[str, Any]) -> List[str]:
|
||||
"""The paths where the run itself failed: a phase that raised (``guarded``), a journey step that did not complete, a connection that broke. The ``extra`` of a journey step is
|
||||
what the PAGE answered (the sign-in step has an ``error`` field that holds the text "Wrong user or password.", on purpose): it is content, not a failure of the run."""
|
||||
return sorted(p for p in flatten(seeds) if p.endswith("/error") and "/extra/" not in p)
|
||||
|
||||
|
||||
def write_json(path: Path, document: Any) -> None:
|
||||
Path(path).write_text(json.dumps(document, sort_keys=True, indent=1), encoding="utf-8", newline="\n")
|
||||
|
||||
@@ -785,6 +802,23 @@ def phase_data(lab: Lab, phase: str) -> Dict[str, Any]:
|
||||
"udp": udp_summary(lab.rec.of(phase, "udp"), lab.norm), "requests": request_summary(lab.rec.of(phase, "http"), lab.norm)}
|
||||
|
||||
|
||||
def step_data(lab: Lab, phase: str) -> Dict[str, Any]:
|
||||
"""What the lab saw in ONE step of the journey: the HTTP requests of the tees and the datagrams. Not the CONNECTs and not the DNS questions: the lab cuts the journey into
|
||||
steps at the moment the driver moves on, and what the browser does on its own (a connection it opens or closes, a name it asks again when the 30 s of an answer are over)
|
||||
lands in the step that happens to be current, a different one in each run (A/A run 44946411675: the same CONNECT to ``journey-o.test`` in step 09 of one run and step 12
|
||||
of the other). Those two are summarised over the whole journey instead (:func:`journey_data`). A request is the page's own act, driven by an event, and stays in its step."""
|
||||
data = phase_data(lab, phase)
|
||||
return {"requests": data["requests"], "udp": data["udp"]}
|
||||
|
||||
|
||||
def journey_data(lab: Lab) -> Dict[str, Any]:
|
||||
"""The CONNECTs and the DNS questions of the whole journey (every stage ``journey.*``): the destinations in the order they were first reached and the names in the order they
|
||||
were first asked, which the engine orders (a name is resolved before its first connection), and how many connections each destination got (a count is the pool's, see
|
||||
ci/ab-network-volatile.json)."""
|
||||
queries = [(q.name, q.qtype, q.via) for q in lab.rec.slice("doh", "journey")]
|
||||
return {"connects": connect_summary([e["target"] for e in lab.rec.of("journey", "connect")], lab.norm), "dns": dns_summary(queries)}
|
||||
|
||||
|
||||
def wire_summary(server: Any, phase: str, norm: Normalizer) -> Dict[str, Any]:
|
||||
"""The connections one capture server saw in a stage: the ClientHello, the HTTP/2 frames or the HTTP/1.1 heads, the QUIC parameters and HTTP/3 settings."""
|
||||
snapshot = server.snapshot()
|
||||
@@ -845,7 +879,7 @@ def walk_journey(browser: Any, lab: Lab) -> Dict[str, Any]:
|
||||
steps: Dict[str, Any] = {}
|
||||
stage = {"%02d" % r["n"]: r for r in records}
|
||||
for key in ["00"] + sorted(stage) + ["end"]:
|
||||
step: Dict[str, Any] = phase_data(lab, "journey.%s" % key)
|
||||
step: Dict[str, Any] = step_data(lab, "journey.%s" % key)
|
||||
record = stage.get(key)
|
||||
if record is not None:
|
||||
step.update(name=record["name"], ok=record["ok"], idle=record["idle"], url=record["url"], title=record.get("title"), marker=record.get("marker"),
|
||||
@@ -854,8 +888,7 @@ def walk_journey(browser: Any, lab: Lab) -> Dict[str, Any]:
|
||||
if not record["ok"]:
|
||||
step["error"] = re.sub(r"\d+", "N", record["error"] or "")[:200]
|
||||
steps[key] = step
|
||||
order = list(dict.fromkeys(lab.norm.text(e["target"]) for e in lab.rec.events if e["kind"] == "connect" and e["phase"].startswith("journey.")))
|
||||
return {"steps": steps, "order": order}
|
||||
return dict(journey_data(lab), steps=steps)
|
||||
|
||||
|
||||
def walk_https(browser: Any, lab: Lab, which: str, server: Any, name: str) -> Dict[str, Any]:
|
||||
@@ -891,10 +924,12 @@ def walk_h3(browser: Any, lab: Lab) -> Dict[str, Any]:
|
||||
out["quic_seen"] = bool(lab.h3.quic)
|
||||
protocol = page.evaluate(NAV_JS)
|
||||
out["visits"].append(protocol)
|
||||
data = phase_data(lab, phase)
|
||||
out["v%d" % visit] = dict(wire_summary(lab.h3, phase, lab.norm), dns=data["dns"], udp=data["udp"])
|
||||
out["v%d" % visit] = dict(wire_summary(lab.h3, phase, lab.norm), dns=phase_data(lab, phase)["dns"])
|
||||
if protocol == "h3" or not out["quic_seen"]:
|
||||
break
|
||||
# The datagrams of the whole walk, not of each visit: the packets a visit leaves in flight (an acknowledgement, a close) arrive in the next visit's stage
|
||||
# (A/A run 44946411675, Linux: 12 and 8 datagrams in one run, 13 and 7 in the other, 20 in both).
|
||||
out["udp"] = phase_data(lab, "h3")["udp"]
|
||||
return out
|
||||
finally:
|
||||
context.close()
|
||||
@@ -1033,7 +1068,7 @@ def run(binary: str, label: str, seeds: Tuple[int, ...], out: Path) -> int:
|
||||
sys.stdout.flush()
|
||||
transcript["seeds"][str(seed)] = walk_seed(binary, seed, index == 0, patch)
|
||||
write_json(out, transcript)
|
||||
for path in sorted(p for p in flatten(transcript["seeds"]) if p.endswith("/error")):
|
||||
for path in transcript_errors(transcript["seeds"]):
|
||||
print("ERROR in the transcript at %s" % path)
|
||||
print("transcript written: %s (%d leaves)" % (out, len(flatten(transcript["seeds"]))))
|
||||
return 0
|
||||
@@ -1062,8 +1097,11 @@ def run_engine(binary: str, seal: Optional[str], label: str, seeds: Tuple[int, .
|
||||
command = [sys.executable, "-u", str(Path(__file__).resolve()), "run", "--binary", binary, "--label", label, "--seeds", ",".join(map(str, seeds)), "--out", str(out)]
|
||||
print("=== run %s: %s (seal %s)" % (label, binary, seal or "the one this process has"))
|
||||
sys.stdout.flush()
|
||||
from ci_ab_oracle import own_cache_env
|
||||
|
||||
try:
|
||||
return subprocess.run(command, env=env, timeout=RUN_TIMEOUT_S).returncode
|
||||
with tempfile.TemporaryDirectory(prefix="ab-network-cache-") as cache:
|
||||
return subprocess.run(command, env=own_cache_env(env, cache), timeout=RUN_TIMEOUT_S).returncode
|
||||
except subprocess.TimeoutExpired:
|
||||
return 124
|
||||
|
||||
|
||||
+25
-1
@@ -265,6 +265,29 @@ def fetch_published(tag: str, work: Path) -> tuple:
|
||||
return str(binary), seal_path
|
||||
|
||||
|
||||
def own_cache_env(env: dict, folder: str, platform: str | None = None) -> dict:
|
||||
"""`env` with the engine's per-user cache in a folder of this run (Linux: `XDG_CACHE_HOME`), and the wrapper's own cache where it was.
|
||||
|
||||
Why. fontconfig names the cache of the bundle's font folder by the md5 of its path, and writes it to the first writable cache folder
|
||||
it knows, `$XDG_CACHE_HOME/fontconfig` or the legacy `~/.fontconfig`; it reads all of them. Every launch of the published engine of a
|
||||
job has the same bundle path, so a launch that shares the user's folders leaves the cache of the bundle where a later launch of the
|
||||
job reads it and finds it warm: tests/test_the_parent_reads_the_bundle_from_fontconfig_s_cache_linux_e2e.py needs its first launch
|
||||
COLD (its run 44946411675 found `~/.fontconfig/<md5>-le64.cache-9` already there). The oracles' launches use a folder of their own, so
|
||||
they neither read what an earlier test left nor leave what a later one would read. Both engines of an A/A start from the same empty
|
||||
cache, which is also what makes their first launch the same.
|
||||
|
||||
`XDG_CACHE_HOME` is also where the wrapper looks for its engine (`platformdirs`): `INVISIBLE_PLAYWRIGHT_CACHE_DIR` is pinned to where
|
||||
that is now, and an engine folder or a cache folder the caller set is kept. Windows has no fontconfig: `env` comes back as it was."""
|
||||
if (platform or sys.platform) == "win32":
|
||||
return env
|
||||
import platformdirs
|
||||
|
||||
out = dict(env)
|
||||
out.setdefault("INVISIBLE_PLAYWRIGHT_CACHE_DIR", platformdirs.user_cache_dir("invisible-playwright"))
|
||||
out["XDG_CACHE_HOME"] = str(folder)
|
||||
return out
|
||||
|
||||
|
||||
def run_dump(binary: str, seal: Path | None, leg: str, out: Path, visits: list | None = None) -> int:
|
||||
"""The host gate's dump of `visits` ([(dpr, seed)], each seed at its own DPR) as a subprocess; None is the host gate's own grid."""
|
||||
env = dict(os.environ, INVISIBLE_CORE_AUTOFIX="off", INVISIBLE_CORE_PIN="allow")
|
||||
@@ -275,7 +298,8 @@ def run_dump(binary: str, seal: Path | None, leg: str, out: Path, visits: list |
|
||||
cmd = [sys.executable, str(Path(gate.__file__)), "dump", binary, "--leg", leg, "--out", str(out)]
|
||||
if visits is not None:
|
||||
cmd += ["--no-pin"] + [a for dpr, seed in visits for a in ("--visit", "%d:%s" % (seed, dpr))]
|
||||
return subprocess.run(cmd, env=env, timeout=DUMP_TIMEOUT_S).returncode
|
||||
with tempfile.TemporaryDirectory(prefix="ab-oracle-cache-") as cache:
|
||||
return subprocess.run(cmd, env=own_cache_env(env, cache), timeout=DUMP_TIMEOUT_S).returncode
|
||||
|
||||
|
||||
def run(candidate: str, candidate_seal: Path, leg: str, out: Path, engine_tag: str,
|
||||
|
||||
+110
-1
@@ -173,11 +173,120 @@ def test_in_the_a_a_the_declared_list_is_not_applied():
|
||||
assert [d["leaf"] for d in report["differences"]] == ["spawn.glxtest", "spawn.glxtest"]
|
||||
|
||||
|
||||
# -
|
||||
# The noise of the engine (ci/ab-host-volatile.json).
|
||||
|
||||
TAB = {"os": "linux", "leaf": "proc.tab/isForBrowser", "reason": "a timer", "aa_run": "run 1 (linux)"}
|
||||
FONT = {"os": "linux", "leaf": "mod.parent:<app>/fonts/tahoma7_04.ttf", "absent_ok": True, "reason": "lazy", "aa_run": "run 1 (linux)"}
|
||||
|
||||
|
||||
def with_tabs(tabs, engine="firefox-68 again", platform="linux", modules=None):
|
||||
fp = footprint(engine, platform)
|
||||
for seed in fp["seeds"]:
|
||||
if seed["seed"] == 12:
|
||||
seed["kinds"]["tab/isForBrowser"] = tabs
|
||||
seed["modules"]["parent"] = list(seed["modules"]["parent"]) + list(modules or [])
|
||||
return fp
|
||||
|
||||
|
||||
def test_a_leaf_that_varies_between_two_launches_of_one_engine_is_excused_by_the_list_and_the_a_a_is_green():
|
||||
report = judge(footprint(), with_tabs(3), expected=[], a_a=True, volatile=[TAB])
|
||||
assert report["verdict"] == "green" and report["problems"] == [] and report["differences"] == []
|
||||
(excused,) = report["excused"]
|
||||
assert (excused["seed"], excused["leaf"], excused["a"], excused["b"], excused["aa_run"]) == (12, "proc.tab/isForBrowser", 2, 3, "run 1 (linux)")
|
||||
assert report["volatile"] == [{"leaf": "proc.tab/isForBrowser", "leaves": 1, "differing": 1}]
|
||||
red = judge(footprint(), with_tabs(3), expected=[], a_a=True)
|
||||
assert red["verdict"] == "red" and [d["leaf"] for d in red["differences"]] == ["proc.tab/isForBrowser"] and red["excused"] == []
|
||||
|
||||
|
||||
def test_the_list_excuses_only_the_leaf_it_names_and_a_real_difference_next_to_it_is_still_red():
|
||||
c = with_tabs(3)
|
||||
c["seeds"][0]["kinds"]["gpu"] = 0
|
||||
c["seeds"][1]["modules"]["tab/isForBrowser"] = c["seeds"][1]["modules"]["tab/isForBrowser"] + ["<app>/libnew.so"]
|
||||
report = judge(footprint(), c, expected=[], a_a=True, volatile=[TAB])
|
||||
assert report["verdict"] == "red"
|
||||
assert sorted(d["leaf"] for d in report["differences"]) == ["mod.tab/isForBrowser:<app>/libnew.so", "proc.gpu"]
|
||||
assert [d["leaf"] for d in report["excused"]] == ["proc.tab/isForBrowser"]
|
||||
|
||||
|
||||
def test_a_counter_that_vanishes_is_not_noise_unless_the_entry_says_a_leaf_may_be_absent():
|
||||
gone = footprint("firefox-68 again")
|
||||
del gone["seeds"][1]["kinds"]["tab/isForBrowser"]
|
||||
report = judge(footprint(), gone, expected=[], a_a=True, volatile=[TAB])
|
||||
assert report["verdict"] == "red" and [(d["leaf"], d["a"], d["b"]) for d in report["differences"]] == [("proc.tab/isForBrowser", 2, host.MISSING)]
|
||||
tahoma = with_tabs(2, modules=["<app>/fonts/tahoma7_04.ttf"])
|
||||
both = judge(footprint(), tahoma, expected=[], a_a=True, volatile=[FONT])
|
||||
assert both["verdict"] == "green" and [(d["leaf"], d["a"], d["b"]) for d in both["excused"]] == [("mod.parent:<app>/fonts/tahoma7_04.ttf", host.MISSING, 1)]
|
||||
other = with_tabs(2, modules=["<app>/fonts/verdana5_33.ttf"])
|
||||
assert judge(footprint(), other, expected=[], a_a=True, volatile=[FONT])["verdict"] == "red", "the other fonts the parent maps stay compared"
|
||||
|
||||
|
||||
def test_the_list_applies_in_the_a_b_too_and_an_entry_that_matches_no_leaf_is_red_as_stale():
|
||||
report = judge(footprint(), with_tabs(3, "candidate"), expected=expected(), volatile=[TAB])
|
||||
assert report["verdict"] == "red" and report["stale"] == ["glxtest-69"] and report["differences"] == [], "the declared difference still has to show; the tab count is excused"
|
||||
green = judge(footprint(), with_tabs(3, "candidate"), expected=[], volatile=[TAB])
|
||||
assert green["verdict"] == "green" and [d["leaf"] for d in green["excused"]] == ["proc.tab/isForBrowser"]
|
||||
stale = judge(footprint(), footprint(), expected=[], a_a=True, volatile=[dict(TAB, leaf="proc.nothing/there")])
|
||||
assert stale["verdict"] == "red" and stale["stale"] == ["proc.nothing/there"] and any("stale" in p for p in stale["problems"])
|
||||
|
||||
|
||||
def test_an_entry_of_another_system_is_neither_applied_nor_stale_here():
|
||||
windows = dict(TAB, os="windows", leaf="short.job_total_processes")
|
||||
report = judge(footprint(), with_tabs(3), expected=[], a_a=True, volatile=[windows])
|
||||
assert report["verdict"] == "red" and report["stale"] == [] and report["excused"] == []
|
||||
on_windows = judge(footprint(platform="win32"), with_tabs(3, platform="win32"), expected=[], a_a=True, volatile=[TAB, windows])
|
||||
assert on_windows["stale"] == ["short.job_total_processes"], "a Windows entry with no short.* leaf in the footprint is stale"
|
||||
|
||||
|
||||
def test_the_volatile_list_of_the_repository_is_well_formed_and_names_its_evidence():
|
||||
entries = host.load_volatile()
|
||||
assert entries and {e["os"] for e in entries} == {"linux", "windows"}
|
||||
assert all(e["aa_run"].startswith("44946411675") and e["reason"].strip() for e in entries)
|
||||
assert len({(e["os"], e["leaf"]) for e in entries}) == len(entries)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("document,why", [
|
||||
({"format": "x", "entries": []}, "format"),
|
||||
({"format": host.VOLATILE_FORMAT, "entries": "no"}, "list"),
|
||||
({"format": host.VOLATILE_FORMAT, "entries": [dict(TAB, os="mac")]}, "os"),
|
||||
({"format": host.VOLATILE_FORMAT, "entries": [{k: v for k, v in TAB.items() if k != "aa_run"}]}, "aa_run"),
|
||||
({"format": host.VOLATILE_FORMAT, "entries": [dict(TAB, reason=" ")]}, "reason"),
|
||||
({"format": host.VOLATILE_FORMAT, "entries": [dict(TAB, absent_ok="yes")]}, "absent_ok"),
|
||||
({"format": host.VOLATILE_FORMAT, "entries": [TAB, TAB]}, "twice"),
|
||||
])
|
||||
def test_a_malformed_volatile_list_is_an_error_not_an_empty_list(tmp_path, document, why):
|
||||
path = tmp_path / "v.json"
|
||||
path.write_text(json.dumps(document), encoding="utf-8")
|
||||
with pytest.raises(SystemExit) as raised:
|
||||
host.load_volatile(path)
|
||||
assert why in str(raised.value)
|
||||
|
||||
|
||||
def test_each_footprint_run_has_a_cache_folder_of_its_own_that_is_gone_when_it_ends(tmp_path, monkeypatch):
|
||||
"""The fontconfig test of the same job needs its first launch cold: the footprint's launches do not leave the cache of the bundle in the user's folders."""
|
||||
seen = []
|
||||
|
||||
class Done:
|
||||
returncode = 0
|
||||
|
||||
original = host.oracle.own_cache_env
|
||||
monkeypatch.setattr(host.oracle, "own_cache_env", lambda env, folder: original(env, folder, platform="linux"))
|
||||
monkeypatch.setenv("XDG_CACHE_HOME", str(tmp_path / "user"))
|
||||
monkeypatch.setattr(host.subprocess, "run", lambda cmd, env, timeout: seen.append((env["XDG_CACHE_HOME"], Path(env["XDG_CACHE_HOME"]).is_dir())) or Done())
|
||||
assert host.run_subprocess("ff", None, "linux-x86_64", tmp_path / "f.json", "firefox-68", [1], "auto") == 0
|
||||
assert host.run_subprocess("ff", None, "linux-x86_64", tmp_path / "f.json", "firefox-68 again", [1], "auto") == 0
|
||||
(first, there1), (second, there2) = seen
|
||||
assert there1 and there2 and first != second and str(tmp_path / "user") not in (first, second)
|
||||
assert not Path(first).exists() and not Path(second).exists()
|
||||
|
||||
|
||||
def test_the_cli_says_broken_control_for_an_a_a_difference(tmp_path, capsys):
|
||||
a, b = tmp_path / "a.json", tmp_path / "b.json"
|
||||
for path, doc in ((a, footprint()), (b, a_candidate_without_glxtest())):
|
||||
path.write_text(json.dumps(doc), encoding="utf-8")
|
||||
assert host.main(["compare", str(a), str(b), "--a-a"]) == 2
|
||||
empty = tmp_path / "volatile.json"
|
||||
empty.write_text(json.dumps({"format": host.VOLATILE_FORMAT, "entries": []}), encoding="utf-8")
|
||||
assert host.main(["compare", str(a), str(b), "--a-a", "--volatile", str(empty)]) == 2
|
||||
assert "AB HOST (a-a) FAILED" in capsys.readouterr().out
|
||||
|
||||
|
||||
|
||||
@@ -15,6 +15,9 @@ Two modes, chosen by the environment as the gate chooses it:
|
||||
(its seal and archive fetched the way the core fetches an engine), then the published engine against the candidate, with the declared differences of
|
||||
ci/ab-host-expected.json.
|
||||
|
||||
What two launches of the SAME engine disagree on is listed in ci/ab-host-volatile.json (with the run that proved it, per system); it applies in the A/A and in the A/B, and an
|
||||
entry that matches no leaf is red as stale. The launches run with a cache folder of their own (XDG_CACHE_HOME on Linux), so they leave nothing for the fontconfig test's cold launch.
|
||||
|
||||
The footprints, the diffs and the log are kept whatever the verdict: in AB_ORACLE_OUT/ab-host (the gate uploads that folder), else in
|
||||
$RUNNER_TEMP/invpw-evidence/ab-host (the e2e job uploads that one), else in tmp_path.
|
||||
|
||||
@@ -74,9 +77,9 @@ def test_the_engine_leaves_the_same_footprint_on_the_host_after_the_same_journey
|
||||
capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=TIMEOUT_S)
|
||||
(out / "ab-host.log").write_text(done.stdout + "\n--- stderr\n" + done.stderr, encoding="utf-8")
|
||||
verdict = [line for line in done.stdout.splitlines()
|
||||
if line.startswith(("DIFF ", "FAIL ", "DECLARED ", "AB HOST", "BROKEN CONTROL", "seed ", "---"))]
|
||||
if line.startswith(("DIFF ", "FAIL ", "DECLARED ", "VOLATILE ", "AB HOST", "BROKEN CONTROL", "seed ", "---"))]
|
||||
control = json.loads((out / "diff-a-a.json").read_text(encoding="utf-8")) if (out / "diff-a-a.json").exists() else {}
|
||||
assert done.returncode != 2, "the control is broken: the engine differs from itself, what is compared is not stable\n" + "\n".join(verdict[:80])
|
||||
assert done.returncode != 2, "the control is broken: the engine differs from itself, what is compared is not stable (what may differ is listed in ci/ab-host-volatile.json)\n" + "\n".join(verdict[:80])
|
||||
assert done.returncode == 0, "the host footprint differs:\n" + "\n".join(verdict[:80]) + "\n" + done.stderr[-1500:]
|
||||
assert control.get("verdict") == "green" and control.get("differences") == [] and control.get("problems") == []
|
||||
names = sorted(p.name for p in out.glob("footprint-*.json"))
|
||||
|
||||
+191
-12
@@ -31,9 +31,9 @@ def transcript(label="a", seeds=(11, 12)):
|
||||
"""A small transcript with the categories a real one has: a journey step, a TLS hello, an HTTP/2 connection, a WebRTC gather, an idle window and the lab's direct lists."""
|
||||
def seed_body():
|
||||
return {
|
||||
"journey": {"order": ["127.0.0.1:A", "127.0.0.1:O"],
|
||||
"journey": {"connects": {"order": ["127.0.0.1:A", "127.0.0.1:O"], "counts": {"127.0.0.1:A": 2, "127.0.0.1:O": 1}},
|
||||
"dns": {"order": ["journey-a.test"], "types": {"journey-a.test": [1]}},
|
||||
"steps": {"01": {"name": "open home", "ok": True, "idle": True, "url": "A/",
|
||||
"connects": {"order": ["127.0.0.1:A"], "counts": {"127.0.0.1:A": 2}},
|
||||
"requests": {"GET A/": {"count": 1, "headers": [["Host", "journey-a.test:A"], ["Accept", "*/*"]], "name_orders": ["Host,Accept"],
|
||||
"body_length": 0}}}}},
|
||||
"https": {"h2": {"v1": {"connections": [{"alpn": "h2", "tls": wc.parse_client_hello(build_hello())}]}}},
|
||||
@@ -114,13 +114,13 @@ def test_a_direct_connection_on_either_side_is_red_by_itself(side, name):
|
||||
|
||||
def test_a_volatile_entry_excuses_the_leaves_it_names_and_only_those():
|
||||
b = transcript("b")
|
||||
b["seeds"]["11"]["journey"]["steps"]["01"]["connects"]["counts"]["127.0.0.1:A"] = 3
|
||||
b["seeds"]["11"]["journey"]["connects"]["counts"]["127.0.0.1:A"] = 3
|
||||
b["seeds"]["12"]["webrtc"]["gathering"] = "new"
|
||||
entry = {"pattern": "seeds/*/journey/steps/*/connects/counts/*", "reason": "speculative connections", "aa_run": "run 1"}
|
||||
entry = {"pattern": "seeds/*/journey/connects/counts/*", "reason": "speculative connections", "aa_run": "run 1"}
|
||||
report = compare(transcript(), b, [entry])
|
||||
assert [d["path"] for d in report["differences"]] == ["seeds/12/webrtc/gathering"]
|
||||
assert report["excused"] == 2 and report["volatile"] == [{"pattern": entry["pattern"], "leaves": 2, "differing": 1}]
|
||||
assert report["leaves"] == compare(transcript(), b)["leaves"] - 2
|
||||
assert report["excused"] == 4 and report["volatile"] == [{"pattern": entry["pattern"], "leaves": 4, "differing": 1}]
|
||||
assert report["leaves"] == compare(transcript(), b)["leaves"] - 4
|
||||
|
||||
|
||||
def test_a_volatile_entry_that_matches_no_leaf_is_stale_and_red():
|
||||
@@ -172,9 +172,13 @@ def test_a_file_that_is_not_a_transcript_is_refused(tmp_path):
|
||||
|
||||
def test_an_a_a_that_differs_proposes_the_volatile_patterns_without_the_seed_and_the_step():
|
||||
b = transcript("b")
|
||||
b["seeds"]["11"]["journey"]["steps"]["01"]["connects"]["counts"]["127.0.0.1:A"] = 3
|
||||
b["seeds"]["12"]["journey"]["steps"]["01"]["connects"]["counts"]["127.0.0.1:A"] = 4
|
||||
assert ab.propose_volatile(compare(transcript(), b)) == ["seeds/*/journey/steps/*/connects/counts/127.0.0.1:A"]
|
||||
b["seeds"]["11"]["journey"]["connects"]["counts"]["127.0.0.1:A"] = 3
|
||||
b["seeds"]["12"]["journey"]["connects"]["counts"]["127.0.0.1:A"] = 4
|
||||
assert ab.propose_volatile(compare(transcript(), b)) == ["seeds/*/journey/connects/counts/127.0.0.1:A"]
|
||||
c = transcript("c")
|
||||
c["seeds"]["11"]["journey"]["steps"]["01"]["requests"]["GET A/"]["count"] = 2
|
||||
c["seeds"]["12"]["journey"]["steps"]["01"]["requests"]["GET A/"]["count"] = 2
|
||||
assert ab.propose_volatile(compare(transcript(), c)) == ["seeds/*/journey/steps/*/requests/GET A//count"]
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------------------------------------------ the volatile list
|
||||
@@ -183,6 +187,23 @@ def test_the_volatile_list_of_the_repository_is_well_formed_and_every_entry_name
|
||||
assert all(e["aa_run"].strip() and e["reason"].strip() for e in entries)
|
||||
|
||||
|
||||
def test_the_entries_of_the_repository_list_excuse_the_counts_of_connections_and_the_grease_aead_and_nothing_next_to_them():
|
||||
import fnmatch
|
||||
|
||||
patterns = [e["pattern"] for e in ab.load_volatile()]
|
||||
def excused(path):
|
||||
return [q for q in patterns if fnmatch.fnmatchcase(path, q)]
|
||||
|
||||
base = "seeds/0/https/h2/v1/connections/0/tls/extensions/encrypted_client_hello/"
|
||||
assert excused(base + "aead") and not excused(base + "kdf") and not excused(base + "payload_length") and not excused(base + "type")
|
||||
assert excused("seeds/0/h3/v1/connections/0/tls/extensions/encrypted_client_hello/aead")
|
||||
assert excused("seeds/0/journey/connects/counts/192.0.2.53:443") and excused("seeds/0/lab/launch/connects/counts/192.0.2.53:443") and excused("seeds/0/webrtc/connects/counts/192.0.2.53:443")
|
||||
for kept in ("seeds/0/journey/connects/order/0", "seeds/0/journey/dns/order/0", "seeds/0/journey/steps/01/requests/GET A//count", "seeds/0/journey/steps/01/requests/GET A//headers/0/1",
|
||||
"seeds/0/journey/steps/01/udp/counts/198.51.100.5:19302", "seeds/0/lab/launch/connects/order/0", "seeds/0/webrtc/connects/order/0", "seeds/0/h3/udp/counts/10.0.0.1:h3",
|
||||
"seeds/0/https/h2/v1/connections/0/tls/extensions/server_name"):
|
||||
assert not excused(kept), kept
|
||||
|
||||
|
||||
@pytest.mark.parametrize("document,why", [
|
||||
({"format": "x", "entries": []}, "format"),
|
||||
({"format": ab.VOLATILE_FORMAT, "entries": "no"}, "list"),
|
||||
@@ -257,6 +278,144 @@ def test_connects_dns_and_datagrams_keep_the_first_seen_order_and_count_the_rest
|
||||
assert ab.message_kind(b"\xc3" + b"\x00" * 30) == "quic-long" and ab.message_kind(b"\x43abc") == "quic-short" and ab.message_kind(b"\x01") == "other"
|
||||
|
||||
|
||||
def test_a_port_inside_a_url_parameter_and_the_token_of_the_slow_frame_are_normalised_so_two_loads_of_the_page_write_the_same_key():
|
||||
"""A/A run 44946411675: the ad frame is told its sibling's origin as ``a=http%3A%2F%2Fjourney-a.test%3A<port>`` and the slow frame holds ``id=sf<token><i>``: both
|
||||
differ at every load, so the same request had a different key in each run and 5,500 leaves differed."""
|
||||
first, second = ab.Normalizer({41039: "A", 41040: "O"}), ab.Normalizer({46001: "A", 46002: "O"})
|
||||
ad = "/jf/ad?n=1&a=http%3A%2F%2Fjourney-a.test%3A"
|
||||
assert first.text(ad + "41039") == second.text(ad + "46001") == ad + "A"
|
||||
assert first.text("/jf/ad?n=0&a=http%3A%2F%2Fjourney-o.test%3a41040") == "/jf/ad?n=0&a=http%3A%2F%2Fjourney-o.test%3AO", "the encoded colon may be written in lower case"
|
||||
assert first.text("/hold?id=sfkjpsqn0") == second.text("/hold?id=sfx7q2m90") == "/hold?id=sf<TOK>0"
|
||||
assert first.text("/release?id=sfab12c32") == "/release?id=sf<TOK>2", "a token that ends in a digit leaves the index alone"
|
||||
assert first.text("/hold?id=sfkjpsqn0") != first.text("/hold?id=sfkjpsqn1"), "the index of the request is not random: three held requests stay three keys"
|
||||
assert first.text("/x?a=http%3A%2F%2Fother.test%3A9999") == "/x?a=http%3A%2F%2Fother.test%3A9999", "a number that is no port of the lab is left as it is"
|
||||
assert first.text("/r?kind=json&id=late3&u=sfun") == "/r?kind=json&id=late3&u=sfun"
|
||||
|
||||
|
||||
def test_two_loads_of_the_journey_write_the_same_request_summary_and_a_request_that_really_differs_is_still_red():
|
||||
def requests(port_a, port_o, token):
|
||||
norm = ab.Normalizer({port_a: "A", port_o: "O"})
|
||||
head = lambda target, extra=(): {"role": "O", "method": "GET", "target": target, "headers": [["Host", "journey-o.test:%d" % port_o], *extra], "body_length": 0} # noqa: E731
|
||||
return ab.request_summary([head("/hold?id=sf%s%d" % (token, i)) for i in range(3)] + [head("/release?id=sf%s%d" % (token, i)) for i in range(3)]
|
||||
+ [head("/jf/ad?n=0&a=http%%3A%%2F%%2Fjourney-a.test%%3A%d" % port_a, [["Referer", "http://journey-o.test:%d/" % port_o]])], norm)
|
||||
|
||||
one, two = requests(41039, 41040, "kjpsqn"), requests(46001, 46002, "x7q2m9")
|
||||
assert one == two and list(one) == ["GET O/hold?id=sf<TOK>0", "GET O/hold?id=sf<TOK>1", "GET O/hold?id=sf<TOK>2", "GET O/jf/ad?n=0&a=http%3A%2F%2Fjourney-a.test%3AA",
|
||||
"GET O/release?id=sf<TOK>0", "GET O/release?id=sf<TOK>1", "GET O/release?id=sf<TOK>2"]
|
||||
a, b = transcript(), transcript("b")
|
||||
for t, summary in ((a, one), (b, two)):
|
||||
t["seeds"]["11"]["journey"]["steps"]["01"]["requests"] = summary
|
||||
assert compare(a, b)["verdict"] == "green"
|
||||
two["GET O/jf/ad?n=0&a=http%3A%2F%2Fjourney-a.test%3AA"]["headers"][1] = ["Referer", "http://journey-o.test:O/other"]
|
||||
report = compare(a, b)
|
||||
(difference,) = report["differences"]
|
||||
assert report["verdict"] == "red" and difference["path"] == "seeds/11/journey/steps/01/requests/GET O/jf/ad?n=0&a=http%3A%2F%2Fjourney-a.test%3AA/headers/1/1"
|
||||
assert difference["a"] == "http://journey-o.test:O/" and difference["b"] == "http://journey-o.test:O/other"
|
||||
|
||||
|
||||
def test_the_error_scan_names_a_failure_of_the_run_and_not_the_text_a_page_answered():
|
||||
seeds = {"0": {"journey": {"steps": {"14": {"extra": {"error": "Wrong user or password.", "user": "alice"}, "ok": True},
|
||||
"15": {"ok": False, "error": "TimeoutError: Page.goto: Timeout Nms exceeded"}}},
|
||||
"h3": {"error": "RuntimeError: no quic"}, "https": {"h2": {"v1": {"connections": [{"error": "ConnectionResetError"}]}}}}}
|
||||
assert ab.transcript_errors(seeds) == ["seeds/0/h3/error", "seeds/0/https/h2/v1/connections/0/error", "seeds/0/journey/steps/15/error"]
|
||||
assert ab.transcript_errors({"0": {"journey": {"steps": {"14": {"extra": {"error": "Wrong user or password."}}}}}}) == []
|
||||
|
||||
|
||||
def _journey_run(monkeypatch, connects_by_step, queries_by_step=None):
|
||||
"""``ab.walk_journey`` with the driver replaced by a function that, in each step, makes the browser's connections and DNS questions arrive to the lab as the events that
|
||||
``connects_by_step`` and ``queries_by_step`` say ({step: [target, ...]}); the requests of every step are the same."""
|
||||
from fakeweb import journey_site, profile_p4
|
||||
|
||||
queries_by_step = queries_by_step or {}
|
||||
with ab.Lab(journey=True, host="127.0.0.1") as lab:
|
||||
port_a = int(lab.origin_a.rsplit(":", 1)[1])
|
||||
|
||||
def drive(browser, origin_a, origin_o, workers, timeout):
|
||||
records = []
|
||||
for n in (1, 2, 3):
|
||||
journey_site.STATE.set_step(n)
|
||||
lab.rec.event("http", role="A", method="GET", target="/page%d" % n, headers=[["Host", "journey-a.test:%d" % port_a]], body_length=0)
|
||||
for target in connects_by_step.get(n, []):
|
||||
lab.rec.event("connect", target=target.replace("<A>", "127.0.0.1:%d" % port_a))
|
||||
for name in queries_by_step.get(n, []):
|
||||
lab.doh.queries.append(type("Q", (), {"name": name, "qtype": 1, "via": "lab"})())
|
||||
records.append({"n": n, "name": "step %d" % n, "ok": True, "idle": True, "url": "A/", "title": "t", "marker": "m", "cookies": [], "history_length": n, "pages": 1,
|
||||
"extra": {}})
|
||||
return records
|
||||
|
||||
monkeypatch.setattr(profile_p4, "drive", drive)
|
||||
return ab.walk_journey(object(), lab)
|
||||
|
||||
|
||||
def test_a_connection_or_a_name_that_lands_in_another_step_of_the_journey_is_the_same_journey_and_a_new_destination_is_not(monkeypatch):
|
||||
"""A/A run 44946411675: the browser's own connections and its second lookup of a name (the answer lives 30 s) were written under the step that was current, a different one in
|
||||
each run; 40 leaves differed that way on Linux and 60 on Windows. The CONNECTs and the DNS questions are one summary of the whole journey; the requests stay in their step."""
|
||||
doh = "192.0.2.53:443"
|
||||
first = _journey_run(monkeypatch, {1: [doh, "<A>", doh], 3: ["<A>"]}, {1: ["journey-a.test"], 3: ["journey-a.test"]})
|
||||
second = _journey_run(monkeypatch, {1: [doh], 2: ["<A>", "<A>"], 3: [doh, doh]}, {1: ["journey-a.test"], 2: ["journey-a.test"]})
|
||||
assert "order" not in first and set(first) == {"steps", "connects", "dns"}
|
||||
assert all(set(step) >= {"requests", "udp"} and "connects" not in step and "dns" not in step for step in first["steps"].values())
|
||||
assert first["connects"]["order"] == second["connects"]["order"] == [doh, "127.0.0.1:A"]
|
||||
assert first["dns"] == second["dns"] == {"order": ["journey-a.test"], "types": {"journey-a.test": [1]}}
|
||||
assert first["connects"]["counts"] != second["connects"]["counts"], "the pool's counts do differ, and the volatile list says so"
|
||||
a, b = transcript(), transcript("b")
|
||||
a["seeds"]["11"]["journey"], b["seeds"]["11"]["journey"] = first, second
|
||||
volatile = [{"pattern": "seeds/*/journey/connects/counts/*", "reason": "the pool", "aa_run": "x"}]
|
||||
report = compare(a, b, volatile)
|
||||
assert report["verdict"] == "green" and report["differences"] == [] and report["excused"] == 4
|
||||
third = _journey_run(monkeypatch, {1: [doh, "<A>", "192.0.2.77:443"]}, {1: ["journey-a.test"]})
|
||||
c = transcript("c")
|
||||
c["seeds"]["11"]["journey"] = third
|
||||
red = compare(a, c, volatile)
|
||||
assert red["verdict"] == "red"
|
||||
assert {"path": "seeds/11/journey/connects/order/2", "a": ab.MISSING, "b": "192.0.2.77:443"} in red["differences"]
|
||||
|
||||
|
||||
def _h3_run(visits):
|
||||
"""``ab.walk_h3`` with a page that answers h2 until the last visit and h3 on it, and a QUIC server that has seen a connection; ``visits`` is the datagrams the relay carries
|
||||
in each visit's stage (the last ones of one visit arrive in the next one's, which is what the A/A showed)."""
|
||||
from types import SimpleNamespace
|
||||
|
||||
rec = ab.Recorder()
|
||||
rec.attach("doh", [])
|
||||
lab = SimpleNamespace(rec=rec, norm=ab.Normalizer({}), h3=SimpleNamespace(port=5, quic=[object()]))
|
||||
state = {"visit": 0}
|
||||
|
||||
class Page:
|
||||
def goto(self, url, **options):
|
||||
state["visit"] += 1
|
||||
for _ in range(visits[state["visit"] - 1]):
|
||||
rec.event("udp", target="127.0.0.1:5", message="quic-short")
|
||||
|
||||
def evaluate(self, script):
|
||||
return "h3" if state["visit"] == len(visits) else "h2"
|
||||
|
||||
def wait_for_timeout(self, ms):
|
||||
pass
|
||||
|
||||
class Context:
|
||||
def new_page(self):
|
||||
return Page()
|
||||
|
||||
def close(self):
|
||||
pass
|
||||
|
||||
browser = SimpleNamespace(new_context=lambda **kw: Context())
|
||||
original = ab.wire_summary
|
||||
ab.wire_summary = lambda server, phase, norm: {"connections": [], "quic": []}
|
||||
try:
|
||||
return ab.walk_h3(browser, lab)
|
||||
finally:
|
||||
ab.wire_summary = original
|
||||
|
||||
|
||||
def test_the_datagrams_of_the_http3_walk_are_summarised_over_the_walk_because_a_visit_leaves_packets_in_flight_for_the_next():
|
||||
one, two = _h3_run([12, 8]), _h3_run([13, 7])
|
||||
assert one == two and one["udp"]["counts"] == {"127.0.0.1:5": 20} and one["visits"] == ["h2", "h3"]
|
||||
assert all("udp" not in one[v] for v in ("v1", "v2"))
|
||||
assert _h3_run([13, 8])["udp"]["counts"] == {"127.0.0.1:5": 21} != one["udp"]["counts"], "a datagram more in the walk is a difference"
|
||||
|
||||
|
||||
def test_an_ice_candidate_loses_what_it_draws_at_random_and_keeps_what_the_client_decides():
|
||||
exit_ip = "198.51.100.9"
|
||||
mdns = "candidate:0 1 UDP 2122252543 6f1c1e2a-9b8d-4c33-a1e0-5d7f7a9c0b11.local 51234 typ host"
|
||||
@@ -453,7 +612,7 @@ def minimal_run():
|
||||
headers = [["Host", "journey-a.test:7000"], ["User-Agent", "Mozilla/5.0"], ["Accept", "text/html"], ["Accept-Language", "en-US,en;q=0.5"], ["Accept-Encoding", "gzip, deflate"],
|
||||
["Connection", "keep-alive"], ["Upgrade-Insecure-Requests", "1"], ["Cookie", "theme=dark"]]
|
||||
request = {"role": "A", "method": "GET", "target": "/", "headers": headers, "body_length": 0}
|
||||
step = {"connects": ab.connect_summary(["127.0.0.1:7000"], norm), "dns": ab.dns_summary([("journey-a.test", 1, "lab")]), "udp": ab.udp_summary([], norm),
|
||||
step = {"udp": ab.udp_summary([], norm),
|
||||
"requests": ab.request_summary([request] * 3, norm), "name": "n", "ok": True, "idle": True, "url": "A/", "title": "t", "marker": "m", "cookies": [], "history_length": 2,
|
||||
"pages": 1, "extra": {}}
|
||||
tls = wc.parse_client_hello(build_hello())
|
||||
@@ -462,7 +621,8 @@ def minimal_run():
|
||||
"frames_after_the_first_request": 3, "settings_ack_sent_by_client": True,
|
||||
"requests": [{"stream": 1, "pseudo_order": [":method", ":path", ":authority", ":scheme"], "header_names": ["user-agent", "accept"], "headers": [[":method", "GET"], ["user-agent", "x"]],
|
||||
"end_stream": True}]}
|
||||
body = {"journey": {"steps": {"%02d" % i: step for i in range(17)}, "order": ["127.0.0.1:A"]}, "https": {"h2": {"v1": {"connections": [{"alpn": "h2", "tls": tls, "h2": h2}]}}},
|
||||
body = {"journey": {"steps": {"%02d" % i: step for i in range(17)}, "connects": ab.connect_summary(["127.0.0.1:7000"], norm),
|
||||
"dns": ab.dns_summary([("journey-a.test", 1, "lab")])}, "https": {"h2": {"v1": {"connections": [{"alpn": "h2", "tls": tls, "h2": h2}]}}},
|
||||
"webrtc": {"candidates": ["udp comp1 prio1 srflx <exit>"], "gathering": "complete"}, "idle": {"c1": {"destinations": {"connects": [], "dns": []}}},
|
||||
"lab": {"direct": {"witness_tcp": [], "witness_udp": [], "watcher": [], "doh_direct": [], "resolver_trap": [], "blind": []}}}
|
||||
leaves = ab.flatten({"11": body})
|
||||
@@ -477,7 +637,7 @@ def test_a_whole_synthetic_transcript_of_a_plausible_run_holds_the_leaves_the_fl
|
||||
assert set(by_category) == {"journey", "https", "webrtc", "idle", "lab"}
|
||||
assert by_category["https"] > 100, "the ClientHello alone is a hundred leaves or more"
|
||||
assert by_category["journey"] > 17 * 30
|
||||
assert total > 700
|
||||
assert total > 600
|
||||
|
||||
|
||||
def test_the_script_names_the_categories_the_run_writes_and_the_e2e_floor_is_below_a_minimal_run():
|
||||
@@ -583,6 +743,25 @@ def _fake_run_engine(monkeypatch, make):
|
||||
return calls
|
||||
|
||||
|
||||
def test_each_engine_run_of_the_network_oracle_has_a_cache_folder_of_its_own_that_is_gone_when_it_ends(tmp_path, monkeypatch):
|
||||
import ci_ab_oracle as oracle
|
||||
|
||||
seen = []
|
||||
|
||||
class Done:
|
||||
returncode = 0
|
||||
|
||||
original = oracle.own_cache_env
|
||||
monkeypatch.setattr(oracle, "own_cache_env", lambda env, folder: original(env, folder, platform="linux"))
|
||||
monkeypatch.setenv("XDG_CACHE_HOME", str(tmp_path / "user"))
|
||||
monkeypatch.setattr(ab.subprocess, "run", lambda cmd, env, timeout: seen.append((env["XDG_CACHE_HOME"], Path(env["XDG_CACHE_HOME"]).is_dir())) or Done())
|
||||
assert ab.run_engine("ff", None, "firefox-68", (0,), tmp_path / "t.json") == 0
|
||||
assert ab.run_engine("ff", None, "firefox-68-again", (0,), tmp_path / "t.json") == 0
|
||||
(first, there1), (second, there2) = seen
|
||||
assert there1 and there2 and first != second and str(tmp_path / "user") not in (first, second)
|
||||
assert not Path(first).exists() and not Path(second).exists()
|
||||
|
||||
|
||||
def _ab_args(tmp_path, *extra):
|
||||
empty = tmp_path / "volatile.json"
|
||||
empty.write_text(json.dumps({"format": ab.VOLATILE_FORMAT, "entries": []}), encoding="utf-8")
|
||||
|
||||
@@ -31,7 +31,7 @@ SCRIPT = ROOT / "scripts" / "ci_ab_network.py"
|
||||
sys.path.insert(0, str(ROOT / "scripts"))
|
||||
import ci_ab_network as oracle # noqa: E402
|
||||
|
||||
#: The fewest leaves a comparison holds, per system. A minimal but complete run of ONE seed (one request on each road, tests/test_ab_network.py) holds about 740; a real one holds several times that. A floor of
|
||||
#: The fewest leaves a comparison holds, per system. A minimal but complete run of ONE seed (one request on each road, tests/test_ab_network.py) holds about 670; a real one holds several times that. A floor of
|
||||
#: 500 says "the run saw something on every road" and nothing more: it is raised to a fraction of the measured count once the A/A has measured it.
|
||||
FLOOR = {"linux": 500, "win32": 500}
|
||||
TIMEOUT_S = 40 * 60
|
||||
|
||||
@@ -305,6 +305,40 @@ def test_each_dump_runs_under_its_own_seal_and_without_the_engine_log(tmp_path,
|
||||
assert env["INVISIBLE_CORE_AUTOFIX"] == "off" and env["INVISIBLE_CORE_PIN"] == "allow"
|
||||
|
||||
|
||||
def test_a_launch_of_an_oracle_keeps_its_user_cache_to_itself_and_the_wrapper_keeps_finding_its_engine(tmp_path, monkeypatch):
|
||||
"""run 44946411675: a cache of the bundle's fonts left in the user's folders made the first launch of the fontconfig test warm. The oracles' launches write theirs elsewhere."""
|
||||
import platformdirs
|
||||
|
||||
monkeypatch.setenv("XDG_CACHE_HOME", str(tmp_path / "user"))
|
||||
monkeypatch.delenv("INVISIBLE_PLAYWRIGHT_CACHE_DIR", raising=False)
|
||||
where_the_engine_is = platformdirs.user_cache_dir("invisible-playwright")
|
||||
base = {"A": "1", "XDG_CACHE_HOME": str(tmp_path / "user")}
|
||||
env = ab.own_cache_env(base, str(tmp_path / "mine"), platform="linux")
|
||||
assert env["XDG_CACHE_HOME"] == str(tmp_path / "mine") and env["INVISIBLE_PLAYWRIGHT_CACHE_DIR"] == where_the_engine_is and env["A"] == "1"
|
||||
assert base == {"A": "1", "XDG_CACHE_HOME": str(tmp_path / "user")}, "the environment it was given is not changed"
|
||||
kept = ab.own_cache_env({"INVISIBLE_PLAYWRIGHT_CACHE_DIR": "/the/callers"}, "x", platform="linux")
|
||||
assert kept["INVISIBLE_PLAYWRIGHT_CACHE_DIR"] == "/the/callers", "a cache folder the caller chose is kept"
|
||||
given = {"A": "1"}
|
||||
assert ab.own_cache_env(given, "x", platform="win32") is given, "Windows has no fontconfig: nothing changes"
|
||||
|
||||
|
||||
def test_every_dump_of_an_oracle_runs_in_a_cache_folder_of_its_own_that_is_gone_when_it_ends(tmp_path, monkeypatch):
|
||||
seen = []
|
||||
|
||||
class Done:
|
||||
returncode = 0
|
||||
|
||||
original = ab.own_cache_env
|
||||
monkeypatch.setattr(ab, "own_cache_env", lambda env, folder: original(env, folder, platform="linux"))
|
||||
monkeypatch.setenv("XDG_CACHE_HOME", str(tmp_path / "user"))
|
||||
monkeypatch.setattr(ab.subprocess, "run", lambda cmd, env, timeout: seen.append((env["XDG_CACHE_HOME"], Path(env["XDG_CACHE_HOME"]).is_dir())) or Done())
|
||||
ab.run_dump("ff", None, "linux-x86_64", tmp_path / "o", [(1.0, 0)])
|
||||
ab.run_dump("ff", None, "linux-x86_64", tmp_path / "o", [(1.0, 0)])
|
||||
(first, there1), (second, there2) = seen
|
||||
assert there1 and there2 and first != second and str(tmp_path / "user") not in (first, second)
|
||||
assert not Path(first).exists() and not Path(second).exists()
|
||||
|
||||
|
||||
# --- the seeds: the persona seeds (ci/persona-seeds.json), each at its own DPR, in shards ---------------------------------------------------------
|
||||
|
||||
def test_the_default_visits_are_the_candidate_persona_seeds_each_at_its_own_dpr():
|
||||
|
||||
Reference in new issue
Block a user