This commit is contained in:
+3
-3
@@ -10,9 +10,9 @@ REM Выходите из программы с кодом 0 только пос
|
||||
REM Уровень 4: перезапуск API, PostgreSQL и Redis. Тома не трогаем.
|
||||
docker compose --env-file .env restart api postgres redis >nul 2>&1
|
||||
if errorlevel 1 (
|
||||
docker restart mtusi-messenger-lab2 >nul 2>&1
|
||||
docker restart mtusi-postgres >nul 2>&1
|
||||
docker restart mtusi-redis >nul 2>&1
|
||||
docker restart mtuci-messenger-lab2 >nul 2>&1
|
||||
docker restart mtuci-postgres >nul 2>&1
|
||||
docker restart mtuci-redis >nul 2>&1
|
||||
)
|
||||
set /a i=0
|
||||
:wait_loop
|
||||
|
||||
+3
-3
@@ -8,9 +8,9 @@ set -eu
|
||||
|
||||
# Уровень 4: перезапускаем API, PostgreSQL и Redis. Тома (postgres-data, redis-data) не трогаем.
|
||||
docker compose --env-file .env restart api postgres redis >/dev/null 2>&1 || {
|
||||
docker restart mtusi-messenger-lab2 >/dev/null 2>&1 || true
|
||||
docker restart mtusi-postgres >/dev/null 2>&1 || true
|
||||
docker restart mtusi-redis >/dev/null 2>&1 || true
|
||||
docker restart mtuci-messenger-lab2 >/dev/null 2>&1 || true
|
||||
docker restart mtuci-postgres >/dev/null 2>&1 || true
|
||||
docker restart mtuci-redis >/dev/null 2>&1 || true
|
||||
}
|
||||
# Ждём readiness
|
||||
i=0
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
Перед запуском:
|
||||
1) в .env выставить SESSION_TTL_SECONDS=5
|
||||
2) docker compose --env-file .env up -d --force-recreate api
|
||||
3) docker exec mtusi-redis redis-cli flushdb
|
||||
3) docker exec mtuci-redis redis-cli flushdb
|
||||
4) python student-tests/test_lab2_level4.py --base-url http://localhost:8080
|
||||
5) перед smoke/persistence вернуть SESSION_TTL_SECONDS=3600 и снова up -d --force-recreate api
|
||||
|
||||
@@ -29,9 +29,8 @@ from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "tests"))
|
||||
from client import Client, Failure, arguments, check, run # noqa: E402
|
||||
|
||||
# Имя compose-сети проекта: <папка-проекта>_default.
|
||||
# Проверить: docker network ls | findstr default
|
||||
COMPOSE_NETWORK = os.environ.get("COMPOSE_NETWORK", "mtusi2026lab2_default")
|
||||
# Имя compose-сети проекта: mtuci2026lab2_default (зафиксировано в compose.yaml networks.default.name).
|
||||
COMPOSE_NETWORK = os.environ.get("COMPOSE_NETWORK", "mtuci2026lab2_default")
|
||||
|
||||
|
||||
# ---------- 1. Конкурентная регистрация одинакового username ----------
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
после restore проверяем, что их нет.
|
||||
|
||||
Все psql-вызовы идут через docker run postgres:18-alpine в compose-сети проекта
|
||||
(--network <project>_default), DSN указывает на хост postgres.
|
||||
(--network mtuci2026lab2_default), DSN указывает на хост postgres.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
@@ -37,9 +37,8 @@ EVIDENCE.mkdir(exist_ok=True)
|
||||
|
||||
SEED_SQL = ROOT / "student-tests" / "track2_seed.sql"
|
||||
|
||||
# Имя compose-сети проекта: <папка-проекта>_default.
|
||||
# Проверить: docker network ls | findstr default
|
||||
COMPOSE_NETWORK = os.environ.get("COMPOSE_NETWORK", "mtusi2026lab2_default")
|
||||
# Имя compose-сети проекта: mtuci2026lab2_default (зафиксировано в compose.yaml networks.default.name).
|
||||
COMPOSE_NETWORK = os.environ.get("COMPOSE_NETWORK", "mtuci2026lab2_default")
|
||||
|
||||
|
||||
# ---------- helpers ----------
|
||||
@@ -244,7 +243,7 @@ def step_backup_restore(dsn: str):
|
||||
|
||||
# новый контейнер как отдельное хранилище — в той же compose-сети,
|
||||
# порт наружу не публикуем
|
||||
restore_container = "mtusi-pg-restore"
|
||||
restore_container = "mtuci-pg-restore"
|
||||
subprocess.run(["docker", "rm", "-f", restore_container], capture_output=True)
|
||||
subprocess.run(
|
||||
["docker", "run", "-d", "--name", restore_container,
|
||||
@@ -273,7 +272,7 @@ def step_backup_restore(dsn: str):
|
||||
"--network", COMPOSE_NETWORK,
|
||||
"-v", f"{EVIDENCE}:/in",
|
||||
"postgres:18-alpine",
|
||||
"pg_restore", "-d", "postgresql://postgres:restore@mtusi-pg-restore:5432/high_load_messenger",
|
||||
"pg_restore", "-d", "postgresql://postgres:restore@mtuci-pg-restore:5432/high_load_messenger",
|
||||
"--no-owner", "--no-privileges", "/in/lab2_track2_dump.dump"],
|
||||
capture_output=True, text=True, timeout=600,
|
||||
)
|
||||
@@ -373,7 +372,7 @@ def step_rpo(dsn: str, base_url: str, ca_file):
|
||||
check(code == 0, "pg_dump для RPO упал")
|
||||
|
||||
# Временный restore-контейнер: в compose-сети, без публикации портов.
|
||||
restore_container = "mtusi-pg-rpo"
|
||||
restore_container = "mtuci-pg-rpo"
|
||||
subprocess.run(["docker", "rm", "-f", restore_container], capture_output=True)
|
||||
subprocess.run(
|
||||
["docker", "run", "-d", "--name", restore_container,
|
||||
@@ -401,7 +400,7 @@ def step_rpo(dsn: str, base_url: str, ca_file):
|
||||
"-v", f"{EVIDENCE}:/in",
|
||||
"postgres:18-alpine",
|
||||
"pg_restore", "-d",
|
||||
"postgresql://postgres:restore@mtusi-pg-rpo:5432/high_load_messenger",
|
||||
"postgresql://postgres:restore@mtuci-pg-rpo:5432/high_load_messenger",
|
||||
"--no-owner", "--no-privileges", "/in/lab2_track2_rpo.dump"],
|
||||
capture_output=True, text=True, timeout=600,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user