forked from mtusi2026/mtusi2026lab5
Bring the stdlib suite and image generator of the lab 5 preparation: make suite-preflight checks services, readiness, schema columns, broker topology and the faults override, and make level3 runs the grade 3 scenarios (smoke through the pipeline, worker down with API, relay and broker restarts, duplicate delivery after ready, poison image, S3 outage with recovery, retries up to JOB_MAX_ATTEMPTS) and checks the invariants into evidence/level3.json. make pipeline-evidence shows the queued job on the broker while the worker is stopped, its properties and contract payload, the 409 before ready and SIGTERM of the relay and the worker; make topology dumps queues, consumers with prefetch, permissions and users. The lab 4 failover and S3 outage scenarios and the upload fault suite now expect 202 and wait for ready, the stack evidence lists the broker and its client packages, and the CI acceptance job runs the pipeline scenarios and the SIGTERM check of the new processes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
52 lines
3.5 KiB
Bash
Executable File
52 lines
3.5 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
base=${1:-http://$(docker compose port lb 8080)}
|
|
stats=http://$(docker compose port lb 8404)/stats\;csv
|
|
header() { echo "date: $(date -u +%FT%TZ) commit: $(git rev-parse --short HEAD)"; }
|
|
{
|
|
header
|
|
echo "\$ docker compose --env-file .env config --quiet && echo valid"
|
|
docker compose --env-file .env config --quiet && echo valid
|
|
echo "\$ docker compose ps --format '{{.Service}} {{.Name}} {{.Status}} {{.Ports}}'"
|
|
docker compose ps --format '{{.Service}} {{.Name}} {{.Status}} {{.Ports}}'
|
|
echo "\$ docker compose config | grep -c container_name"
|
|
docker compose config | grep -c container_name || true
|
|
echo "\$ docker port <каждая реплика api> # реплики не публикуют порт"
|
|
for id in $(docker compose ps -q api); do echo "$(docker inspect -f '{{.Config.Hostname}}' "$id"): [$(docker port "$id")]"; done
|
|
echo "\$ docker inspect: hostname = X-Instance-Id, сети, лимиты CPU (nano) и памяти"
|
|
for id in $(docker compose ps -q); do
|
|
docker inspect -f '{{index .Config.Labels "com.docker.compose.service"}} {{.Config.Hostname}} {{.Name}} nets={{range $k, $v := .NetworkSettings.Networks}}{{$k}},{{end}} cpus={{.HostConfig.NanoCpus}} mem={{.HostConfig.Memory}} user={{.Config.User}} ro={{.HostConfig.ReadonlyRootfs}}' "$id"
|
|
done | sort
|
|
echo "\$ curl LB stats: backend api, server status check"
|
|
curl -fsS "$stats" | python3 -c 'import csv,sys
|
|
for r in csv.DictReader(sys.stdin.read().lstrip("# ").splitlines()):
|
|
if r["pxname"] == "api" and r["status"] != "MAINT (resolution)":
|
|
print(r["svname"], r["status"], r["check_status"], r["check_code"])'
|
|
echo "\$ for i in 1..6: curl -D - $base/health/live | X-Instance-Id"
|
|
for _ in 1 2 3 4 5 6; do curl -fsS -D - -o /dev/null "$base/health/live" | tr -d '\r' | grep -i '^x-instance-id'; done
|
|
} > evidence/stack.txt
|
|
{
|
|
header
|
|
echo "host: $(sysctl -n machdep.cpu.brand_string 2>/dev/null || uname -m), $(sysctl -n hw.ncpu 2>/dev/null) CPU, $(($(sysctl -n hw.memsize 2>/dev/null || echo 0) / 1073741824)) GiB RAM, $(sw_vers -productName 2>/dev/null) $(sw_vers -productVersion 2>/dev/null)"
|
|
echo "docker: $(docker version -f '{{.Server.Version}}'), VM: $(docker info -f '{{.NCPU}}') CPU, $(docker info -f '{{.MemTotal}}') bytes"
|
|
echo "compose: $(docker compose version --short)"
|
|
echo "images:"
|
|
grep -h -E 'image:|@sha256' compose.yaml Dockerfile | sed 's/^ */ /'
|
|
echo "python in image: $(docker exec "$(docker compose ps -q api | head -1)" python -V)"
|
|
echo "haproxy: $(docker compose exec -T lb haproxy -v | head -1)"
|
|
echo "rustfs: $(docker compose exec -T s3 rustfs --version 2>/dev/null | head -1)"
|
|
echo "rabbitmq: $(docker compose exec -T broker rabbitmqctl -q version 2>/dev/null | head -1)"
|
|
echo "packages (uv.lock):"
|
|
for name in fastapi uvicorn uvicorn-worker gunicorn asyncpg argon2-cffi pydantic pydantic-settings dishka structlog redis aiobotocore botocore aiohttp pillow \
|
|
faststream aio-pika aiormq dishka-faststream; do
|
|
printf ' %s %s\n' "$name" "$(sed -n "/^name = \"$name\"$/{n;s/version = \"\(.*\)\"/\1/p;}" uv.lock)"
|
|
done
|
|
echo "process users (service uid command):"
|
|
for id in $(docker compose ps -q); do
|
|
service=$(docker inspect -f '{{index .Config.Labels "com.docker.compose.service"}}' "$id")
|
|
docker top "$id" -eo pid,uid,comm | awk -v s="$service" 'NR > 1 {print " " s, $2, $3}'
|
|
done | sort -u
|
|
} > evidence/environment.txt
|
|
cat evidence/stack.txt evidence/environment.txt
|