Лабораторная работа 3

This commit is contained in:
2026-10-26 23:23:12 +03:00
parent 0ab3a341aa
commit fafd1828c0
70 changed files with 6665 additions and 25 deletions
+74 -1
View File
@@ -4,10 +4,14 @@ CA_FILE ?=
ACTION_SCRIPT ?=
TLS_ARGS = $(if $(CA_FILE),--ca-file "$(CA_FILE)",)
.PHONY: help check validate test load test-persistence test-failover
.PHONY: help check validate test load test-persistence test-failover \
secrets up wait ps down migrate restore rolling-update logs-lb \
test-student test-idempotency test-failover-series test-failover-series-kill \
test-rolling test-storage test-expiry test-failures test-revocation explain evidence
help:
@echo "check: offline structure; validate: full OpenAPI (requirements-dev.txt); test: running API; load: synthetic writes"
@echo "up/wait/ps/down/restore/rolling-update: stand; test-*: own checks (see REPORT.md)"
check:
$(PYTHON) scripts/check_contract.py
@@ -28,3 +32,72 @@ 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)
# ---------------------------------------------------------------- Решение
COMPOSE ?= docker compose --env-file .env
secrets:
$(PYTHON) scripts/init_secrets.py
@test -f .env || cp .env.example .env
up: secrets
$(COMPOSE) config --quiet
$(COMPOSE) up -d --build
$(PYTHON) scripts/ops.py wait
wait:
$(PYTHON) scripts/ops.py wait
ps:
$(PYTHON) scripts/ops.py ps
# Безопасная остановка: volumes (данные PostgreSQL) сохраняются.
down:
$(COMPOSE) --profile ttl down
migrate:
$(COMPOSE) run --rm -T migrate
restore:
$(PYTHON) scripts/ops.py restore
rolling-update:
$(PYTHON) scripts/ops.py rolling-update
logs-lb:
$(COMPOSE) logs --tail 50 lb
test-student:
$(PYTHON) student-tests/run_all.py --base-url "$(BASE_URL)"
test-idempotency:
BASE_URL="$(BASE_URL)" $(PYTHON) -m unittest discover -s student-tests -p test_idempotency.py -v
test-failover-series:
$(PYTHON) student-tests/failover_series.py --base-url "$(BASE_URL)" --output evidence/failover_series.json
test-failover-series-kill:
$(PYTHON) student-tests/failover_series.py --base-url "$(BASE_URL)" --mode kill --output evidence/failover_series_kill.json
test-rolling:
$(PYTHON) student-tests/rolling_update_load.py --base-url "$(BASE_URL)" --output evidence/rolling_update.json
test-storage:
$(PYTHON) scripts/ops.py in-network storage
test-expiry:
$(PYTHON) scripts/ops.py in-network expiry
test-failures:
$(PYTHON) student-tests/dependency_failure.py --base-url "$(BASE_URL)" --output evidence/dependency_failure.json
test-revocation:
$(PYTHON) student-tests/revocation_partition.py --base-url "$(BASE_URL)" | tee evidence/revocation_partition.txt
explain:
$(COMPOSE) exec -T postgres psql -U messenger -d messenger -v ON_ERROR_STOP=1 < scripts/sql/explain_history.sql > evidence/explain_history.txt
@echo "saved evidence/explain_history.txt"
# Все проверки на compose-стенде с записью результатов в evidence/ (~6-8 минут).
evidence:
$(PYTHON) scripts/collect_evidence.py