File size: 1,247 Bytes
a2b0c04
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""Start each environment, save its /schema and a first reset(), and report whether it came up."""

import json
import sys
from pathlib import Path

import requests

sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from shortlist.serve import APPS, ROOT, serve  # noqa: E402

out = ROOT / "runs" / "probe"
out.mkdir(parents=True, exist_ok=True)
wanted = sys.argv[1:] or list(APPS)
for env in wanted:
    try:
        with serve(env) as url:
            schema = requests.get(f"{url}/schema", timeout=30).json()
            meta = requests.get(f"{url}/metadata", timeout=30).json()
            reset = requests.post(f"{url}/reset", json={}, timeout=120)
            body = reset.json() if reset.headers.get("content-type", "").startswith("application/json") else reset.text
            (out / f"{env}.json").write_text(json.dumps({"schema": schema, "metadata": meta, "reset": body}, indent=2))
            action = schema.get("action", {})
            print(f"up    {env:28s} action fields: {list(action.get('properties', {}))[:8]}  reset {reset.status_code}")
    except Exception as error:  # noqa: BLE001 - a broken environment is a result, not a crash
        print(f"DOWN  {env:28s} {type(error).__name__}: {str(error)[:200]}")