PYTHON ?= python3 BASE_URL ?= http://localhost:8080 CA_FILE ?= ACTION_SCRIPT ?= TLS_ARGS = $(if $(CA_FILE),--ca-file "$(CA_FILE)",) .PHONY: help check validate test load test-persistence test-failover help: @echo "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) 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) # --------------------------------------------------------------------------- # Application targets (Go implementation). The targets above are the skeleton. # --------------------------------------------------------------------------- EVIDENCE_DIR ?= evidence .PHONY: build vet unit secrets up down destroy logs concurrency explain instances rollout bench plot failover-load rollout-load build: go build -o bin/server ./cmd/server vet: go vet ./... # The tests start disposable PostgreSQL and Valkey containers: Docker must run. unit: go test -race -count=1 ./... secrets: sh scripts/init-secrets.sh up: docker compose up -d --build --wait # Stops and removes the containers; volumes and therefore data are kept. down: docker compose down # Deletes the volumes too: every user, chat, message and session of the stand. destroy: docker compose down -v logs: docker compose logs # Which container answers under which X-Instance-Id. instances: sh scripts/instances.sh # Replaces every API replica with one built from the current sources, without # downtime; restore a replica stopped by stop-one with `docker compose start api`. rollout: sh scripts/rollout.sh # Track 1, the cost of scaling: one series on fresh stands, then the charts. # RATES is required, e.g. make bench SERIES=scripts/bench/series/B.conf RATES=200,400,800 SERIES ?= scripts/bench/series/A.conf REPEATS ?= 3 bench: sh scripts/bench/run-series.sh $(SERIES) $(REPEATS) # Needs matplotlib from requirements-bench.txt: make plot PYTHON=. plot: $(PYTHON) scripts/bench/plot.py evidence/track1/raw evidence/track1 # Level 4 under load: one replica stopped (KIND=stop) or killed (KIND=kill), # and the rolling update. KIND ?= stop REPLICA ?= 1 failover-load: sh scripts/bench/failover.sh $(KIND) $(REPLICA) rollout-load: sh scripts/bench/rollout-under-load.sh concurrency: go run ./tools/concurrency --base-url "$(BASE_URL)" --output "$(EVIDENCE_DIR)/concurrency.json" explain: docker compose exec -T postgres psql -U messenger -d messenger -X -q -v ON_ERROR_STOP=1 -f - < scripts/explain-history.sql