forked from mtusi2026/mtusi2026lab4
97 lines
2.6 KiB
Makefile
97 lines
2.6 KiB
Makefile
PYTHON ?= $(if $(wildcard .venv/bin/python),.venv/bin/python,python3)
|
|
GO ?= go
|
|
PORT ?= 8080
|
|
BASE_URL ?= http://localhost:$(PORT)
|
|
IMAGE ?= mtusi-messenger:lab4
|
|
CA_FILE ?=
|
|
ACTION_SCRIPT ?= scripts/restart.sh
|
|
FAILOVER_SCRIPT ?= scripts/stop-one.sh
|
|
RECONCILE_ARGS ?=
|
|
export PYTHONDONTWRITEBYTECODE=1
|
|
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 test-lab4 test-reconcile measure-uploads measure-load migrate-status rolling-update test-failover wait bootstrap-s3 reconcile reconcile-apply
|
|
|
|
export PORT BASE_URL
|
|
|
|
help:
|
|
@echo "up: build and deploy Swarm stack; down: stop with volumes retained; test-integration: PostgreSQL race/rollback/EXPLAIN; test-grade4: cross-replica idempotency, both failures and rolling update; 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:
|
|
$(PYTHON) scripts/swarm.py up
|
|
|
|
down:
|
|
$(PYTHON) scripts/swarm.py down
|
|
|
|
migrate:
|
|
$(PYTHON) scripts/swarm.py migrate
|
|
|
|
migrate-status:
|
|
$(PYTHON) scripts/swarm.py migrate-status
|
|
|
|
rolling-update:
|
|
$(PYTHON) scripts/swarm.py update
|
|
|
|
run:
|
|
PORT="$(PORT)" $(GO) run ./cmd
|
|
|
|
docker-build:
|
|
docker build -t "$(IMAGE)" .
|
|
|
|
test-integration:
|
|
$(PYTHON) scripts/swarm.py test-integration
|
|
|
|
test-grade4:
|
|
$(PYTHON) tests/own/swarm_grade4.py
|
|
|
|
test-lab4:
|
|
$(PYTHON) tests/own/lab4.py
|
|
|
|
test-reconcile:
|
|
$(PYTHON) tests/own/reconcile.py
|
|
|
|
measure-uploads:
|
|
$(PYTHON) scripts/measure_uploads.py
|
|
|
|
bootstrap-s3:
|
|
$(PYTHON) scripts/swarm.py bootstrap-s3
|
|
|
|
reconcile:
|
|
$(PYTHON) scripts/swarm.py reconcile $(RECONCILE_ARGS)
|
|
|
|
reconcile-apply:
|
|
$(PYTHON) scripts/swarm.py reconcile --apply $(RECONCILE_ARGS)
|
|
|
|
measure-load:
|
|
$(PYTHON) scripts/measure_load.py --base-url "$(BASE_URL)"
|
|
|
|
test-failover:
|
|
$(PYTHON) tests/resilience.py --mode failover --action-script "$(if $(filter command line,$(origin ACTION_SCRIPT)),$(ACTION_SCRIPT),$(FAILOVER_SCRIPT))" --base-url "$(BASE_URL)" $(TLS_ARGS)
|
|
|
|
wait:
|
|
$(PYTHON) scripts/swarm.py wait
|