finished
Skeleton contracts / contracts (pull_request) Canceled after 0s
Skeleton contracts / application (pull_request) Canceled after 0s

This commit is contained in:
2026-11-06 20:40:12 +03:00
parent 65003b6119
commit 7329d94740
31 changed files with 1662 additions and 4 deletions
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env python3
"""Restart API, PostgreSQL and Redis without removing named volumes."""
from pathlib import Path
import subprocess
import sys
ROOT = Path(__file__).resolve().parents[1]
def main() -> int:
env_file = ROOT / ".env"
cmd = ["docker", "compose"]
if env_file.is_file():
cmd.extend(["--env-file", str(env_file)])
cmd.extend(["restart", "postgres", "redis", "api"])
proc = subprocess.run(cmd, cwd=ROOT)
return proc.returncode
if __name__ == "__main__":
sys.exit(main())
+9
View File
@@ -0,0 +1,9 @@
#!/bin/sh
set -eu
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
cd "$ROOT"
if [ -f .env ]; then
docker compose --env-file .env restart postgres redis api
else
docker compose restart postgres redis api
fi
+51
View File
@@ -0,0 +1,51 @@
#!/usr/bin/env python3
"""Recreate API with SESSION_TTL_SECONDS=2, test expiry, restore TTL."""
import os
import subprocess
import sys
import time
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def compose(args, extra_env=None):
env = os.environ.copy()
if extra_env:
env.update(extra_env)
cmd = ["docker", "compose"]
if (ROOT / ".env").is_file():
cmd.extend(["--env-file", str(ROOT / ".env")])
cmd.extend(args)
proc = subprocess.run(cmd, cwd=ROOT, env=env)
if proc.returncode != 0:
raise SystemExit(proc.returncode)
def wait_ready():
import urllib.request
deadline = time.monotonic() + 90
while time.monotonic() < deadline:
try:
urllib.request.urlopen("http://127.0.0.1:8080/health/ready", timeout=2)
return
except Exception:
time.sleep(0.5)
raise SystemExit("API did not become ready")
def main():
compose(["up", "-d", "--no-deps", "--force-recreate", "api"], {"SESSION_TTL_SECONDS": "2"})
wait_ready()
env = os.environ.copy()
env["SESSION_TTL_SECONDS"] = "2"
env["RUN_EXPIRY"] = "1"
proc = subprocess.run([sys.executable, str(ROOT / "student-tests" / "expiry.py")], cwd=ROOT, env=env)
compose(["up", "-d", "--no-deps", "--force-recreate", "api"], {"SESSION_TTL_SECONDS": "3600"})
wait_ready()
raise SystemExit(proc.returncode)
if __name__ == "__main__":
main()