"""Temporarily use a two-second TTL, then restore both API configurations.""" import os from pathlib import Path import subprocess import sys os.chdir(Path(__file__).resolve().parents[1]) base = os.environ.get('BASE_URL', 'http://localhost:' + os.environ.get('LAB3_HOST_PORT', '8080')) compose = ['docker', 'compose', '--env-file', '.env', 'up', '-d', '--no-deps', '--force-recreate', '--wait', '--wait-timeout', '60', 'api1', 'api2'] normal = dict(os.environ, BASE_URL=base) short = dict(normal, SESSION_TTL_SECONDS='2') try: subprocess.run(compose, env=short, check=True, timeout=90) subprocess.run([sys.executable, 'scripts/wait_replicas.py'], env=short, check=True) subprocess.run([sys.executable, 'tests/student_tests.py', '--base-url', base, '--expiry'], env=short, check=True) finally: subprocess.run(compose, env=normal, check=True, timeout=90) subprocess.run([sys.executable, 'scripts/wait_replicas.py'], env=normal, check=True) print('PASS: session expiration tested with TTL=2; original API settings restored')