Files
mtusi2026lab2/scripts/test_short_ttl.sh
T

51 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
restore_api() {
echo "Restoring API with SESSION_TTL_SECONDS=3600..."
SESSION_TTL_SECONDS=3600 \
docker compose up -d --force-recreate --no-deps api
}
trap restore_api EXIT
echo "Starting API with SESSION_TTL_SECONDS=2..."
SESSION_TTL_SECONDS=2 \
docker compose up -d --force-recreate --no-deps api
echo "Checking API configuration..."
actual_ttl=$(docker compose exec -T api printenv SESSION_TTL_SECONDS)
if [[ "$actual_ttl" != "2" ]]; then
echo "Expected SESSION_TTL_SECONDS=2, got $actual_ttl" >&2
exit 1
fi
echo "Waiting for API readiness..."
ready=false
for attempt in $(seq 1 30); do
if curl --silent --fail \
http://localhost:8080/health/ready > /dev/null; then
ready=true
break
fi
sleep 1
done
if [[ "$ready" != "true" ]]; then
echo "API did not become ready." >&2
exit 1
fi
echo "Running short TTL test..."
python tests_student/test_short_ttl.py
echo "PASS: short session TTL test completed."