forked from mtusi2026/mtusi2026lab4
ЛР4 на 4: MinIO-вложения поверх LB, идемпотентности и failover.
PNG/JPEG через API, student-tests, REPORT и DEFENSE.
This commit is contained in:
@@ -1,13 +1,30 @@
|
||||
PYTHON ?= python3
|
||||
BASE_URL ?= http://localhost:8080
|
||||
BASE_URL ?= http://127.0.0.1:8081
|
||||
CA_FILE ?=
|
||||
ACTION_SCRIPT ?=
|
||||
TLS_ARGS = $(if $(CA_FILE),--ca-file "$(CA_FILE)",)
|
||||
COMPOSE ?= docker compose -p gavrilenko-lab4 --env-file .env
|
||||
GO ?= go
|
||||
|
||||
.PHONY: help check validate test load test-persistence test-failover
|
||||
ENV_FILE ?= .env
|
||||
env_val = $(shell grep -E '^$(1)=' $(ENV_FILE) 2>/dev/null | tail -n1 | cut -d= -f2-)
|
||||
PG_PORT := $(or $(call env_val,POSTGRES_HOST_PORT),5433)
|
||||
REDIS_PORT := $(or $(call env_val,REDIS_HOST_PORT),6380)
|
||||
MINIO_PORT := $(or $(call env_val,MINIO_HOST_PORT),9002)
|
||||
PG_USER := $(or $(call env_val,POSTGRES_USER),messenger)
|
||||
PG_PASS := $(or $(call env_val,POSTGRES_PASSWORD),messenger)
|
||||
PG_DB := $(or $(call env_val,POSTGRES_DB),messenger)
|
||||
|
||||
.PHONY: help check validate test load test-persistence test-failover up down student-test private-bucket upload-mem reconcile-dry
|
||||
|
||||
help:
|
||||
@echo "check: offline structure; validate: full OpenAPI (requirements-dev.txt); test: running API; load: synthetic writes"
|
||||
@echo "up/down: стенд; test BASE_URL=...; student-test; private-bucket; upload-mem"
|
||||
|
||||
up:
|
||||
bash scripts/up.sh
|
||||
|
||||
down:
|
||||
$(COMPOSE) down
|
||||
|
||||
check:
|
||||
$(PYTHON) scripts/check_contract.py
|
||||
@@ -22,9 +39,27 @@ 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)
|
||||
@test -n "$(ACTION_SCRIPT)" || (echo "Set ACTION_SCRIPT"; 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)
|
||||
@test -n "$(ACTION_SCRIPT)" || (echo "Set ACTION_SCRIPT"; exit 2)
|
||||
$(PYTHON) tests/resilience.py --mode failover --action-script "$(ACTION_SCRIPT)" --base-url "$(BASE_URL)" $(TLS_ARGS)
|
||||
|
||||
student-test:
|
||||
DATABASE_URL="$${DATABASE_URL:-postgres://$(PG_USER):$(PG_PASS)@127.0.0.1:$(PG_PORT)/$(PG_DB)?sslmode=disable}" \
|
||||
REDIS_URL="$${REDIS_URL:-redis://127.0.0.1:$(REDIS_PORT)/0}" \
|
||||
S3_ENDPOINT="$${S3_ENDPOINT:-http://127.0.0.1:$(MINIO_PORT)}" \
|
||||
S3_ACCESS_KEY="$${S3_ACCESS_KEY:-$(or $(call env_val,S3_ACCESS_KEY),messenger-api)}" \
|
||||
S3_SECRET_KEY="$${S3_SECRET_KEY:-$(or $(call env_val,S3_SECRET_KEY),messenger-api-secret-change-me)}" \
|
||||
S3_BUCKET="$${S3_BUCKET:-$(or $(call env_val,S3_BUCKET),messenger)}" \
|
||||
$(GO) test ./student-tests/ -v -count=1 -timeout 300s
|
||||
|
||||
private-bucket:
|
||||
bash scripts/check_private_bucket.sh | tee evidence/private-bucket.txt
|
||||
|
||||
upload-mem:
|
||||
bash scripts/upload_mem_experiment.sh
|
||||
|
||||
reconcile-dry:
|
||||
$(COMPOSE) run --rm reconcile -reconcile-dry-run
|
||||
Reference in New Issue
Block a user