- Ajout de procps-ng dans les 4 Dockerfiles runtime (ps/pgrep disponibles) - Remplacement de pgrep par ps -C dans tous les run-tests.sh - Correction entrypoint nginx-varnish : pgrep nginx → cat nginx.pid (exit 127) - Activation HTTP/2 dans Varnish : ajout de -p feature=+http2 dans les entrypoints nginx-varnish et hitch-varnish - Restauration ALPN h2,http/1.1 dans hitch.conf (varnish supporte maintenant h2) - Correction healthcheck hitch-varnish : curl sans --http1.1 (h2 fonctionnel) - Correction requêtes phase_verify : http_logs_raw → http_logs, colonnes correctes - Correction writer clickhouse.go : noms JSON alignés avec la MV (ip_meta_*, tls_sni…) - Fix toStartOfSecond(DateTime) → toStartOfSecond(toDateTime64(col, 3)) - Retrait du SKIP el8/nginx-varnish (varnish s'installe bien sur AlmaLinux 8) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
99 lines
4.3 KiB
Bash
Executable File
99 lines
4.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# =============================================================================
|
|
# run-tests.sh — Tests d'intégration stack hitch + varnish + ja4ebpf
|
|
# =============================================================================
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
export STACK_NAME="hitch-varnish"
|
|
export COMPOSE_FILE="$SCRIPT_DIR/docker-compose.yml"
|
|
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--no-down) export KEEP_UP=true ;;
|
|
--build-only) export BUILD_ONLY=true ;;
|
|
esac
|
|
done
|
|
|
|
source "$SCRIPT_DIR/../lib/run-stack-tests.sh"
|
|
|
|
# ── Vérifications spécifiques hitch+varnish ───────────────────────────────────
|
|
stack_verify_extra() {
|
|
# Vérifie que hitch est bien en cours d'exécution
|
|
local hitch_pid
|
|
hitch_pid=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
|
ps -C hitch -o pid= 2>/dev/null | head -1 || echo "")
|
|
[ -n "$hitch_pid" ] && pass "Processus hitch actif (PID $hitch_pid)" \
|
|
|| fail "Processus hitch introuvable"
|
|
|
|
# Vérifie Varnish
|
|
local varnish_pid
|
|
varnish_pid=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
|
ps -C varnishd -o pid= 2>/dev/null | head -1 || echo "")
|
|
[ -n "$varnish_pid" ] && pass "Processus varnishd actif (PID $varnish_pid)" \
|
|
|| fail "Processus varnishd introuvable"
|
|
|
|
# Vérifie que ja4ebpf tourne
|
|
local ja4_pid
|
|
ja4_pid=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
|
ps -C ja4ebpf -o pid= 2>/dev/null | head -1 || echo "")
|
|
[ -n "$ja4_pid" ] && pass "ja4ebpf actif (PID $ja4_pid)" \
|
|
|| fail "ja4ebpf introuvable"
|
|
|
|
# Vérifie la présence du header Via Varnish (trafic bien routé hitch→varnish)
|
|
local via_hdr
|
|
via_hdr=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
|
curl -skI https://localhost/ 2>/dev/null | grep -i "^Via:" | tr -d '\r' || echo "")
|
|
if echo "$via_hdr" | grep -qi "varnish"; then
|
|
pass "Header Via: varnish — trafic routé hitch→Varnish→backend"
|
|
else
|
|
warn "Header Via varnish absent ('$via_hdr')"
|
|
fi
|
|
|
|
# Vérifie X-Client-IP : doit être non-vide (Varnish récupère l'IP via PROXY protocol)
|
|
local client_ip_hdr
|
|
client_ip_hdr=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
|
curl -skI https://localhost/ 2>/dev/null | grep -i "^X-Client-IP:" | tr -d '\r' || echo "")
|
|
if [ -n "$client_ip_hdr" ]; then
|
|
pass "PROXY protocol actif : X-Client-IP visible ('$client_ip_hdr')"
|
|
else
|
|
warn "X-Client-IP absent — PROXY protocol peut-être désactivé dans Varnish"
|
|
fi
|
|
|
|
# Vérifie ALPN h2 côté hitch (varnish supporte h2 via -p feature=+http2)
|
|
local http_ver
|
|
http_ver=$(docker compose -f "$COMPOSE_FILE" exec -T platform \
|
|
curl -sk --http2 -w "%{http_version}" -o /dev/null https://localhost/ 2>/dev/null || echo "")
|
|
if [ "$http_ver" = "2" ]; then
|
|
pass "HTTP/2 ALPN négocié par hitch→Varnish (h2)"
|
|
else
|
|
warn "HTTP/2 non négocié (version: '$http_ver') — vérifier -p feature=+http2"
|
|
fi
|
|
|
|
# Vérification clé : dans la stack hitch+varnish, les uprobes sont sur hitch.
|
|
# ja4ebpf doit avoir capturé des requêtes depuis le processus hitch.
|
|
local l7_from_hitch
|
|
l7_from_hitch=$(ch_query "SELECT count() FROM ja4_logs.http_logs WHERE method != ''" || echo "0")
|
|
if [ "${l7_from_hitch:-0}" -gt 0 ] 2>/dev/null; then
|
|
pass "L7 capturé via uprobe hitch : $l7_from_hitch requêtes HTTP"
|
|
else
|
|
warn "Aucune requête L7 — uprobe hitch/libssl peut-être non attaché"
|
|
log " Vérifier : les uprobes nécessitent que hitch soit compilé avec des symboles"
|
|
log " Debug : docker compose exec platform ja4ebpf -config /etc/ja4ebpf/config.yml --dry-run"
|
|
fi
|
|
|
|
# Vérifie que le fingerprint JA4 est cohérent avec la config TLS de hitch
|
|
local ja4_sample
|
|
ja4_sample=$(ch_query "SELECT ja4 FROM ja4_logs.http_logs WHERE ja4 != '' LIMIT 1" || echo "")
|
|
if [ -n "$ja4_sample" ]; then
|
|
if echo "$ja4_sample" | grep -qE "^tt1[23]"; then
|
|
pass "JA4 cohérent avec config hitch TLS 1.2/1.3 : $ja4_sample"
|
|
else
|
|
warn "JA4 inattendu pour hitch TLS config : $ja4_sample"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
run_all_phases
|