forked from mtusi2026/mtusi2026lab3
Перенести актуальную lab2 как базу lab3
This commit is contained in:
@@ -4,10 +4,10 @@ CA_FILE ?=
|
||||
ACTION_SCRIPT ?=
|
||||
TLS_ARGS = $(if $(CA_FILE),--ca-file "$(CA_FILE)",)
|
||||
|
||||
.PHONY: help check validate test load test-persistence test-failover
|
||||
.PHONY: help check validate test load test-persistence
|
||||
|
||||
help:
|
||||
@echo "check: offline structure; validate: full OpenAPI (requirements-dev.txt); test: running API; load: synthetic writes"
|
||||
@echo "init/deploy/port-forward: Helm stand; chart-check: Helm lint; reshard SHARDS=2|3; test/test-persistence: API; coverage: Go; research: SQL; check/validate: contract"
|
||||
|
||||
check:
|
||||
$(PYTHON) scripts/check_contract.py
|
||||
@@ -25,6 +25,59 @@ 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)
|
||||
GO ?= go
|
||||
.PHONY: build test-student coverage vet lint fmt research
|
||||
build:
|
||||
$(GO) build -trimpath -o bin/server ./cmd/server
|
||||
test-student:
|
||||
$(GO) test -race ./...
|
||||
coverage:
|
||||
GO="$(GO)" scripts/coverage.sh
|
||||
vet:
|
||||
$(GO) vet ./...
|
||||
lint:
|
||||
golangci-lint run ./...
|
||||
fmt:
|
||||
golangci-lint fmt
|
||||
research:
|
||||
scripts/research.sh
|
||||
|
||||
REGISTRY ?= asisti.registry.twcstorage.ru
|
||||
IMAGE := $(REGISTRY)/mtusi2026lab2
|
||||
IMAGE_TAG ?= dev-$(shell date -u +%Y%m%d%H%M%S)
|
||||
PLATFORM ?= linux/amd64
|
||||
REGISTRY_USER ?= token
|
||||
REGISTRY_TOKEN_FILE ?= $(HOME)/.secrets/twc-registry-token
|
||||
KUBE_CONTEXT ?= dev
|
||||
NAMESPACE ?= highload-applications
|
||||
RELEASE ?= lab2
|
||||
CHART := charts/messenger
|
||||
VALUES ?= $(CHART)/values.yaml
|
||||
HELM_ARGS := --kube-context "$(KUBE_CONTEXT)" -n "$(NAMESPACE)"
|
||||
export KUBE_CONTEXT NAMESPACE RELEASE REGISTRY REGISTRY_USER REGISTRY_TOKEN_FILE
|
||||
|
||||
.PHONY: registry-login build-push init deploy chart-check reload port-forward ready reshard
|
||||
registry-login:
|
||||
docker login "$(REGISTRY)" --username "$(REGISTRY_USER)" --password-stdin < "$(REGISTRY_TOKEN_FILE)"
|
||||
build-push: registry-login
|
||||
docker buildx build --platform "$(PLATFORM)" --target runtime --tag "$(IMAGE):$(IMAGE_TAG)" --metadata-file evidence/image-build.json --push .
|
||||
init:
|
||||
scripts/init-secrets.sh
|
||||
chart-check:
|
||||
helm lint $(CHART) -f "$(VALUES)"
|
||||
helm template "$(RELEASE)" $(CHART) -n "$(NAMESPACE)" -f "$(VALUES)" > /dev/null
|
||||
deploy:
|
||||
helm upgrade --install "$(RELEASE)" $(CHART) $(HELM_ARGS) --create-namespace -f "$(VALUES)" $(if $(IMAGE_DIGEST),--set-string image.digest=$(IMAGE_DIGEST),) --wait --timeout 180s
|
||||
reload:
|
||||
kubectl --context "$(KUBE_CONTEXT)" -n "$(NAMESPACE)" rollout restart deployment/api
|
||||
kubectl --context "$(KUBE_CONTEXT)" -n "$(NAMESPACE)" rollout status deployment/api --timeout=180s
|
||||
port-forward:
|
||||
scripts/port-forward.sh
|
||||
ready:
|
||||
@for attempt in $$(seq 1 60); do curl --fail --silent --max-time 1 "$(BASE_URL)/health/ready" >/dev/null && exit 0; sleep 1; done; echo 'API readiness timeout' >&2; exit 1
|
||||
reshard:
|
||||
SHARDS="$(SHARDS)" scripts/scale-shards.sh
|
||||
|
||||
.PHONY: test-faults
|
||||
test-faults:
|
||||
scripts/test-faults.sh
|
||||
|
||||
Reference in New Issue
Block a user