mirror of
https://github.com/azaion/loader.git
synced 2026-04-22 10:16:32 +00:00
Quality cleanup refactoring
Made-with: Cursor
This commit is contained in:
+26
-22
@@ -1,39 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
set -uo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
COMPOSE_FILE="$PROJECT_DIR/e2e/docker-compose.test.yml"
|
||||
|
||||
cleanup() {
|
||||
if [[ -n "${SUT_PID:-}" ]]; then
|
||||
kill "$SUT_PID" 2>/dev/null || true
|
||||
wait "$SUT_PID" 2>/dev/null || true
|
||||
fi
|
||||
echo "=== Tearing down Docker services ==="
|
||||
docker compose -f "$COMPOSE_FILE" down --timeout 10
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
cd "$PROJECT_DIR"
|
||||
|
||||
UNIT_ONLY=false
|
||||
if [[ "${1:-}" == "--unit-only" ]]; then
|
||||
UNIT_ONLY=true
|
||||
pip3 install -q -r e2e/requirements.txt
|
||||
|
||||
echo "=== Starting Docker services ==="
|
||||
docker compose -f "$COMPOSE_FILE" up -d --build
|
||||
|
||||
echo "=== Waiting for system-under-test ==="
|
||||
DEADLINE=$((SECONDS + 60))
|
||||
while [[ $SECONDS -lt $DEADLINE ]]; do
|
||||
if curl -sf http://localhost:8080/health > /dev/null 2>&1; then
|
||||
echo "system-under-test is ready"
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
if ! curl -sf http://localhost:8080/health > /dev/null 2>&1; then
|
||||
echo "ERROR: system-under-test did not become healthy within 60s"
|
||||
docker compose -f "$COMPOSE_FILE" logs system-under-test
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pip install -q -r requirements.txt
|
||||
python setup.py build_ext --inplace 2>&1 | tail -1
|
||||
|
||||
if [[ -f requirements-test.txt ]]; then
|
||||
pip install -q -r requirements-test.txt
|
||||
fi
|
||||
|
||||
if [[ "$UNIT_ONLY" == true ]]; then
|
||||
echo "=== Running unit tests only ==="
|
||||
pytest tests/ -v --tb=short -m "not e2e" --junitxml=test-results/results.xml
|
||||
else
|
||||
echo "=== Running all tests ==="
|
||||
pytest tests/ -v --tb=short --junitxml=test-results/results.xml
|
||||
fi
|
||||
mkdir -p "$PROJECT_DIR/test-results"
|
||||
|
||||
echo "=== Running e2e tests ==="
|
||||
python3 -m pytest e2e/tests/ -v --tb=short --junitxml=test-results/results.xml
|
||||
EXIT_CODE=$?
|
||||
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user