forked from mtusi2026/mtusi2026lab3
81 lines
2.8 KiB
Makefile
81 lines
2.8 KiB
Makefile
PYTHON ?= python3
|
|
PUBLIC_PORT ?= $(or $(shell sed -n 's/^PUBLIC_PORT=//p' .env 2>/dev/null),8080)
|
|
BASE_URL ?= http://localhost:$(PUBLIC_PORT)
|
|
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)
|
|
|
|
.PHONY: unit-test student-test concurrency lab3-test
|
|
unit-test:
|
|
docker compose run --rm --no-deps -v "$(CURDIR)/student-tests:/app/student-tests:ro" api-a python /app/student-tests/unit_test.py
|
|
|
|
student-test:
|
|
$(PYTHON) student-tests/run.py --base-url "$(BASE_URL)" $(TLS_ARGS)
|
|
|
|
concurrency:
|
|
$(PYTHON) student-tests/concurrency.py --base-url "$(BASE_URL)" --clients 10 --messages-per-client 10 --output evidence/concurrency.json $(TLS_ARGS)
|
|
|
|
lab3-test:
|
|
$(PYTHON) student-tests/lab3.py --base-url "$(BASE_URL)" $(TLS_ARGS)
|
|
|
|
.PHONY: bootstrap up restore rolling-update test-dependencies test-expiry test-readiness test-failover-load test-rolling-load
|
|
bootstrap:
|
|
$(PYTHON) scripts/bootstrap.py
|
|
|
|
up:
|
|
docker compose --env-file .env up -d --build
|
|
|
|
restore:
|
|
$(PYTHON) scripts/manage.py restore
|
|
|
|
rolling-update:
|
|
scripts/rolling-update.sh
|
|
|
|
test-dependencies:
|
|
$(PYTHON) student-tests/dependencies.py --base-url "$(BASE_URL)" $(TLS_ARGS)
|
|
|
|
test-expiry:
|
|
SESSION_TTL_SECONDS=2 docker compose up -d --no-deps --force-recreate api-a api-b
|
|
$(PYTHON) scripts/manage.py restore
|
|
@status=0; $(PYTHON) student-tests/dependencies.py --mode expiry --base-url "$(BASE_URL)" $(TLS_ARGS) || status=$$?; \
|
|
docker compose up -d --no-deps --force-recreate api-a api-b; \
|
|
$(PYTHON) scripts/manage.py restore; exit $$status
|
|
|
|
test-readiness:
|
|
$(PYTHON) student-tests/readiness.py
|
|
|
|
test-failover-load:
|
|
$(PYTHON) student-tests/experiments.py --base-url "$(BASE_URL)" --scenario failover $(TLS_ARGS)
|
|
|
|
test-rolling-load:
|
|
$(PYTHON) student-tests/experiments.py --base-url "$(BASE_URL)" --scenario rolling $(TLS_ARGS)
|
|
|
|
.PHONY: test-storage
|
|
test-storage:
|
|
docker compose run --rm --no-deps -v "$(CURDIR)/student-tests:/app/student-tests:ro" api-a python /app/student-tests/storage.py
|