Files
mtusi2026lab2/scripts/check_short_ttl.sh

31 lines
838 B
Bash

#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
backup=$(mktemp)
cp .env "$backup"
restore() {
cp "$backup" .env
rm -f "$backup"
docker compose --env-file .env up -d --force-recreate api
for attempt in $(seq 1 30); do
if curl -fsS http://localhost:8080/health/ready >/dev/null; then return; fi
sleep 2
done
return 1
}
trap restore EXIT
trap 'exit 130' INT
trap 'exit 143' TERM
if grep -q '^SESSION_TTL_SECONDS=' .env; then
sed -i 's/^SESSION_TTL_SECONDS=.*/SESSION_TTL_SECONDS=3/' .env
else
printf '\nSESSION_TTL_SECONDS=3\n' >> .env
fi
docker compose --env-file .env up -d --force-recreate api
for attempt in $(seq 1 30); do
if curl -fsS http://localhost:8080/health/ready >/dev/null; then break; fi
sleep 2
done
curl -fsS http://localhost:8080/health/ready >/dev/null
SESSION_TTL_SECONDS=3 python3 tests/expiry.py