summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/smoke.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/smoke.sh b/tests/smoke.sh
new file mode 100755
index 0000000..a5ef23d
--- /dev/null
+++ b/tests/smoke.sh
@@ -0,0 +1,38 @@
1#!/usr/bin/env bash
2# Smoke test for the OpenAI-compatible LLM endpoint.
3# Usage:
4# ENDPOINT=http://llm.dev.localtest.me:8080 MODEL=Qwen2.5-0.5B-Instruct ./tests/smoke.sh
5set -euo pipefail
6
7ENDPOINT="${ENDPOINT:-http://llm.dev.localtest.me:8080}"
8MODEL="${MODEL:-Qwen2.5-0.5B-Instruct}"
9TIMEOUT="${TIMEOUT:-120}"
10
11say() { printf '\033[1;34m==>\033[0m %s\n' "$*"; }
12fail() { printf '\033[1;31mFAIL\033[0m %s\n' "$*" >&2; exit 1; }
13
14say "Endpoint: $ENDPOINT"
15say "Model: $MODEL"
16
17say "GET /v1/models"
18models_json="$(curl -fsS --max-time "$TIMEOUT" "$ENDPOINT/v1/models")" || fail "/v1/models unreachable"
19echo "$models_json" | grep -q "$MODEL" || fail "/v1/models does not list $MODEL"
20
21say "POST /v1/chat/completions"
22resp="$(curl -fsS --max-time "$TIMEOUT" "$ENDPOINT/v1/chat/completions" \
23 -H 'Content-Type: application/json' \
24 -d "$(cat <<EOF
25{
26 "model": "$MODEL",
27 "messages": [{"role": "user", "content": "Reply with the single word: pong"}],
28 "max_tokens": 8,
29 "temperature": 0
30}
31EOF
32)")" || fail "chat completion request failed"
33
34content="$(echo "$resp" | python3 -c 'import sys, json; print(json.load(sys.stdin)["choices"][0]["message"]["content"])')"
35echo "model reply: $content"
36[[ -n "$content" ]] || fail "empty completion content"
37
38say "OK"