Files
detections/run-tests.sh
T
Oleksandr Bezdieniezhnykh 86b8f076b7 Update health endpoint and refine test documentation
- Modified the health endpoint to return "None" for AI availability when inference is not initialized, improving clarity on system status.
- Enhanced the test documentation to include handling of skipped tests, emphasizing the need for investigation before proceeding.
- Updated test assertions to ensure proper execution order and prevent premature engine initialization.
- Refactored test cases to streamline performance testing and improve readability, removing unnecessary complexity.

These changes aim to enhance the robustness of the health check and improve the overall testing framework.
2026-03-30 01:17:53 +03:00

65 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
FIXTURES="$ROOT/e2e/fixtures"
LOADER_PORT=8080
ANNOTATIONS_PORT=8081
DETECTIONS_PORT=8000
PIDS=()
cleanup() {
for pid in "${PIDS[@]}"; do
kill "$pid" 2>/dev/null || true
done
wait 2>/dev/null
}
trap cleanup EXIT
for port in $LOADER_PORT $ANNOTATIONS_PORT $DETECTIONS_PORT; do
if lsof -ti :"$port" >/dev/null 2>&1; then
echo "ERROR: port $port is already in use" >&2
exit 1
fi
done
echo "Starting mock-loader on :$LOADER_PORT ..."
MODELS_ROOT="$FIXTURES" \
python -m gunicorn --bind "0.0.0.0:$LOADER_PORT" --workers 1 --timeout 120 \
'e2e.mocks.loader.app:app' >/dev/null 2>&1 &
PIDS+=($!)
echo "Starting mock-annotations on :$ANNOTATIONS_PORT ..."
python -m gunicorn --bind "0.0.0.0:$ANNOTATIONS_PORT" --workers 1 --timeout 120 \
'e2e.mocks.annotations.app:app' >/dev/null 2>&1 &
PIDS+=($!)
echo "Starting detections service on :$DETECTIONS_PORT ..."
LOADER_URL="http://localhost:$LOADER_PORT" \
ANNOTATIONS_URL="http://localhost:$ANNOTATIONS_PORT" \
python -m uvicorn main:app --host 0.0.0.0 --port "$DETECTIONS_PORT" \
--log-level warning >/dev/null 2>&1 &
PIDS+=($!)
echo "Waiting for services ..."
for url in \
"http://localhost:$DETECTIONS_PORT/health" \
"http://localhost:$LOADER_PORT/mock/status" \
"http://localhost:$ANNOTATIONS_PORT/mock/status"; do
for i in $(seq 1 30); do
if curl -sf "$url" >/dev/null 2>&1; then break; fi
if [ "$i" -eq 30 ]; then echo "ERROR: $url not ready" >&2; exit 1; fi
sleep 1
done
done
echo "All services ready. Running tests ..."
echo ""
BASE_URL="http://localhost:$DETECTIONS_PORT" \
MOCK_LOADER_URL="http://localhost:$LOADER_PORT" \
MOCK_ANNOTATIONS_URL="http://localhost:$ANNOTATIONS_PORT" \
MEDIA_DIR="$FIXTURES" \
python -m pytest e2e/tests/ -v --tb=short "$@"