forked from mtusi2026/mtusi2026lab5
ЛР 5 — БВТ2302 — Лебедев — на 5
This commit is contained in:
@@ -28,3 +28,111 @@ test-persistence:
|
||||
test-failover:
|
||||
@test -n "$(ACTION_SCRIPT)" || (echo "Set ACTION_SCRIPT to your implemented executable stop-one hook"; exit 2)
|
||||
$(PYTHON) tests/resilience.py --mode failover --action-script "$(ACTION_SCRIPT)" --base-url "$(BASE_URL)" $(TLS_ARGS)
|
||||
|
||||
# ---------------------------------------------------------------------------------------------
|
||||
# Цели решения (lab5). Публичные цели выше не изменены.
|
||||
# ---------------------------------------------------------------------------------------------
|
||||
COMPOSE ?= docker compose --env-file .env
|
||||
IN_WORKER = $(COMPOSE) run --rm --no-deps -T -v "$(CURDIR)/student-tests:/app/student-tests:ro" --entrypoint python worker
|
||||
IN_API = $(COMPOSE) run --rm --no-deps -T -v "$(CURDIR)/student-tests:/app/student-tests:ro" --entrypoint python api
|
||||
|
||||
.PHONY: secrets up down ps logs destroy-data restore stop-worker start-worker restart-api-broker s3-check \
|
||||
jobs-failed jobs-invariants test-student test-pipeline test-imgproc test-jobs-failures test-track2 \
|
||||
chaos test-attachments test-storage-failures test-api test-idempotency test-expiry test-cache-race \
|
||||
test-failures upload-memory evidence
|
||||
|
||||
secrets:
|
||||
./scripts/init-secrets.sh
|
||||
|
||||
# Единая команда запуска: LB + 2 API + 2 worker + migrate/s3-init/broker-init (one-shot) + PostgreSQL + Redis + S3 + NATS.
|
||||
up: secrets
|
||||
$(COMPOSE) --profile ttl up -d --build --wait
|
||||
|
||||
ps:
|
||||
$(COMPOSE) --profile ttl --profile fault ps -a
|
||||
|
||||
logs:
|
||||
$(COMPOSE) logs --tail=100 lb api worker nats
|
||||
|
||||
# Безопасная остановка: контейнеры удаляются, volumes pgdata, s3data и natsdata сохраняются.
|
||||
down:
|
||||
$(COMPOSE) --profile ttl --profile fault down
|
||||
|
||||
# НАМЕРЕННОЕ удаление учебных данных (volumes pgdata, s3data, natsdata). Необратимо.
|
||||
destroy-data:
|
||||
@echo "This deletes ALL lab5 data volumes (PostgreSQL + S3 + NATS). Type 'yes' to continue:"; read ans; [ "$$ans" = yes ]
|
||||
$(COMPOSE) --profile ttl --profile fault down -v
|
||||
|
||||
# Вернуть реплики API после make test-failover ACTION_SCRIPT=scripts/stop-one.sh
|
||||
restore:
|
||||
./scripts/start-replicas.sh
|
||||
|
||||
# Сценарий защиты: остановить/запустить worker; перезапустить API и брокер (volumes сохраняются).
|
||||
stop-worker:
|
||||
./scripts/stop-worker.sh
|
||||
|
||||
start-worker:
|
||||
./scripts/start-worker.sh
|
||||
|
||||
restart-api-broker:
|
||||
./scripts/restart-api-broker.sh
|
||||
|
||||
s3-check:
|
||||
$(COMPOSE) exec -T api python -m messenger s3-check
|
||||
|
||||
# Реестр failed (DLQ) и проверка инвариантов pipeline.
|
||||
jobs-failed:
|
||||
$(COMPOSE) exec -T api python -m messenger jobs failed
|
||||
|
||||
jobs-invariants:
|
||||
$(COMPOSE) exec -T api python -m messenger jobs invariants --settled --verify-bytes
|
||||
|
||||
test-pipeline:
|
||||
$(PYTHON) student-tests/test_pipeline.py
|
||||
|
||||
# Правила вариантов и лимиты worker — внутри образа (нужен Pillow).
|
||||
test-imgproc:
|
||||
$(IN_WORKER) student-tests/test_imgproc.py
|
||||
|
||||
# Останавливает/запускает worker, брокер и реплики API, профиль fault. Volumes не трогает. ≈ 6 мин.
|
||||
test-jobs-failures:
|
||||
$(PYTHON) student-tests/test_jobs_failures.py
|
||||
|
||||
# Трек 2: автоматическая инъекция отказов (дубли, reorder, crash, версии) + инварианты. ≈ 3 мин.
|
||||
test-track2:
|
||||
$(PYTHON) student-tests/test_pipeline_idempotency.py
|
||||
|
||||
# Трек 2: рандомизированный хаос-прогон (три seed).
|
||||
chaos:
|
||||
mkdir -p evidence/track2
|
||||
for s in 1 2 3; do $(PYTHON) research/track2_chaos.py --seed $$s --uploads 60 --output evidence/track2/chaos-seed$$s.json || exit 1; done
|
||||
|
||||
test-attachments:
|
||||
$(PYTHON) student-tests/test_attachments.py
|
||||
|
||||
test-storage-failures:
|
||||
$(PYTHON) student-tests/test_storage_failures.py
|
||||
|
||||
test-api:
|
||||
$(PYTHON) student-tests/test_api.py
|
||||
|
||||
test-idempotency:
|
||||
$(PYTHON) student-tests/test_idempotency.py
|
||||
|
||||
test-expiry:
|
||||
$(PYTHON) student-tests/test_expiry.py
|
||||
|
||||
test-cache-race:
|
||||
$(IN_API) student-tests/test_cache_race.py
|
||||
|
||||
test-failures:
|
||||
$(PYTHON) student-tests/test_failures.py
|
||||
|
||||
test-student: test-pipeline test-imgproc test-attachments test-api test-idempotency test-expiry test-cache-race \
|
||||
test-jobs-failures test-storage-failures test-failures test-track2
|
||||
|
||||
upload-memory:
|
||||
$(PYTHON) research/upload_memory.py --output evidence/upload-memory.json
|
||||
|
||||
evidence:
|
||||
./scripts/collect-evidence.sh
|
||||
|
||||
Reference in New Issue
Block a user