выполнение лр2 на 4

This commit is contained in:
Ilya
2026-10-09 12:44:56 +03:00
parent e914e384fc
commit 13fa1852cb
30 changed files with 585 additions and 238 deletions
+1 -5
View File
@@ -1,4 +1,3 @@
"""Shared helpers for student tests: public client + direct access to the compose stack."""
import os
import subprocess
import sys
@@ -6,7 +5,7 @@ from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "tests"))
from client import Client, Failure, check # noqa: E402,F401
from client import Client, Failure, check
BASE_URL = os.environ.get("BASE_URL", "http://localhost:8080")
SHORT_TTL_URL = os.environ.get("SHORT_TTL_URL", "http://localhost:8081")
@@ -20,7 +19,6 @@ def ok(label):
def compose(*args, check_rc=True):
"""docker compose in the repository root; output is captured, never printed raw."""
proc = subprocess.run(["docker", "compose", *args], cwd=ROOT, capture_output=True, text=True)
if check_rc and proc.returncode != 0:
raise Failure("docker compose %s failed: %s" % (args[0], proc.stderr.strip()[-300:]))
@@ -28,12 +26,10 @@ def compose(*args, check_rc=True):
def psql(sql):
"""Run SQL inside the postgres container (local socket, no password on the wire)."""
return compose("exec", "-T", "postgres", "psql", "-U", "messenger", "-d", "messenger", "-tAX", "-c", sql).strip()
def valkey(*args):
"""valkey-cli with the password read inside the container, never on this host's argv."""
cmd = 'valkey-cli --no-auth-warning -a "$(sed -n "s/^requirepass //p" /run/secrets/valkey_conf)" "$@"'
return compose("exec", "-T", "valkey", "sh", "-c", cmd, "valkey-cli", *args).strip()