Files
mtusi2026lab2/scripts/run_evidence.sh
T
2026-09-30 12:13:29 +03:00

45 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
# Collects lab2 evidence from a running stand:
# docker compose --profile tests up -d --build api api_short_ttl
# sh scripts/run_evidence.sh
# Output contains only synthetic data and aggregates, never tokens/secrets.
set -eu
cd "$(dirname "$0")/.."
mkdir -p evidence
PYTHON="${PYTHON:-python3}"
if [ -x .venv-wsl/bin/python3 ]; then PYTHON=.venv-wsl/bin/python3; fi
if [ -x .venv/bin/python3 ]; then PYTHON=.venv/bin/python3; fi
containers() {
docker compose ps -a --format '{{.Service}}\t{{.State}}\t{{.Status}}\t{{.CreatedAt}}'
}
"$PYTHON" scripts/check_contract.py | tee evidence/check_contract.txt
"$PYTHON" scripts/validate_openapi.py | tee evidence/validate_openapi.txt
"$PYTHON" tests/smoke.py --base-url http://localhost:8080 | tee evidence/smoke.txt
{
echo "## containers before restart hook"
containers
"$PYTHON" tests/resilience.py \
--base-url http://localhost:8080 \
--action-script scripts/restart.sh \
--mode persistence
echo "## containers after restart hook (Status shows new uptime)"
containers
} 2>&1 | tee evidence/persistence.txt
docker compose run --rm migrate 2>/dev/null | tee evidence/migrations_repeat.txt
"$PYTHON" student-tests/level4.py | tee evidence/level4.txt
docker compose --profile tools run --rm db_checks 2>/dev/null \
| tee evidence/explain.txt
"$PYTHON" tests/load.py \
--base-url http://localhost:8080 \
--duration 15 \
--concurrency 4 \
--output evidence/load.json | tee evidence/load.txt