feat(scripts): rolling update and failover under k6 load

This commit is contained in:
Голиков Maximillian Антон
2026-10-07 18:11:44 +03:00
parent 320d797554
commit eb7662b137
3 changed files with 182 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
#!/usr/bin/env python3
"""Собирает метрики из k6 summary-export в плоский CSV.
Использование:
python3 scripts/collect-metrics.py evidence/*-k6.json > evidence/summary.csv
"""
import json
import sys
from pathlib import Path
FIELDS = [
("http_reqs", "rate"),
("http_req_failed", "rate"),
("write_errors", "rate"),
("write_total", "count"),
("write_latency_ms", "avg"),
("write_latency_ms", "p(90)"),
("write_latency_ms", "p(95)"),
("write_latency_ms", "max"),
("http_req_duration", "p(95)"),
("http_req_duration", "p(99)"),
]
def main() -> int:
if len(sys.argv) < 2:
print("usage: collect-metrics.py <k6-summary.json> ...", file=sys.stderr)
return 2
print("run,metric,value")
for path in sys.argv[1:]:
name = Path(path).stem
try:
data = json.loads(Path(path).read_text(encoding="utf-8"))
except (OSError, json.JSONDecodeError) as exc:
print(f"# skip {path}: {exc}", file=sys.stderr)
continue
metrics = data.get("metrics", {})
for metric, key in FIELDS:
entry = metrics.get(metric)
if not entry:
continue
values = entry.get("values", entry)
value = values.get(key)
if value is None:
continue
print(f"{name},{metric}.{key},{value}")
return 0
if __name__ == "__main__":
raise SystemExit(main())