Files
vpp-maglev/tests/01-maglevd/maglevd-lab/maglevd.clab.yml
Pim van Pelt 4ab3096c8b Add Prometheus metrics endpoint; containerize integration tests
Prometheus metrics (internal/metrics/, cmd/maglevd/)
- New --metrics-addr flag (default :9091, env MAGLEV_METRICS_ADDR)
  serving /metrics via promhttp.
- Gauge metrics scraped on demand via a custom prometheus.Collector:
  maglev_backend_state, maglev_backend_health, maglev_backend_enabled,
  maglev_frontend_pool_backend_weight.
- Inline counter/histogram metrics updated per probe:
  maglev_probe_total (by backend, type, result, code),
  maglev_probe_duration_seconds (by backend, type),
  maglev_backend_transitions_total (by backend, from, to).
- StateSource interface in metrics package breaks the import cycle
  with checker; checker.Checker satisfies it via GetBackendInfo.

Integration tests
- Run maglevd inside a containerlab node (debian:trixie-slim with
  build/ bind-mounted) instead of on the host. Eliminates port
  collisions with any host maglevd.
- maglevc commands run via docker exec into the maglevd container.
- Add 6 Prometheus test cases: endpoint reachable, all backends
  report state=up, probe counters non-zero, duration histogram
  populated, pool weights correct, transition counters present.
2026-04-11 20:50:59 +02:00

30 lines
619 B
YAML

name: maglevd-test
mgmt:
network: maglevd-test-net
ipv4-subnet: 172.20.30.0/24
topology:
nodes:
maglevd:
kind: linux
image: debian:trixie-slim
mgmt-ipv4: 172.20.30.2
binds:
- ../../../build:/opt/maglev/build:ro
- ./maglev.yaml:/etc/maglev/maglev.yaml:ro
- ./start.sh:/start.sh:ro
cmd: /start.sh
nginx1:
kind: linux
image: nginx:alpine
mgmt-ipv4: 172.20.30.11
nginx2:
kind: linux
image: nginx:alpine
mgmt-ipv4: 172.20.30.12
nginx3:
kind: linux
image: nginx:alpine
mgmt-ipv4: 172.20.30.13