init commit: create skeleton from lab1
This commit is contained in:
@@ -4,10 +4,17 @@ CA_FILE ?=
|
||||
ACTION_SCRIPT ?=
|
||||
TLS_ARGS = $(if $(CA_FILE),--ca-file "$(CA_FILE)",)
|
||||
|
||||
.PHONY: help check validate test load test-persistence
|
||||
TEST_DATABASE_URL ?= $(shell sed -e 's|@postgres:|@localhost:|' -e 's|/messenger$$|/messenger_test|' secrets/database_url 2>/dev/null)
|
||||
export TEST_DATABASE_URL
|
||||
|
||||
.PHONY: help check validate test load test-persistence \
|
||||
secrets up down logs db-up migrate migration \
|
||||
test-own test-limits test-concurrency test-migrations
|
||||
|
||||
help:
|
||||
@echo "check: offline structure; validate: full OpenAPI (requirements-dev.txt); test: running API; load: synthetic writes"
|
||||
@echo "Курс: check | validate | test (smoke по BASE_URL) | load | test-persistence ACTION_SCRIPT=scripts/restart.sh"
|
||||
@echo "Стенд: secrets | up | down | logs | db-up (только PostgreSQL + тестовая БД) | migrate"
|
||||
@echo "Свои: test-own | test-limits | test-concurrency | test-migrations | migration m='описание'"
|
||||
|
||||
check:
|
||||
$(PYTHON) scripts/check_contract.py
|
||||
@@ -24,3 +31,38 @@ load:
|
||||
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)
|
||||
|
||||
secrets:
|
||||
sh scripts/init-secrets.sh
|
||||
|
||||
up:
|
||||
docker compose --env-file .env up -d --build
|
||||
|
||||
down:
|
||||
docker compose down # без -v: volumes с данными сохраняются
|
||||
|
||||
logs:
|
||||
docker compose logs -f api
|
||||
|
||||
db-up:
|
||||
docker compose up -d --wait postgres
|
||||
docker compose exec -T postgres sh -c \
|
||||
"psql -U messenger -d postgres -tc \"SELECT 1 FROM pg_database WHERE datname='messenger_test'\" | grep -q 1 || createdb -U messenger messenger_test"
|
||||
|
||||
migrate:
|
||||
docker compose run --rm migrate
|
||||
|
||||
migration:
|
||||
$(PYTHON) -m alembic revision --autogenerate -m "$(m)"
|
||||
|
||||
test-own:
|
||||
$(PYTHON) -m pytest tests -q
|
||||
|
||||
test-limits:
|
||||
$(PYTHON) -m pytest tests/test_limits.py -q
|
||||
|
||||
test-concurrency:
|
||||
$(PYTHON) -m pytest tests/test_concurrency.py -q
|
||||
|
||||
test-migrations:
|
||||
$(PYTHON) -m pytest tests/test_migrations.py -q
|
||||
|
||||
Reference in New Issue
Block a user