ЛР 2: PostgreSQL, Redis-сессии и проверки на оценку 4
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Separate API container with 2 second TTL; main API configuration is unchanged."""
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
command = ['docker', 'compose', 'run', '-d', '--no-deps', '-e', 'SESSION_TTL_SECONDS=2', 'api']
|
||||
identifier = subprocess.check_output(command, cwd=root, text=True).strip()
|
||||
try:
|
||||
# Start the client in the temporary container after its HTTP server is ready.
|
||||
subprocess.run(['docker', 'exec', identifier, 'python', '-c',
|
||||
"import time,urllib.request; "
|
||||
"\nfor _ in range(50):\n try:\n urllib.request.urlopen('http://localhost:8080/health/ready',timeout=3); break"
|
||||
"\n except OSError: time.sleep(.2)\nelse: raise RuntimeError('API not ready')"], check=True)
|
||||
subprocess.run(['docker', 'exec', identifier, 'python', 'student-tests/test_expiry.py'], check=True)
|
||||
finally:
|
||||
subprocess.run(['docker', 'rm', '-f', identifier], check=True, stdout=subprocess.DEVNULL)
|
||||
Reference in New Issue
Block a user