#!/bin/sh
set -eu
compose="docker compose"
for dependency in docker curl node; do
if ! command -v "$dependency" >/dev/null 2>&1; then
echo "SKIP: $dependency is required for the database smoke"
exit 0
fi
done
if ! docker info >/dev/null 2>&1; then
echo "SKIP: Docker daemon is unavailable"
exit 0
fi
if ! curl --silent --show-error --connect-timeout 2 --output /dev/null \
'http://localhost:8080/api/user/info?id=0'; then
echo "SKIP: user-service is unavailable at http://localhost:8080"
exit 0
fi
if ! curl --fail --silent --show-error --connect-timeout 2 \
http://localhost:8082/health/ready >/dev/null; then
echo "SKIP: Aegida Gate is not ready at http://localhost:8082"
exit 0
fi
$compose up --build -d
cleanup() {
$compose down
}
trap cleanup EXIT INT TERM
for attempt in $(seq 1 30); do
if curl --fail --silent http://localhost:3000/api/health >/dev/null 2>&1; then
break
fi
sleep 2
done
smoke_email=${SMOKE_EMAIL:-demo@ai-control.local}
smoke_password=${SMOKE_PASSWORD:-Demo1234!}
token=$(curl --fail --silent \
--header 'Content-Type: application/json' \
--data "{\"email\":\"$smoke_email\",\"password\":\"$smoke_password\"}" \
http://localhost:3000/api/auth/login | \
node -e 'let data=""; process.stdin.on("data", chunk => data += chunk); process.stdin.on("end", () => process.stdout.write(JSON.parse(data).token));')
curl --fail --silent \
--header "Authorization: Bearer $token" \
http://localhost:3000/api/conversations
curl --fail --silent \
--header "Authorization: Bearer $token" \
http://localhost:3000/api/models
curl --fail --silent \
--header "Authorization: Bearer $token" \
'http://localhost:3000/api/me/quota?model=auto'