Перенеси реализацию мессенджера из ЛР 6
Источник — проверенное рабочее дерево ЛР 6 поверх 18878d6, включая изменения после повторного ревью. SHA-256 списка исходных файлов: e45a3d85b41feff1da78dce3f20fd1f4af1c5ee629e6ed703218bc8e21ad58fe.
This commit is contained in:
@@ -31,3 +31,121 @@ test-failover:
|
||||
|
||||
test-security:
|
||||
$(PYTHON) tests/security.py --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
|
||||
sh scripts/wait-ready.sh
|
||||
|
||||
# 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
|
||||
|
||||
# Safe default: inspection only; APPLY=1 explicitly enables repairs.
|
||||
APPLY ?= 0
|
||||
DEEP ?= 0
|
||||
.PHONY: reconcile upload-memory reconcile-bench
|
||||
reconcile:
|
||||
docker compose --profile recon run --rm reconcile $(if $(filter 1,$(APPLY)),--apply,) $(if $(filter 1,$(DEEP)),--deep,)
|
||||
|
||||
upload-memory:
|
||||
$(PYTHON) -X utf8 scripts/lab4/upload-memory.py --base-url "$(BASE_URL)" --output "$(EVIDENCE_DIR)/upload-memory.json"
|
||||
|
||||
reconcile-bench:
|
||||
go run ./tools/reconcilebench --output "$(EVIDENCE_DIR)/track2/results.json"
|
||||
|
||||
# Which container answers under which X-Instance-Id.
|
||||
instances:
|
||||
sh scripts/instances.sh
|
||||
|
||||
# Replaces every API replica without downtime; all of them must be running.
|
||||
rollout:
|
||||
sh scripts/rollout.sh
|
||||
|
||||
# Track 1. Every run starts from empty volumes, so the stand's data is lost.
|
||||
# make bench SERIES="scripts/bench/series/A.conf scripts/bench/series/B.conf" RATES=400,800,1200
|
||||
SERIES ?= scripts/bench/series/A.conf
|
||||
bench:
|
||||
sh scripts/bench/run-series.sh $(SERIES)
|
||||
|
||||
# Needs matplotlib from requirements-bench.txt: make plot PYTHON=<venv 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
|
||||
|
||||
# Set CODEC_STRESS=1 after generating bin/decoder-fixtures to include the 40 MP cases.
|
||||
.PHONY: codec-test
|
||||
codec-test: export GOOS = linux
|
||||
codec-test: export GOARCH = $(shell docker version --format "{{.Server.Arch}}")
|
||||
codec-test: export CGO_ENABLED = 0
|
||||
codec-test: export MSYS_NO_PATHCONV = 1
|
||||
codec-test:
|
||||
go test -c -o bin/imaging.test ./internal/imaging
|
||||
docker build --target worker -t mtusi-messenger-worker:lab7 .
|
||||
docker run --rm --network none --cpus 2 --memory 2g --entrypoint /codec/imaging.test -e CODEC_REQUIRED=1 $(if $(filter 1,$(CODEC_STRESS)),-e CODEC_FIXTURES=/codec/decoder-fixtures,) --mount "type=bind,source=$(CURDIR)/bin,target=/codec,readonly" mtusi-messenger-worker:lab7 -test.v
|
||||
|
||||
# Explicit destructive-to-availability experiment on this lab's own stand.
|
||||
# Containers restart; volumes and accepted attachments are preserved.
|
||||
.PHONY: lab5-track2
|
||||
lab5-track2:
|
||||
docker compose -f compose.yaml -f compose.faults.yaml up -d --build --wait
|
||||
$(PYTHON) -X utf8 scripts/lab5/track2.py --project "$(or $(COMPOSE_PROJECT_NAME),lab7)" --base-url "$(BASE_URL)" --output "$(EVIDENCE_DIR)/lab5/run.json"
|
||||
|
||||
# Run against the stand started by this operator. Use EVIDENCE_DIR to keep separate runs.
|
||||
.PHONY: calibrate track2 retry-trace backend-outage test-observability
|
||||
test-observability:
|
||||
$(PYTHON) -X utf8 -m unittest discover -s scripts/lab6
|
||||
MSYS_NO_PATHCONV=1 docker compose run --rm --no-deps --volume "$(CURDIR)/infra/otel:/rules:ro" --workdir /rules --entrypoint /bin/promtool prometheus test rules rules_test.yaml
|
||||
|
||||
calibrate:
|
||||
$(PYTHON) -X utf8 scripts/lab6/experiment.py calibrate --base-url "$(BASE_URL)" --output "$(EVIDENCE_DIR)/lab6/calibration.json"
|
||||
|
||||
track2:
|
||||
$(PYTHON) -X utf8 scripts/lab6/experiment.py incidents --base-url "$(BASE_URL)" --output "$(EVIDENCE_DIR)/lab6/incidents.json"
|
||||
|
||||
retry-trace:
|
||||
$(PYTHON) -X utf8 scripts/lab6/diagnostics.py retry --base-url "$(BASE_URL)" --output "$(EVIDENCE_DIR)/lab6/retry.json"
|
||||
|
||||
backend-outage:
|
||||
$(PYTHON) -X utf8 scripts/lab6/diagnostics.py backend --base-url "$(BASE_URL)" --output "$(EVIDENCE_DIR)/lab6/backend.json"
|
||||
|
||||
Reference in New Issue
Block a user