forked from mtusi2026/mtusi2026lab2
70 lines
1.9 KiB
Makefile
70 lines
1.9 KiB
Makefile
PYTHON ?= $(if $(wildcard .venv/bin/python),.venv/bin/python,python3)
|
|
GO ?= go
|
|
PORT ?= 8080
|
|
BASE_URL ?= http://localhost:$(PORT)
|
|
IMAGE ?= mtusi-messenger:lab2
|
|
CA_FILE ?=
|
|
ACTION_SCRIPT ?= scripts/restart.sh
|
|
TLS_ARGS = $(if $(CA_FILE),--ca-file "$(CA_FILE)",)
|
|
|
|
.PHONY: help run docker-build docker-run check validate test test-own test-all load test-persistence bootstrap up down migrate test-integration test-grade4 measure-load migrate-status migrate-down
|
|
|
|
export PORT BASE_URL
|
|
|
|
help:
|
|
@echo "up: start Compose stack; down: stop with volumes retained; test-integration: PostgreSQL race/rollback/EXPLAIN; test-grade4: auth/expiry/outages; check: offline structure; validate: full OpenAPI (requirements-dev.txt); test: running API; load: synthetic writes"
|
|
|
|
check:
|
|
$(PYTHON) scripts/check_contract.py
|
|
|
|
validate:
|
|
$(PYTHON) scripts/validate_openapi.py
|
|
|
|
test:
|
|
$(PYTHON) tests/smoke.py --base-url "$(BASE_URL)" $(TLS_ARGS)
|
|
|
|
test-own:
|
|
$(GO) test -race ./...
|
|
|
|
test-all: check validate test-own
|
|
|
|
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)
|
|
|
|
bootstrap:
|
|
./scripts/bootstrap.sh
|
|
|
|
up: bootstrap
|
|
./scripts/compose.sh up -d --build --wait
|
|
|
|
down:
|
|
./scripts/compose.sh down
|
|
|
|
migrate: bootstrap
|
|
./scripts/compose.sh run --build --rm migrations up
|
|
|
|
migrate-status:
|
|
./scripts/compose.sh run --rm migrations status
|
|
|
|
migrate-down:
|
|
./scripts/compose.sh run --rm migrations down
|
|
|
|
run:
|
|
PORT="$(PORT)" $(GO) run ./cmd
|
|
|
|
docker-build:
|
|
docker build -t "$(IMAGE)" .
|
|
|
|
test-integration:
|
|
./scripts/compose.sh run --build --rm tests
|
|
|
|
test-grade4:
|
|
$(PYTHON) tests/own/grade4.py
|
|
|
|
measure-load:
|
|
$(PYTHON) scripts/measure_load.py --base-url "$(BASE_URL)"
|