forked from mtusi2026/mtusi2026lab5
перенос: реализация lab4 без изменений (API, миграции 0001-0004, HAProxy, Valkey, SeaweedFS, тесты)
Скопировано из mtusi2026lab4 (ветка solution/bvt2302-bodanyuk, commit 17c33cd) через git archive: исходники, миграции, собственные тесты, Dockerfile, compose, конфигурации infra/, скрипты и bench/. README, COURSE, contracts/, tests/ и отчёт lab4 не копировались. Makefile и .env.example — версии lab4 (skeleton-часть совпадает с lab5, строки broker добавляются в следующих коммитах). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
276dbdad8a
commit
5112be83cc
@@ -28,3 +28,70 @@ 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)
|
||||
# ---------------------------------------------------------------------------
|
||||
# Student solution (lab 4, Python). On Windows: PowerShell/Git Bash with GNU make, public
|
||||
# tests need PYTHONUTF8=1, and the hooks are started through scripts/*.cmd (Git Bash).
|
||||
.PHONY: secrets up down logs ps migrate student-test unit-test explain lb-status restore rolling-update failover-series reconcile reconcile-apply bench-memory bench-reconcile
|
||||
|
||||
secrets:
|
||||
$(PYTHON) scripts/init_secrets.py
|
||||
|
||||
# Build, apply migrations ONCE (service migrate), start API replicas and the LB, wait for healthy.
|
||||
up: secrets
|
||||
docker compose up -d --build --wait
|
||||
|
||||
# Safe stop: containers stop, named volumes (data) stay.
|
||||
down:
|
||||
docker compose down
|
||||
|
||||
logs:
|
||||
docker compose logs --tail 50 api lb
|
||||
|
||||
ps:
|
||||
docker compose ps -a
|
||||
|
||||
migrate:
|
||||
docker compose run --rm migrate
|
||||
|
||||
# HAProxy view of the replicas (UP/DOWN) mapped to containers and X-Instance-Id.
|
||||
lb-status:
|
||||
$(PYTHON) scripts/lbctl.py status
|
||||
$(PYTHON) scripts/lbctl.py replicas
|
||||
|
||||
# Start replicas stopped by scripts/stop-one.sh again and wait until the LB has them all UP.
|
||||
restore:
|
||||
sh scripts/restore-api.sh
|
||||
$(PYTHON) scripts/lbctl.py wait-up $${API_REPLICAS:-2}
|
||||
|
||||
# Replace every API replica one by one with a freshly built image (no downtime).
|
||||
rolling-update:
|
||||
sh scripts/rolling-update.sh
|
||||
|
||||
# Level 4: stop each replica in turn under load, measure RPS/errors/recovery (evidence/failover/).
|
||||
failover-series:
|
||||
$(PYTHON) bench/failover_series.py --output evidence/failover
|
||||
|
||||
# Own tests: unit + black-box against the running stand (needs requirements*.txt in a venv).
|
||||
student-test:
|
||||
$(PYTHON) -m pytest student-tests -v
|
||||
|
||||
unit-test:
|
||||
$(PYTHON) -m pytest student-tests -m "not stack" -q
|
||||
|
||||
explain:
|
||||
$(PYTHON) scripts/explain_history.py --output evidence/explain-history.txt
|
||||
|
||||
# Track 2: reconciler of S3 objects vs attachment rows (dry-run by default, read-only).
|
||||
reconcile:
|
||||
docker compose run --rm reconciler
|
||||
|
||||
reconcile-apply:
|
||||
docker compose run --rm reconciler --apply
|
||||
|
||||
# Level 4: peak RAM of the replicas under 16 simultaneous uploads (evidence/memory/).
|
||||
bench-memory:
|
||||
$(PYTHON) bench/upload_memory.py --output evidence/memory
|
||||
|
||||
# Track 2: cost of one reconciler pass for 1k/10k/50k attachments (evidence/reconcile/).
|
||||
bench-reconcile:
|
||||
$(PYTHON) bench/reconcile_cost.py --output evidence/reconcile
|
||||
|
||||
Reference in New Issue
Block a user