This commit is contained in:
41
scripts/docker-test.sh
Executable file
41
scripts/docker-test.sh
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/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."
|
||||
Reference in New Issue
Block a user