item-atlas/deploy/local/ci-smoke.sh

43 lines
1.8 KiB
Bash
Executable File

#!/bin/sh
set -eu
trap 'for service_pid in $service_pids; do kill "$service_pid" 2>/dev/null || true; done' EXIT
service_pids=""
for try_number in $(seq 1 30); do
if pg_isready -h postgres -U postgres; then break; fi
sleep 1
done
psql -h postgres -U postgres -d postgres -v ON_ERROR_STOP=1 <<'SQL'
CREATE ROLE atlas_inventory LOGIN;
CREATE ROLE atlas_intake LOGIN;
CREATE DATABASE itematlas_inventory OWNER atlas_inventory;
CREATE DATABASE itematlas_intake OWNER atlas_intake;
SQL
export SPRING_PROFILES_ACTIVE=local ATLAS_DB_PASSWORD="" JAVA_TOOL_OPTIONS="-Xmx192m"
ATLAS_DB_USER=atlas_inventory ATLAS_DB_URL=jdbc:postgresql://postgres:5432/itematlas_inventory \
java -jar backend/inventory-service/target/app.jar > /tmp/atlas-inventory.log 2>&1 &
service_pids="$!"
ATLAS_DB_USER=atlas_intake ATLAS_DB_URL=jdbc:postgresql://postgres:5432/itematlas_intake \
java -jar backend/intake-service/target/app.jar > /tmp/atlas-intake.log 2>&1 &
service_pids="$service_pids $!"
java -jar backend/gateway/target/app.jar > /tmp/atlas-gateway.log 2>&1 &
service_pids="$service_pids $!"
export ATLAS_SMOKE_INTAKE_DSN="postgresql://postgres@postgres/itematlas_intake"
export ATLAS_SMOKE_INVENTORY_DSN="postgresql://postgres@postgres/itematlas_inventory"
export ATLAS_SMOKE_METRIC_TARGETS="http://127.0.0.1:8080,http://127.0.0.1:8081,http://127.0.0.1:8082"
if ! python3 backend/tests/smoke.py; then
tail -80 /tmp/atlas-inventory.log /tmp/atlas-intake.log /tmp/atlas-gateway.log
exit 1
fi
psql "$ATLAS_SMOKE_INVENTORY_DSN" -v ON_ERROR_STOP=1 <<'SQL'
INSERT INTO native_account(username, subject, password_hash)
VALUES ('viewer', 'viewer', 'ci-basic-auth-fixture');
SQL
if ! python3 backend/tests/ios_experience_smoke.py; then
tail -80 /tmp/atlas-inventory.log /tmp/atlas-intake.log /tmp/atlas-gateway.log
exit 1
fi