#!/usr/bin/env python3 """Pinned, isolated alert firing/recovery. No production access or notifications. Log tests accelerate windows/for/interval only; expressions and numeric thresholds are otherwise shipped rules. PromQL tests use promtool's simulated clock. """ import json, pathlib, re, subprocess, tempfile, time, urllib.request, urllib.parse, uuid import yaml ROOT = pathlib.Path(__file__).resolve().parents[1] CONFIG = ROOT / 'deploy/logging' images = yaml.safe_load((CONFIG/'compose.yml').read_text())['services'] def run(*args): result=subprocess.run(args, capture_output=True, text=True) if result.returncode:raise RuntimeError(result.stdout+'\n'+result.stderr) return result.stdout.strip() def request(url, data=None): return json.loads(urllib.request.urlopen(urllib.request.Request(url, data=data, headers={'Content-Type':'application/stream+json'} if data else {}), timeout=5).read()) def wait(fn, seconds=30): end=time.monotonic()+seconds; last=None while time.monotonic()