40 lines
1.4 KiB
Bash
40 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
|||
|
|
# Full SLA sweep across every team, SEQUENTIALLY.
|
||
|
|
#
|
||
|
|
# Sequential is not optional: the receivers are sync Flask apps, so hitting
|
||
|
|
# several at once makes them contend for the same 2 CPUs and report false
|
||
|
|
# timeouts (a pitfall already documented, and re-violated once here).
|
||
|
|
set -uo pipefail
|
||
|
|
BASE=/opt/gemastik18-final
|
||
|
|
declare -A RPORT=( [1]=31080 [2]=32080 [3]=33080 [4]=34080 )
|
||
|
|
|
||
|
|
echo "load: $(cut -d' ' -f1-3 /proc/loadavg)"
|
||
|
|
for t in 1 2 3 4; do
|
||
|
|
ENVF=$BASE/teams/team$t/receiver/.env
|
||
|
|
[ -f "$ENVF" ] || { echo "=== team$t: no receiver env ==="; continue; }
|
||
|
|
U=$(grep -oP '^ADMIN_USERNAME=\K.*' "$ENVF")
|
||
|
|
P=$(grep -oP '^ADMIN_PASSWORD=\K.*' "$ENVF")
|
||
|
|
port=${RPORT[$t]}
|
||
|
|
S=$(date +%s)
|
||
|
|
code=$(timeout 900 curl -sS -u "$U:$P" \
|
||
|
|
"http://127.0.0.1:$port/check/all" \
|
||
|
|
-o "/tmp/sla_t$t.json" -w '%{http_code}' 2>/dev/null)
|
||
|
|
took=$(( $(date +%s) - S ))
|
||
|
|
echo "=== team$t (receiver :$port, HTTP $code, ${took}s) ==="
|
||
|
|
python3 - "$t" <<'PY'
|
||
|
|
import json, sys
|
||
|
|
t = sys.argv[1]
|
||
|
|
try:
|
||
|
|
d = json.load(open(f"/tmp/sla_t{t}.json"))
|
||
|
|
except Exception as e:
|
||
|
|
print(" no/invalid result:", e); raise SystemExit
|
||
|
|
r = d.get("results", d)
|
||
|
|
if not isinstance(r, dict):
|
||
|
|
print(" ", json.dumps(d)[:300]); raise SystemExit
|
||
|
|
ok = sorted(k for k, v in r.items() if v is True)
|
||
|
|
bad = sorted(k for k, v in r.items() if v is not True)
|
||
|
|
print(f" PASS {len(ok)}/{len(r)}")
|
||
|
|
if ok: print(" ok :", ", ".join(ok))
|
||
|
|
if bad: print(" BAD:", ", ".join(bad))
|
||
|
|
PY
|
||
|
|
done
|