Two endpoints over forge's Ollama gpt-oss:120b: /local-optimistic/v1 forge, else cloud gpt-5.4-mini /local-strict/v1 forge, else a clean 503 the caller handles Discovery, not configuration: each instance probes an ordered candidate list (stable DNS name, then the Lounge and future Serenity literals) concurrently but in priority order, so the happy path is one round trip and silicon's move to Serenity needs no rewrite. /healthz runs a real 1-token completion — forge can be up with Ollama stopped. Liveness/readiness are deliberately NOT forge-gated: otherwise k8s would evict the pods during an outage and callers would get a connection failure instead of the promised 503, and Kuma could not tell "forge down" from "router gone". max_tokens/max_completion_tokens are translated per backend: Ollama accepts only the former, gpt-5.4-mini rejects it outright. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
33 lines
2.4 KiB
Bash
Executable File
33 lines
2.4 KiB
Bash
Executable File
#!/bin/sh
|
|
# Runs INSIDE the cluster, against the live Service and against a throwaway
|
|
# instance whose upstream is deliberately dead. Plain POSIX sh + curl only.
|
|
GOOD=http://forgeway.forgeway.svc.cluster.local
|
|
BAD=http://forgeway-badtest.forgeway.svc.cluster.local
|
|
CHAT='{"messages":[{"role":"user","content":"Answer with the single word: PONG"}],"max_tokens":400}'
|
|
|
|
j() { curl -s -m 180 -o /tmp/b -D /tmp/h -w '%{http_code}' "$@"; }
|
|
backend() { grep -i '^x-forgeway-backend:' /tmp/h | tr -d '\r' | awk '{print $2}'; }
|
|
content() { sed -n 's/.*"content":"\([^"]*\)".*/\1/p' /tmp/b | head -1 | cut -c1-60; }
|
|
|
|
echo "1 healthz (forge up) .................. HTTP $(j $GOOD/healthz)"
|
|
echo " $(cut -c1-150 /tmp/b)"
|
|
echo "2 strict chat (forge up) .............. HTTP $(j -XPOST $GOOD/local-strict/v1/chat/completions -H 'Content-Type: application/json' -d "$CHAT") backend=$(backend)"
|
|
echo " content=[$(content)]"
|
|
echo "3 optimistic chat (forge up) .......... HTTP $(j -XPOST $GOOD/local-optimistic/v1/chat/completions -H 'Content-Type: application/json' -d "$CHAT") backend=$(backend)"
|
|
echo " content=[$(content)]"
|
|
echo "4 strict /v1/models .................. HTTP $(j $GOOD/local-strict/v1/models)"
|
|
echo " $(cut -c1-140 /tmp/b)"
|
|
echo "5 optimistic /v1/models .............. HTTP $(j $GOOD/local-optimistic/v1/models)"
|
|
echo " $(cut -c1-220 /tmp/b)"
|
|
echo "6 STRICT chat, forge UNAVAILABLE ..... HTTP $(j -XPOST $BAD/local-strict/v1/chat/completions -H 'Content-Type: application/json' -d "$CHAT")"
|
|
echo " $(cut -c1-260 /tmp/b)"
|
|
echo "7 OPTIMISTIC chat, forge UNAVAILABLE . HTTP $(j -XPOST $BAD/local-optimistic/v1/chat/completions -H 'Content-Type: application/json' -d "$CHAT") backend=$(backend)"
|
|
echo " content=[$(content)]"
|
|
echo "8 healthz, forge UNAVAILABLE ......... HTTP $(j $BAD/healthz)"
|
|
echo " $(cut -c1-150 /tmp/b)"
|
|
echo "9 liveness, forge UNAVAILABLE ........ HTTP $(j $BAD/healthz/live)"
|
|
echo "10 readiness, forge UNAVAILABLE ....... HTTP $(j $BAD/healthz/ready)"
|
|
echo "11 streaming through forge ............ HTTP $(j -XPOST $GOOD/local-strict/v1/chat/completions -H 'Content-Type: application/json' -d '{"messages":[{"role":"user","content":"count to three"}],"max_tokens":200,"stream":true}') sse_chunks=$(grep -c '^data:' /tmp/b)"
|
|
echo "12 bare /v1 guard (expect 404) ........ HTTP $(j $GOOD/v1/models)"
|
|
echo "13 unknown mode guard (expect 404) .... HTTP $(j $GOOD/local-wishful/v1/models)"
|