Files
felhom.eu/documentation/audits/night-2026-10-28/tools/r1338_box.py
T

34 lines
2.3 KiB
Python

#!/usr/bin/env python3
"""r1338_box.py — R-1338 on scratch 9202 (night 2026-10-28): Wanderer as the live catalog has it (v0.21.2, no cap),
seeded with the box walk's fixture, then the box walk's OWN soak (box_walk.soak — now recording `anon` AND the live
figure) for 420 s, and the full memory.stat of the search container at the peak. The app is removed at the end."""
import json, os, sys, time
sys.path.insert(0, "/mnt/5_hdd/felhom.eu/git/app-catalog-felhom.eu/scripts")
os.environ.setdefault("SC", "/tmp/claude-1000/-mnt-5-hdd-felhom-eu-git/0b76c4d7-9b39-4e4e-869d-d0d2c6006331/scratchpad/rt-9202")
os.environ.setdefault("TARGET", "9202")
import box_walk as w
import upgrade_fixtures_box as fb
EV = "/tmp/claude-1000/-mnt-5-hdd-felhom-eu-git/0b76c4d7-9b39-4e4e-869d-d0d2c6006331/scratchpad/night/r1338/box"
w.login()
out = {}
try:
assert w.deploy("wanderer", "hike"), "deploy failed"
out["images"] = w.guest("docker ps --filter label=com.docker.compose.project=wanderer --format '{{.Names}} {{.Image}}'")
out["meili_env_cap"] = w.guest("docker inspect -f '{{range .Config.Env}}{{println .}}{{end}}' wanderer-search | grep -c MEILI_MAX_INDEXING_MEMORY")
t = fb.Wanderer().seed(w, "hike", w.say)
out["seeded"] = bool(t)
out["soak"] = w.soak("wanderer", 420, 10)
out["search_memory_stat_end"] = w.guest("cid=$(docker inspect -f '{{.Id}}' wanderer-search); cat /sys/fs/cgroup/system.slice/docker-$cid.scope/memory.stat | grep -E '^(anon|file|active_anon|inactive_anon|active_file|inactive_file|shmem|pglazyfree|pglazyfreed) '")
out["readback"] = fb.Wanderer().verify(w, "hike", t, w.say) if t else None
out["guest_swap"] = w.guest("free -m | tail -1")
finally:
json.dump(out, open(os.path.join(EV, "r1338-9202.json"), "w"), indent=1, default=list)
open(os.path.join(EV, "r1338-9202.log"), "w").write("\n".join(w.LOG) + "\n")
if w.stack("wanderer").get("deployed"):
w.remove("wanderer")
open(os.path.join(EV, "r1338-9202.log"), "a").write("\n".join(w.LOG[-6:]) + "\n")
c = (out.get("soak") or {}).get("containers", {})
for n, v in c.items():
print(n, "anon", v.get("anon_peak_pct"), "live", v.get("anon_live_peak_pct"), "cgroup", v.get("cgroup_peak_pct"), "kills", v.get("oom_kill_delta"))
print("peak_pct (live)", (out.get("soak") or {}).get("peak_pct"), "readback", out.get("readback"), "cap-env-lines", out.get("meili_env_cap"))