summaryrefslogtreecommitdiff
path: root/scripts/load-smoke.sh
diff options
context:
space:
mode:
authorChia <Chia@93.nz>2026-08-05 22:01:29 +1200
committerChia <Chia@93.nz>2026-08-05 22:07:50 +1200
commiteadb2ffe85c43cf6fc741c9823cd28eedb4a844c (patch)
tree1aba2536d57360da403aa35c9ced58b615c7064e /scripts/load-smoke.sh
parentcd0dd91ab93653631904f2ea0e574ccde6d60339 (diff)
feat: harden prepaid billing and commercial operations
Diffstat (limited to '')
-rwxr-xr-xscripts/load-smoke.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/scripts/load-smoke.sh b/scripts/load-smoke.sh
new file mode 100755
index 0000000..536edc1
--- /dev/null
+++ b/scripts/load-smoke.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+: "${AIGW_LOAD_BASE_URL:?AIGW_LOAD_BASE_URL is required}"
+: "${AIGW_LOAD_API_KEY:?AIGW_LOAD_API_KEY is required}"
+: "${AIGW_LOAD_MODEL:?AIGW_LOAD_MODEL is required}"
+requests="${AIGW_LOAD_REQUESTS:-1000}"
+concurrency="${AIGW_LOAD_CONCURRENCY:-50}"
+payload="$(mktemp)"
+results="$(mktemp)"
+trap 'rm -f -- "$payload" "$results"' EXIT
+chmod 600 "$payload" "$results"
+printf '{"model":"%s","messages":[{"role":"user","content":"health probe"}],"max_tokens":1}\n' "$AIGW_LOAD_MODEL" >"$payload"
+export AIGW_LOAD_BASE_URL AIGW_LOAD_API_KEY payload results
+seq "$requests" | xargs -P "$concurrency" -n 1 sh -c '
+ curl --silent --show-error --output /dev/null --write-out "%{http_code}\n" \
+ --header "Authorization: Bearer $AIGW_LOAD_API_KEY" --header "Content-Type: application/json" \
+ --data-binary "@$payload" "$AIGW_LOAD_BASE_URL/v1/chat/completions" >>"$results"
+' _
+failures="$(awk '$1 < 200 || $1 >= 300 { count++ } END { print count+0 }' "$results")"
+printf 'requests=%s concurrency=%s failures=%s\n' "$requests" "$concurrency" "$failures"
+test "$failures" -eq 0