Give every level 4 check one make target

make limits, make lb-check (now 20 rounds of 8 parallel posts with one
key), make detection, make failover-each and make rolling-update each
write their file in evidence/ and fail on a violated check; make
level4 runs them in order. RATE sets the k6 arrival rate (100 rps by
default). make rolling-update builds the image before the load starts
so the build does not skew the measurement; with FROM_REV=<commit> it
first builds the image tag from git archive of that commit and
recreates the replicas on it, so the update is a real change of
version, and it writes to evidence/rolling-from-<commit>. Lint covers
scripts/limits.py. CI acceptance runs make limits and make detection.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Artyom
2026-10-28 19:52:29 +03:00
co-authored by Claude Opus 5.5
parent 3584501de8
commit eb04fc10e3
3 changed files with 47 additions and 13 deletions
+6
View File
@@ -49,6 +49,12 @@ jobs:
- name: Отказы Valkey и PostgreSQL, гонка и rollback
run: make test-faults
- name: Лимиты, порты, секреты, volumes и сети по политике
run: make limits
- name: Время обнаружения отказа балансировщиком (SIGTERM, kill, pause, PostgreSQL)
run: make detection
- name: Наружу опубликован только балансировщик
run: |
docker compose ps --format '{{.Service}} {{.Ports}}' | awk '$2 != "" && $1 != "lb" {print; bad=1} END {exit bad}'
+35 -7
View File
@@ -7,18 +7,24 @@ TLS_ARGS = $(if $(CA_FILE),--ca-file "$(CA_FILE)",)
VENV ?= .venv
UV ?= uv
COMPOSE ?= docker compose
RATE ?= 100
API_IMAGE ?= mtusi-messenger:lab3
FROM_REV ?=
SCRIPTS_PY = scripts/probe.py scripts/limits.py
PSQL = $(COMPOSE) exec -T postgres psql -U messenger -d messenger -X -q
.PHONY: help check validate test load test-persistence test-failover \
install lint format typecheck student-test \
secrets up down reset-data migrate ps logs restore lb-check failover-evidence stack-evidence \
persistence-evidence storage-evidence cache-evidence test-faults seed explain
persistence-evidence storage-evidence cache-evidence test-faults seed explain \
limits detection failover-each rolling-update level4
help:
@echo "check: offline structure; validate: full OpenAPI (requirements-dev.txt); test: running API; load: synthetic writes"
@echo "install/lint/typecheck/student-test: студенческий тулчейн"
@echo "secrets/up/down/migrate/ps/logs: стенд Docker Compose; reset-data: намеренное удаление volumes"
@echo "restore: вернуть остановленные реплики; lb-check: реплики на одном токене и гонка одного ключа"
@echo "restore: вернуть остановленные реплики; lb-check: реплики на одном токене и 20 гонок одного ключа"
@echo "level4 = limits, lb-check, detection, failover-each, rolling-update [FROM_REV=<коммит>]; RATE=$(RATE) rps"
check:
$(PYTHON) scripts/check_contract.py
@@ -44,13 +50,13 @@ install:
$(UV) sync --group dev
lint:
$(VENV)/bin/ruff check src student-tests scripts/probe.py
$(VENV)/bin/ruff format --check src student-tests scripts/probe.py
$(VENV)/bin/ruff check src student-tests $(SCRIPTS_PY)
$(VENV)/bin/ruff format --check src student-tests $(SCRIPTS_PY)
$(VENV)/bin/ty check src student-tests
format:
$(VENV)/bin/ruff check --fix src student-tests scripts/probe.py
$(VENV)/bin/ruff format src student-tests scripts/probe.py
$(VENV)/bin/ruff check --fix src student-tests $(SCRIPTS_PY)
$(VENV)/bin/ruff format src student-tests $(SCRIPTS_PY)
typecheck:
$(VENV)/bin/ty check src student-tests
@@ -84,7 +90,29 @@ restore:
scripts/restore.sh
lb-check:
$(PYTHON) scripts/probe.py check --out evidence/lb-check.json
$(PYTHON) scripts/probe.py check --rounds 20 --out evidence/lb-check.json
limits:
$(PYTHON) scripts/limits.py --out evidence/limits.txt
detection:
sh scripts/detection.sh evidence/detection
failover-each:
RATE=$(RATE) sh scripts/failover-each.sh evidence/failover-each
rolling-update:
ifneq ($(FROM_REV),)
git archive "$(FROM_REV)" | docker build -q -t "$(API_IMAGE)" -
$(COMPOSE) up -d --no-deps --force-recreate --wait api
scripts/lb-wait.sh
endif
$(COMPOSE) build -q api
RATE=$(RATE) $(PYTHON) scripts/probe.py load --expect replace --duration 90 \
--out evidence/rolling$(if $(FROM_REV),-from-$(FROM_REV)) \
-- scripts/rolling-update.sh
level4: limits lb-check detection failover-each rolling-update
failover-evidence:
sh scripts/failover-evidence.sh "$(BASE_URL)"
@@ -20,12 +20,12 @@
## 4. Сценарии уровня «4»
- [ ] 4.1 `scripts/detection.sh` и `make detection`: `SIGTERM`, `docker kill`, `docker pause`, остановка PostgreSQL с заявленными максимумами
- [ ] 4.2 `scripts/failover-each.sh` и `make failover-each`: остановка, 10 с без реплики и возврат каждой реплики под нагрузкой
- [ ] 4.3 `scripts/limits.py` и `make limits`: политика лимитов, портов, секретов, volumes, сетей
- [ ] 4.4 `scripts/rolling-update.sh` и `make rolling-update [FROM_REV=…]`: `migrate` один раз, замена с запасом +1, журнал образов
- [ ] 4.5 Тест отказа PostgreSQL через LB: ответы `503`, live внутри реплики `200`, LB исключает все реплики и сам отвечает `503`
- [ ] 4.6 CI: `make limits`, `make detection` в acceptance
- [x] 4.1 `scripts/detection.sh` и `make detection`: `SIGTERM`, `docker kill`, `docker pause`, остановка PostgreSQL с заявленными максимумами
- [x] 4.2 `scripts/failover-each.sh` и `make failover-each`: остановка, 10 с без реплики и возврат каждой реплики под нагрузкой
- [x] 4.3 `scripts/limits.py` и `make limits`: политика лимитов, портов, секретов, volumes, сетей
- [x] 4.4 `scripts/rolling-update.sh` и `make rolling-update [FROM_REV=…]`: `migrate` один раз, замена с запасом +1, журнал образов
- [x] 4.5 Тест отказа PostgreSQL через LB: ответы `503`, live внутри реплики `200`, LB исключает все реплики и сам отвечает `503`
- [x] 4.6 CI: `make limits`, `make detection` в acceptance
- [ ] 4.7 Проверка группы: `make up`, `make limits`, `make lb-check`, `make detection`, `make failover-each`, `make rolling-update FROM_REV=8d28d45`, `make test-faults`
## 5. Отчёт