Files
App/scripts/docker-test.sh
HiepLM c05b1d5f5c
Some checks failed
Test / test (push) Has been cancelled
Clean and Test làn 3
2026-06-13 14:04:56 +07:00

42 lines
1021 B
Bash
Executable File

#!/usr/bin/env bash
# Build image, start container, chạy smoke + pytest trên port 8080.
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
# shellcheck source=docker-lib.sh
source "$ROOT/scripts/docker-lib.sh"
docker_cmd
BASE="${TEST_BASE_URL:-http://127.0.0.1:8080}"
echo "==> Docker compose up --build -d"
"${DOCKER[@]}" compose up --build -d
echo "==> Đợi server sẵn sàng ($BASE)"
for i in $(seq 1 40); do
if curl -sf "$BASE/api/health" >/dev/null 2>&1; then
break
fi
sleep 0.5
done
if ! curl -sf "$BASE/api/health" >/dev/null 2>&1; then
echo "Container không phản hồi tại $BASE" >&2
"${DOCKER[@]}" logs --tail 30 lidar-manager-limited 2>&1 || true
exit 1
fi
echo "==> Unit + integration tests (local build)"
./scripts/run-tests.sh
echo "==> API smoke (container $BASE)"
./scripts/api-smoke.sh "$BASE"
echo "==> pytest (container $BASE)"
TEST_BASE_URL="$BASE" python3 -m pytest tests/test_api_integration.py -q
echo
echo "Docker + tests OK."