forked from mtusi2026/mtusi2026lab2
52 lines
1.8 KiB
Bash
Executable File
52 lines
1.8 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
|
|
|
|
# Do not overwrite evidence/ with failures of a stand that is not running.
|
|
if ! curl -fsS --max-time 5 http://localhost:8080/health/ready >/dev/null 2>&1 || ! curl -fsS --max-time 5 http://localhost:8081/health/ready >/dev/null 2>&1; then
|
|
echo "API is not running. Start it first:" >&2
|
|
echo " docker compose --profile tests up -d --build api api_short_ttl" >&2
|
|
exit 1
|
|
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
|