Files
mtusi2026lab3-fork/Makefile

104 lines
3.4 KiB
Makefile

PYTHON ?= python3
BASE_URL ?= http://localhost:8080
CA_FILE ?=
ACTION_SCRIPT ?=
TLS_ARGS = $(if $(CA_FILE),--ca-file "$(CA_FILE)",)
.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
validate:
$(PYTHON) scripts/validate_openapi.py
test:
$(PYTHON) tests/smoke.py --base-url "$(BASE_URL)" $(TLS_ARGS)
load:
$(PYTHON) tests/load.py --base-url "$(BASE_URL)" $(TLS_ARGS)
test-persistence:
@test -n "$(ACTION_SCRIPT)" || (echo "Set ACTION_SCRIPT to your implemented executable restart hook"; exit 2)
$(PYTHON) tests/resilience.py --mode persistence --action-script "$(ACTION_SCRIPT)" --base-url "$(BASE_URL)" $(TLS_ARGS)
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