From 78a43d6a42c4b9ce165a2f657d1e3b613ce9233c Mon Sep 17 00:00:00 2001 From: Mathias Bergqvist Date: Tue, 5 May 2026 22:52:23 +0200 Subject: [PATCH] test(routing): live-contract smoke target Co-Authored-By: Claude Sonnet 4.6 --- Taskfile.yml | 5 ++++ scripts/smoke-routing.sh | 65 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100755 scripts/smoke-routing.sh diff --git a/Taskfile.yml b/Taskfile.yml index 67f8657..7caf336 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -128,6 +128,11 @@ tasks: -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | jq . + smoke:routing: + desc: Boot the routing pod against live LiteLLM + brain and verify _routing logs land + cmds: + - bash scripts/smoke-routing.sh + # ── Git / Release ────────────────────────────────────────────────────────── tag: diff --git a/scripts/smoke-routing.sh b/scripts/smoke-routing.sh new file mode 100755 index 0000000..60e6d93 --- /dev/null +++ b/scripts/smoke-routing.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Boot the routing binary and exercise its four tools against live deps. +# Skipped when LITELLM_BASE_URL or BRAIN_URL is unreachable. + +LITELLM_BASE_URL="${LITELLM_BASE_URL:-http://piguard:4000}" +BRAIN_URL="${BRAIN_URL:-http://koala:30330}" + +if ! curl -sS --max-time 2 "${LITELLM_BASE_URL}/v1/models" >/dev/null 2>&1; then + echo "SKIP: LITELLM at ${LITELLM_BASE_URL} unreachable" + exit 0 +fi +if ! curl -sS --max-time 2 "${BRAIN_URL}/query" -X POST -d '{"query":"x","k":1}' -H 'Content-Type: application/json' >/dev/null 2>&1; then + echo "SKIP: BRAIN at ${BRAIN_URL} unreachable" + exit 0 +fi + +PORT=33310 +BIN=$(mktemp) +trap 'rm -f $BIN; pkill -P $$ -f "$BIN" 2>/dev/null || true' EXIT + +go build -o "$BIN" ./cmd/routing + +LITELLM_BASE_URL="$LITELLM_BASE_URL" BRAIN_URL="$BRAIN_URL" \ + ROUTING_PORT="$PORT" SUPERVISOR_CONFIG_DIR="$(pwd)/config/supervisor" \ + "$BIN" & +BIN_PID=$! + +# Wait for the binary to bind. +for _ in $(seq 1 50); do + curl -sS "http://127.0.0.1:${PORT}/healthz" >/dev/null 2>&1 && break + sleep 0.1 +done + +call_tool() { + local tool="$1" + local args="$2" + curl -sS -X POST "http://127.0.0.1:${PORT}/mcp" \ + -H 'Content-Type: application/json' \ + -d "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"tools/call\",\"params\":{\"name\":\"${tool}\",\"arguments\":${args}}}" \ + | jq -e '.result // .error' > /dev/null +} + +echo "calling tools/list..." +curl -sS -X POST "http://127.0.0.1:${PORT}/mcp" \ + -H 'Content-Type: application/json' \ + -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' \ + | jq -r '.result.tools | map(.name) | sort | .[]' + +echo "calling each tool..." +call_tool review '{"project_root":"/tmp","files":["README.md"],"session_id":"smoke-1"}' +call_tool debug '{"project_root":"/tmp","error":"smoke test","session_id":"smoke-1"}' +call_tool retrospective '{"session_id":"smoke-1"}' +call_tool trainer '{"session_id":"smoke-1"}' + +echo "checking brain has _routing entries..." +sleep 2 +COUNT=$(curl -sS "${BRAIN_URL}/pass-rate?skill=_routing&window=1h" | jq -r '.total // 0') +if [ "${COUNT}" -lt 4 ]; then + echo "FAIL: expected >=4 _routing entries in last 1h, got ${COUNT}" + exit 1 +fi + +echo "PASS: smoke:routing"