forked from mtusi2026/mtusi2026lab3
Add the stop-one, restart and restore hooks and an LB probe
scripts/stop-one.sh maps TARGET_INSTANCE_ID to the api container whose hostname matches, stops only it with docker stop -t 6 and leaves it stopped; an unknown id exits 3 and touches nothing. scripts/restart.sh replaces the lab 2 hook: it stops lb and the replicas, restarts PostgreSQL and Valkey with their volumes and brings the stand back with up --wait, which also reruns the idempotent migrate job. scripts/restore.sh starts stopped replicas without recreating them and scripts/lb-wait.sh waits until the balancer statistics show every replica UP again, so the next failover run sees two replicas. scripts/probe.py check (stdlib, Python 3.9 syntax) counts X-Instance-Id over 40 calls with one token and races 8 posts with one key through the balancer. make restore and make lb-check run them, ruff covers the probe, and the CI acceptance job runs the failover test and the probe. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
dc2015473f
commit
ceb266ed05
@@ -11,12 +11,14 @@ 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 persistence-evidence storage-evidence cache-evidence test-faults seed explain
|
||||
secrets up down reset-data migrate ps logs restore lb-check \
|
||||
persistence-evidence storage-evidence cache-evidence test-faults seed explain
|
||||
|
||||
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: реплики на одном токене и гонка одного ключа"
|
||||
|
||||
check:
|
||||
$(PYTHON) scripts/check_contract.py
|
||||
@@ -42,13 +44,13 @@ install:
|
||||
$(UV) sync --group dev
|
||||
|
||||
lint:
|
||||
$(VENV)/bin/ruff check src student-tests
|
||||
$(VENV)/bin/ruff format --check src student-tests
|
||||
$(VENV)/bin/ruff check src student-tests scripts/probe.py
|
||||
$(VENV)/bin/ruff format --check src student-tests scripts/probe.py
|
||||
$(VENV)/bin/ty check src student-tests
|
||||
|
||||
format:
|
||||
$(VENV)/bin/ruff check --fix src student-tests
|
||||
$(VENV)/bin/ruff format src student-tests
|
||||
$(VENV)/bin/ruff check --fix src student-tests scripts/probe.py
|
||||
$(VENV)/bin/ruff format src student-tests scripts/probe.py
|
||||
|
||||
typecheck:
|
||||
$(VENV)/bin/ty check src student-tests
|
||||
@@ -78,6 +80,12 @@ ps:
|
||||
logs:
|
||||
$(COMPOSE) logs --tail 200
|
||||
|
||||
restore:
|
||||
scripts/restore.sh
|
||||
|
||||
lb-check:
|
||||
$(PYTHON) scripts/probe.py check --out evidence/lb-check.json
|
||||
|
||||
persistence-evidence:
|
||||
sh scripts/persistence-evidence.sh "$(BASE_URL)" > evidence/persistence.txt
|
||||
cat evidence/persistence.txt
|
||||
|
||||
Reference in New Issue
Block a user