forked from mtusi2026/mtusi2026lab6
Лабораторная работа 6
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
"""Запуск собственных тестов, которые идут по HTTP через балансировщик.
|
||||
|
||||
python student-tests/run_all.py --base-url http://127.0.0.1:8080
|
||||
|
||||
Входит: API/auth/конкурентность (lab2), идемпотентность через реплики (lab3),
|
||||
race.py, вложения lab4 (test_attachments.py, lab5: 202 + ожидание ready), варианты lab5
|
||||
(test_pipeline.py). Отказы pipeline (test_pipeline_faults.py) здесь пропускаются — нужен доступ
|
||||
к БД/брокеру и стенд отказов: python scripts/ops.py pipeline-faults. Тест согласованности БД<->S3
|
||||
(test_attachment_consistency.py) здесь пропускается: нужен доступ к БД и S3 —
|
||||
python scripts/ops.py in-network consistency. Отдельно (меняют состояние стенда или нужен доступ к БД):
|
||||
python scripts/ops.py in-network storage # тесты хранилища внутри compose-сети
|
||||
python scripts/ops.py in-network expiry # истечение сессии (api-short-ttl)
|
||||
python student-tests/failover_series.py # остановка каждой реплики под нагрузкой
|
||||
python student-tests/rolling_update_load.py # rolling update под нагрузкой
|
||||
python student-tests/dependency_failure.py # отказ Redis/PostgreSQL (останавливает контейнеры)
|
||||
"""
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--base-url", default="http://127.0.0.1:8080")
|
||||
parser.add_argument("--expiry-url", default=os.environ.get("EXPIRY_BASE_URL", ""))
|
||||
parser.add_argument("--with-failures", action="store_true",
|
||||
help="run student-tests/dependency_failure.py (stops redis/postgres)")
|
||||
parser.add_argument("--failure-args", default="",
|
||||
help="extra arguments for dependency_failure.py (custom stop/start commands)")
|
||||
args = parser.parse_args()
|
||||
|
||||
env = os.environ.copy()
|
||||
env["BASE_URL"] = args.base_url.rstrip("/")
|
||||
if args.expiry_url:
|
||||
env["EXPIRY_BASE_URL"] = args.expiry_url.rstrip("/")
|
||||
|
||||
|
||||
def step(title, cmd):
|
||||
print("\n== " + title, flush=True)
|
||||
subprocess.run(cmd, env=env, check=True)
|
||||
|
||||
|
||||
step("API, auth, concurrency, idempotency tests (DB/expiry tests skip without their env)",
|
||||
[sys.executable, "-m", "unittest", "discover", "-s", "student-tests", "-p", "test_*.py", "-v"])
|
||||
step("Concurrent write test", [sys.executable, "student-tests/race.py", "--base-url", args.base_url])
|
||||
if args.with_failures:
|
||||
import shlex
|
||||
step("Dependency failure scenario",
|
||||
[sys.executable, "student-tests/dependency_failure.py", "--base-url", args.base_url]
|
||||
+ shlex.split(args.failure_args))
|
||||
|
||||
print("\nALL STUDENT TESTS PASSED", flush=True)
|
||||
Reference in New Issue
Block a user