Files
satellite-provider/scripts/run-tests.sh
T
Oleksandr Bezdieniezhnykh cc0a876168 [AZ-AUTODEV] Step 7 (Run Tests): smoke profile + green run
Add a fast integration profile so Step 7 (and future autodev
re-entries) can verify the full stack in ~2 min instead of ~15 min,
without losing access to the long-running coverage when needed.

- TestRunMode.cs: smoke flag + tightened poll/timeout values.
- Program.cs: env var INTEGRATION_TESTS_MODE / --smoke|--full CLI
  switch; smoke runs Tile + 200m region + simple route + ZIP route +
  Security; full keeps the existing sequence.
- RegionTests / ExtendedRouteTests: read timeouts from TestRunMode
  instead of hardcoding 120/180/360.
- docker-compose.tests.yml: forwards INTEGRATION_TESTS_MODE to the
  integration-tests container (default 'full').
- scripts/run-tests.sh: adds --unit-only / --smoke / --full flags,
  loads .env automatically, fails fast if GOOGLE_MAPS_API_KEY is
  missing.

Step 7 result: all tests passed in 111.86 s wall-clock (35/35 unit +
5/5 smoke integration scenarios incl. SEC-01..04). Report saved to
_docs/03_implementation/test_run_step7.md.

State advanced to Step 8 (Refactor).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-10 05:29:10 +03:00

76 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
cleanup() {
docker compose -f "$PROJECT_ROOT/docker-compose.yml" -f "$PROJECT_ROOT/docker-compose.tests.yml" down --remove-orphans || true
}
trap cleanup EXIT
usage() {
cat <<EOF
Usage: $(basename "$0") [--unit-only | --smoke | --full]
Modes:
--unit-only Run only the .NET unit test project (no Docker Compose, no integration tests)
--smoke Run unit tests + a fast integration subset (~2 min target, tightened timeouts)
--full Run unit tests + the full integration suite (default if no flag is provided)
Environment:
GOOGLE_MAPS_API_KEY Required for any integration test mode (loaded from .env or shell env).
EOF
}
mode="full"
case "${1:-}" in
--unit-only) mode="unit"; ;;
--smoke) mode="smoke"; ;;
--full) mode="full"; ;;
-h|--help) usage; exit 0; ;;
"") ;;
*) echo "Unknown argument: $1"; usage; exit 2; ;;
esac
echo "=== Satellite Provider Test Suite ==="
echo "Mode: $mode"
echo ""
if [[ "$mode" == "unit" ]]; then
echo "Running unit tests only..."
docker run --rm -v "$PROJECT_ROOT:/src" -w /src mcr.microsoft.com/dotnet/sdk:8.0 \
dotnet test SatelliteProvider.Tests/SatelliteProvider.Tests.csproj \
--no-restore --configuration Release \
--logger "console;verbosity=normal"
echo ""
echo "=== Unit tests complete ==="
exit 0
fi
if [[ -z "${GOOGLE_MAPS_API_KEY:-}" ]] && [[ -f "$PROJECT_ROOT/.env" ]]; then
set -o allexport
# shellcheck disable=SC1091
source "$PROJECT_ROOT/.env"
set +o allexport
fi
if [[ -z "${GOOGLE_MAPS_API_KEY:-}" ]]; then
echo "ERROR: GOOGLE_MAPS_API_KEY is not set (export it or add to .env). Integration tests will fail."
exit 3
fi
echo "Step 1: Unit tests"
docker run --rm -v "$PROJECT_ROOT:/src" -w /src mcr.microsoft.com/dotnet/sdk:8.0 \
sh -c "dotnet restore SatelliteProvider.sln && dotnet test SatelliteProvider.Tests/SatelliteProvider.Tests.csproj --no-restore --configuration Release --logger 'console;verbosity=normal'"
echo ""
echo "Step 2: Integration tests (Docker Compose, mode=$mode)"
INTEGRATION_TESTS_MODE="$mode" docker compose \
-f "$PROJECT_ROOT/docker-compose.yml" \
-f "$PROJECT_ROOT/docker-compose.tests.yml" \
up --build --abort-on-container-exit --exit-code-from integration-tests
echo ""
echo "=== All tests passed (mode=$mode) ==="