Реализовать ЛР 7 на оценку 3

This commit is contained in:
2026-12-04 14:27:18 +03:00
parent 31d441184b
commit 7996ebbb48
59 changed files with 2236 additions and 498 deletions
+43 -5
View File
@@ -1,13 +1,30 @@
PYTHON ?= python3
BASE_URL ?= https://localhost:8443
CA_FILE ?=
CA_FILE ?= secrets/ca.crt
COMPOSE_ENV_FILE ?= .env
export COMPOSE_ENV_FILE
COMPOSE = docker compose --env-file "$(COMPOSE_ENV_FILE)"
ACTION_SCRIPT ?=
TLS_ARGS = $(if $(CA_FILE),--ca-file "$(CA_FILE)",)
.PHONY: help check validate test load test-persistence test-failover test-security
.PHONY: help bootstrap bao-setup up down check validate test test-observability load test-persistence test-failover test-failover-both test-security test-security-api test-security-internal test-expiry benchmark-argon2
help:
@echo "check: offline structure; validate: full OpenAPI (requirements-dev.txt); test: running API; load: synthetic writes"
@echo "up: bootstrap and start; down: stop while keeping data; test: HTTPS API; test-observability: Grafana signals"
bootstrap:
$(PYTHON) scripts/bootstrap.py --env-file "$(COMPOSE_ENV_FILE)"
bao-setup: bootstrap
$(COMPOSE) up -d openbao
$(PYTHON) -m scripts.provision_openbao --env-file "$(COMPOSE_ENV_FILE)"
up: bao-setup
$(COMPOSE) up -d --build --wait
$(COMPOSE) exec -T broker sh -ec 'users=$$(rabbitmqctl -q list_users); for user in guest messenger; do if printf "%s\n" "$$users" | grep -q "^$$user[[:space:]]"; then rabbitmqctl -q delete_user "$$user"; fi; done'
down:
$(COMPOSE) down
check:
$(PYTHON) scripts/check_contract.py
@@ -18,16 +35,37 @@ validate:
test:
$(PYTHON) tests/smoke.py --base-url "$(BASE_URL)" $(TLS_ARGS)
test-observability:
$(COMPOSE) -f compose.yaml -f compose.observability-tests.yaml run --rm observability-test
load:
$(PYTHON) tests/load.py --base-url "$(BASE_URL)" $(TLS_ARGS)
test-persistence: ACTION_SCRIPT := $(or $(ACTION_SCRIPT),scripts/restart.sh)
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: ACTION_SCRIPT := $(or $(ACTION_SCRIPT),scripts/stop-one.sh)
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)
test-security:
$(PYTHON) tests/security.py --base-url "$(BASE_URL)" $(TLS_ARGS)
test-security-api:
$(PYTHON) tests/security_grade3.py --base-url "$(BASE_URL)" $(TLS_ARGS)
test-expiry:
$(PYTHON) tests/security_grade3.py --expiry --base-url "$(BASE_URL)" $(TLS_ARGS)
benchmark-argon2:
$(COMPOSE) exec -T api python -m app.tools.benchmark_argon2
test-security-internal:
$(PYTHON) scripts/bootstrap.py --test-fixtures --env-file "$(COMPOSE_ENV_FILE)"
$(COMPOSE) -f compose.yaml -f compose.security-tests.yaml build security-test
$(COMPOSE) -f compose.yaml -f compose.security-tests.yaml run --rm --no-deps security-test
test-failover-both: ACTION_SCRIPT := $(or $(ACTION_SCRIPT),scripts/stop-one.sh)
test-failover-both:
$(PYTHON) tests/failover_both.py --mode failover --action-script "$(ACTION_SCRIPT)" --base-url "$(BASE_URL)" $(TLS_ARGS)