Files
mtusi2026lab7/Makefile
T

118 lines
3.5 KiB
Makefile

PYTHON ?= python3
BASE_URL ?= https://localhost:8443
CA_FILE ?=
ACTION_SCRIPT ?=
TLS_ARGS = $(if $(CA_FILE),--ca-file "$(CA_FILE)",)
CLEANUP_ARGS ?= --dry-run
SERVICES ?=
JOB_ID ?=
ATTACHMENT_ID ?=
REASON ?=
export JOB_ID ATTACHMENT_ID REASON
COMPOSE = docker compose --project-name highload-lab7 --env-file .env -f compose.yml
.PHONY: app-init app-build app-up app-start app-stop app-down app-restart app-logs app-status
.PHONY: app-migrate app-s3-bootstrap worker-start worker-stop queue-status attachments-cleanup
.PHONY: jobs-failed jobs-replay jobs-upgrade jobs-cleanup-staging
.PHONY: test-backend test-pipeline
.PHONY: help check validate test load test-persistence test-failover test-security
help:
@echo "check: offline structure; validate: full OpenAPI (requirements-dev.txt); test: running API; load: synthetic writes"
@echo "app-up: build and start the stand; app-status: inspect it; app-down: stop it"
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)
test-security:
$(PYTHON) tests/security.py --base-url "$(BASE_URL)" $(TLS_ARGS)
app-init:
$(PYTHON) scripts/init_env.py
./scripts/bootstrap_tls.sh
app-build: app-init
$(COMPOSE) build
app-up: app-init
$(COMPOSE) up -d --build --wait
./scripts/wait_ingress.sh
app-start: app-init
$(COMPOSE) up -d --no-build --wait
./scripts/wait_ingress.sh
app-stop:
$(COMPOSE) stop
app-down:
$(COMPOSE) down
app-restart: app-init
./scripts/restart.sh
app-logs:
$(COMPOSE) logs -f --tail=100 $(SERVICES)
app-status:
$(COMPOSE) ps --all
app-migrate: app-init
$(COMPOSE) run --rm migrate
app-s3-bootstrap: app-init
$(COMPOSE) run --rm s3-bootstrap
worker-start:
$(COMPOSE) start worker
worker-stop:
$(COMPOSE) stop worker
queue-status:
$(COMPOSE) exec -T broker rabbitmqctl -q list_queues name messages_ready messages_unacknowledged --formatter json
attachments-cleanup:
$(COMPOSE) run --rm --no-deps upload-cleanup ./messenger attachments-cleanup $(CLEANUP_ARGS)
jobs-failed:
$(COMPOSE) exec -T dispatcher ./messenger jobs list-failed
jobs-replay:
@test -n "$$JOB_ID" && test -n "$$REASON" || { echo "Set JOB_ID=... REASON='...'"; exit 2; }
$(COMPOSE) exec -T dispatcher ./messenger jobs replay "$$JOB_ID" "$$REASON"
jobs-upgrade:
@test -n "$$ATTACHMENT_ID" && test -n "$$REASON" || { echo "Set ATTACHMENT_ID=... REASON='...'"; exit 2; }
$(COMPOSE) exec -T dispatcher ./messenger jobs upgrade "$$ATTACHMENT_ID" 2 "$$REASON"
jobs-cleanup-staging:
@test -n "$$JOB_ID" || { echo "Set JOB_ID=..."; exit 2; }
$(COMPOSE) exec -T dispatcher ./messenger jobs cleanup-staging "$$JOB_ID"
test-backend: app-init
$(COMPOSE) --profile test run --rm --build backend-tests
test-pipeline: app-init
$(COMPOSE) --profile test run --rm --build backend-tests go test -race -count=1 -v ./backend/tests ./backend/workers -run 'TestPipeline|TestVersionedRendering|TestThumbnail|TestOptimized'