#!/usr/bin/env python3 """R-612 red-proof on 9202, through the product. argv[1] = before|after. before: the drill template as live (128M). after: the drill template at 512M (the fix). Observables: the controller's state; the container's own log (seed Killed / executed); a sign-up through the app's own front door, and what the household is told.""" import sys, re, json, time, fcntl, subprocess sys.path.insert(0, ".") import walk as w mode = sys.argv[1] APP, SUB = "wishlist", "wishlist" if mode == "after": with open(f"{w.SC}/drill.lock", "w") as lk: fcntl.flock(lk, fcntl.LOCK_EX) w.sh(["git", "-C", w.DRILL, "pull", "-q", "--rebase", "origin", "main"], timeout=120) p = f"{w.DRILL}/templates/wishlist/docker-compose.yml" s = open(p).read().replace("memory: 128M", "memory: 512M"); open(p, "w").write(s) w.sh(["git", "-C", w.DRILL, "commit", "-qam", "DRILL R-612: wishlist 512M"]) w.sh(["git", "-C", w.DRILL, "push", "-q", "origin", "main"], timeout=120) w.login() w.sync_rescan() w.deploy(APP, SUB) time.sleep(60) st = w.stack(APP) w.say(f"[{mode}] controller: deployed={st.get('deployed')} state={st.get('state')}") logs = w.app_logs(APP, 200) seed = [l for l in logs.splitlines() if re.search(r"seed|Killed|roles are|default group", l)] w.say(f"[{mode}] container log, seed lines: {seed}") lim = w.guest("docker inspect wishlist -f '{{.HostConfig.Memory}}'").strip() w.say(f"[{mode}] memory limit on the container: {lim}") # sign-up through the front door: GET the page, POST the form the page renders rc, code, page = w.app_curl(SUB, "/signup") names = sorted(set(re.findall(r'name="([a-zA-Z_]+)"', page))) w.say(f"[{mode}] GET /signup -> {code}; form fields {names}") import secrets u = "drill" + secrets.token_hex(3) form = f"name=Drill&username={u}&email={u}%40example.invalid&password=Drill-{secrets.token_hex(8)}&tokenId=" rc, code, body = w.app_curl(SUB, "/signup", "-H", "Content-Type: application/x-www-form-urlencoded", "-H", "Origin: https://wishlist." + w.DOMAIN, "-H", "x-sveltekit-action: true", method="POST", data=form) w.say(f"[{mode}] POST /signup -> {code}: {body[:300]}") told = "already exists" in body w.say(f"[{mode}] household told 'already exists': {told}") cl = w.guest("docker logs wishlist 2>&1 | grep -iE 'foreign key|constraint' | tail -3") w.say(f"[{mode}] container log after sign-up: {cl.strip()!r}") json.dump({"mode": mode, "state": st.get("state"), "seed_lines": seed, "limit": lim, "signup_http": code, "signup_body": body[:500], "told_already_exists": told, "fk_log": cl.strip()}, open(f"apps/wishlist/r612-{mode}.json", "w"), indent=2, ensure_ascii=False) w.remove(APP) open(f"apps/wishlist/r612-{mode}.log", "w").write("\n".join(w.LOG) + "\n")