#!/usr/bin/env bash # # S-16c (#124): assert the golden-signal metrics pipeline works — the .NET services expose # /metrics and Prometheus scrapes them — against an ALREADY-RUNNING full stack. Runs the # driver in a python:3-slim container on the stack network (services reached by container IP; # the runner can't reach published ports — gitea-actions-gotchas.md §5/§6). Does NOT manage # the stack lifecycle. set -euo pipefail here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ip() { docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$1"; } bff="$(docker ps -q --filter 'name=[-_]bff[-_]' | head -1)" prom="$(docker ps -q --filter 'name=[-_]prometheus[-_]' | head -1)" [ -n "$bff" ] && [ -n "$prom" ] || { echo "ERROR: bff and/or prometheus not running — bring the stack up first" >&2; exit 1; } net="$(docker inspect -f '{{range $k,$_ := .NetworkSettings.Networks}}{{$k}}{{"\n"}}{{end}}' "$bff" | head -1)" bff_ip="$(ip "$bff")"; prom_ip="$(ip "$prom")" echo ">> network=$net bff=$bff_ip prometheus=$prom_ip" cid="$(docker create --network "$net" \ -e "BFF=http://$bff_ip:8080" -e "PROMETHEUS=http://$prom_ip:9090" \ -e "METRICS_TIMEOUT=${METRICS_TIMEOUT:-90}" \ python:3-slim python /metrics-check.py)" docker cp "$here/metrics-check.py" "$cid:/metrics-check.py" >/dev/null rc=0; docker start -a "$cid" || rc=$? docker rm -f "$cid" >/dev/null exit $rc