Реализация лабораторной 2: PostgreSQL, сессии, Valkey-кэш
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
Tmribob
2026-10-30 19:37:21 +03:00
parent 65003b6119
commit 3df9b09896
44 changed files with 3519 additions and 17 deletions
+34 -2
View File
@@ -1,13 +1,19 @@
PYTHON ?= python3
BASE_URL ?= http://localhost:8080
# 127.0.0.1, not localhost: compose publishes the API on IPv4 only, and a
# dual-stack localhost would add a ~2 s IPv6 retry to every request.
BASE_URL ?= http://127.0.0.1:8080
CA_FILE ?=
ACTION_SCRIPT ?=
TLS_ARGS = $(if $(CA_FILE),--ca-file "$(CA_FILE)",)
STUDENT_DIR = student-tests
.PHONY: help check validate test load test-persistence
.PHONY: help check validate test load test-persistence run bootstrap up down test-student test-ttl test-degradation explain
help:
@echo "check: offline structure; validate: full OpenAPI (requirements-dev.txt); test: running API; load: synthetic writes"
@echo "bootstrap/up/down: local Compose stand; run: API without Docker (needs DATABASE_URL/CACHE_URL)"
@echo "test-student: own functional+race tests; test-ttl: expiry on the short-TTL stand; test-degradation: cache/DB outages"
@echo "explain: seed 12k messages and capture EXPLAIN (ANALYZE, BUFFERS) into evidence/"
check:
$(PYTHON) scripts/check_contract.py
@@ -24,3 +30,29 @@ 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)
# --- lab 2 -----------------------------------------------------------------
run:
$(PYTHON) -B src/app.py
bootstrap:
sh scripts/bootstrap-secrets.sh
up: bootstrap
docker compose --env-file .env up -d --build --wait --wait-timeout 180
docker compose --env-file .env ps
down:
docker compose --env-file .env down
test-student:
cd $(STUDENT_DIR) && BASE_URL="$(BASE_URL)" $(PYTHON) -B -m unittest -v test_api test_race
test-ttl:
sh scripts/test-ttl.sh
test-degradation:
cd $(STUDENT_DIR) && BASE_URL="$(BASE_URL)" STUDENT_DOCKER_TESTS=1 $(PYTHON) -B -m unittest -v test_degradation
explain:
sh scripts/explain-history.sh