forked from mtusi2026/mtusi2026lab6
Перенесено дерево lab5 целиком: NestJS-приложение (API + worker,
RabbitMQ, outbox, S3), Dockerfile, compose.yaml, infra/{haproxy,minio,
rabbitmq}, стендовые скрипты, scripts/lab4, scripts/lab5,
evidence/lab4, evidence/lab5 и contracts/extensions.openapi.json.
Задание lab6 оставлено своим: README, REPORT, COURSE, lab.json,
contracts/{openapi,infrastructure,jobs.schema,attachment-states,
examples,observability}, tests, compose.example.yaml, infra/otel,
.github/pull_request_template.md.
Адаптации при переносе:
- docker-проект mtusi-lab5 -> mtusi-lab6 и тег образа
mtusi-messenger:lab6 (compose.yaml, scripts/stop-one.sh, .env.example,
infra/README.md), чтобы тома и контейнеры не пересекались с lab5;
- Makefile: цели lab5 сохранены целиком (skeleton lab6 не отличается
от skeleton lab5);
- .env.example: переменные приложения и стенда lab5 + блок lab6
(OTEL_*) из skeleton.
82 lines
2.5 KiB
Makefile
82 lines
2.5 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 test-dependencies stand-up stand-down stand-status wait-ready init-env test-e2e s3-security consistency bench lab5-demo lab5-faults lab5-track2 jobs
|
|
|
|
help:
|
|
@echo "check: offline structure; validate: full OpenAPI (requirements-dev.txt); test: running API; load: synthetic writes; init-env: .env + secrets; test-e2e: app e2e; s3-security; consistency; bench; lab5-demo; lab5-faults; lab5-track2; jobs ARGS=..."
|
|
|
|
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_ENV_FILE ?= .env
|
|
COMPOSE = docker compose --env-file $(COMPOSE_ENV_FILE)
|
|
|
|
test-dependencies:
|
|
cd app && E2E_COMPOSE_DIR="$(CURDIR)" E2E_COMPOSE_ENV_FILE="$(COMPOSE_ENV_FILE)" npm run test:dependencies
|
|
|
|
stand-up:
|
|
$(COMPOSE) up -d --build --wait
|
|
|
|
stand-down:
|
|
$(COMPOSE) down
|
|
|
|
stand-status:
|
|
$(COMPOSE) ps
|
|
|
|
wait-ready:
|
|
@for attempt in $$(seq 1 60); do \
|
|
if curl -fsS "$(BASE_URL)/health/ready" >/dev/null 2>&1; then \
|
|
echo "stand is ready ($(BASE_URL))"; exit 0; \
|
|
fi; \
|
|
sleep 1; \
|
|
done; \
|
|
echo "stand did not become ready within 60s" >&2; exit 1
|
|
|
|
init-env:
|
|
./scripts/init-env.sh
|
|
|
|
test-e2e:
|
|
scripts/app-e2e.sh
|
|
|
|
s3-security:
|
|
scripts/lab4/check_s3_security.sh
|
|
|
|
consistency:
|
|
scripts/lab4/consistency_check.sh
|
|
|
|
bench:
|
|
scripts/lab4/run_matrix.sh
|
|
|
|
lab5-demo:
|
|
$(PYTHON) scripts/lab5/worker_down_demo.py --base-url "$(BASE_URL)" $(TLS_ARGS)
|
|
|
|
lab5-faults:
|
|
$(PYTHON) scripts/lab5/fault_suite.py --base-url "$(BASE_URL)" --scenario level4 --output evidence/lab5/faults-level4.json $(TLS_ARGS)
|
|
|
|
lab5-track2:
|
|
$(PYTHON) scripts/lab5/fault_suite.py --base-url "$(BASE_URL)" --scenario track2 --repeat 3 --output evidence/lab5/track2.json $(TLS_ARGS)
|
|
|
|
jobs:
|
|
docker compose --env-file $(COMPOSE_ENV_FILE) exec -T api node dist/jobs/jobs.cli.js $(ARGS)
|