forked from mtusi2026/mtusi2026lab6
ЛР 6 — БВТ2302 — Лебедев — на 5
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
#!/bin/sh
|
||||
# Полный прогон доказательств lab6 на Compose-стенде; вывод — evidence/ (без токенов, паролей и ключей).
|
||||
# Останавливает/перезапускает контейнеры стенда (worker, БД, Collector, Tempo, Loki, реплики API …).
|
||||
# Volumes не удаляются. Длительность ≈ 90 мин; SKIP_REGRESSION=1 (без тестов lab2–lab5) — ≈ 60 мин,
|
||||
# SKIP_RESEARCH=1 (без трека 1) — ещё −35 мин.
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
. scripts/lib.sh
|
||||
PY=${PYTHON:-python3}
|
||||
B=${BASE_URL:-http://127.0.0.1:8080}
|
||||
export BASE_URL=$B TTL_BASE_URL=${TTL_BASE_URL:-http://127.0.0.1:8081} NO_PROXY=127.0.0.1,localhost no_proxy=127.0.0.1,localhost
|
||||
mkdir -p evidence evidence/incidents evidence/track1 evidence/track2
|
||||
stamp() { echo "# $(now) commit=$(git rev-parse --short HEAD 2>/dev/null || echo n/a) host=$(uname -srm) cpus=$(getconf _NPROCESSORS_ONLN)"; }
|
||||
run() { name=$1; shift; { stamp; echo "\$ $*"; "$@" 2>&1; echo "exit=$?"; } > "evidence/$name.txt" || true; tail -2 "evidence/$name.txt"; }
|
||||
IN_WORKER="dc run --rm --no-deps -T -v $PWD/student-tests:/app/student-tests:ro --entrypoint python worker"
|
||||
IN_API="dc run --rm --no-deps -T -v $PWD/student-tests:/app/student-tests:ro --entrypoint python api"
|
||||
|
||||
./scripts/init-secrets.sh
|
||||
dc --profile ttl up -d --build --wait
|
||||
{ stamp; docker version --format 'docker {{.Server.Version}}'; dc version; dc --profile ttl images; dc --profile ttl ps -a; state; } > evidence/stack.txt 2>&1
|
||||
run migrations sh -c "docker compose --env-file .env exec -T postgres psql -U messenger -d messenger -c 'SELECT version, left(checksum,12) AS checksum, applied_at FROM schema_migrations ORDER BY version'; docker compose --env-file .env logs --no-log-prefix migrate"
|
||||
run broker-bootstrap dc logs --no-log-prefix broker-init
|
||||
run s3-bootstrap dc logs --no-log-prefix s3-init
|
||||
run no-local-files sh -c "for c in \$(docker compose --env-file .env ps -q api worker); do docker inspect -f '{{.Name}} ReadonlyRootfs={{.HostConfig.ReadonlyRootfs}} Tmpfs={{json .HostConfig.Tmpfs}} Mounts={{range .Mounts}}{{.Type}}:{{.Destination}} {{end}}' \$c; done"
|
||||
run published-ports sh -c "docker compose --env-file .env ps --format '{{.Service}} {{.Ports}}' | sort -u"
|
||||
run make-check make check
|
||||
run smoke $PY tests/smoke.py --base-url "$B"
|
||||
# ---------------------------------------------------------------- lab6: наблюдаемость
|
||||
run collector-config-validate dc run --rm --no-deps otel-collector validate --config=/etc/otelcol-contrib/collector.yaml
|
||||
run test-observability $PY student-tests/test_observability.py
|
||||
run observability $PY research/obs_snapshot.py
|
||||
: > evidence/restart-hook.txt
|
||||
run test-telemetry-persistence $PY student-tests/test_telemetry_persistence.py
|
||||
for s in worker-stop db-slow handler-slow db-down telemetry-down collector-down; do
|
||||
run incident-$s $PY research/incidents.py $s --out evidence/incidents
|
||||
done
|
||||
# ---------------------------------------------------------------- публичные проверки отказа и сохранности
|
||||
: > evidence/failover-hook.txt
|
||||
run failover-1 $PY tests/resilience.py --mode failover --action-script scripts/stop-one.sh --base-url "$B"
|
||||
run restore-1 ./scripts/start-replicas.sh
|
||||
run failover-2 $PY tests/resilience.py --mode failover --action-script scripts/stop-one.sh --base-url "$B"
|
||||
run restore-2 ./scripts/start-replicas.sh
|
||||
: > evidence/restart-hook.txt
|
||||
run persistence $PY tests/resilience.py --mode persistence --action-script scripts/restart.sh --base-url "$B"
|
||||
# ---------------------------------------------------------------- регрессия lab2–lab5 (make test при включённой telemetry)
|
||||
if [ "${SKIP_REGRESSION:-0}" != 1 ]; then
|
||||
run test-pipeline $PY student-tests/test_pipeline.py
|
||||
run test-imgproc $IN_WORKER student-tests/test_imgproc.py
|
||||
run defense-demo $PY student-tests/defense_demo.py
|
||||
run test-attachments $PY student-tests/test_attachments.py
|
||||
run test-api $PY student-tests/test_api.py
|
||||
run test-idempotency $PY student-tests/test_idempotency.py
|
||||
run test-expiry $PY student-tests/test_expiry.py
|
||||
run test-cache-race $IN_API student-tests/test_cache_race.py
|
||||
run test-jobs-failures $PY student-tests/test_jobs_failures.py
|
||||
run test-storage-failures $PY student-tests/test_storage_failures.py
|
||||
run test-failures $PY student-tests/test_failures.py
|
||||
run test-track2-lab5 $PY student-tests/test_pipeline_idempotency.py
|
||||
run track2-chaos-seed1 $PY research/track2_chaos.py --seed 1 --uploads 60 --output evidence/track2/chaos-seed1.json
|
||||
fi
|
||||
# ---------------------------------------------------------------- трек 1
|
||||
if [ "${SKIP_RESEARCH:-0}" != 1 ]; then
|
||||
run track1-telemetry-cost $PY research/telemetry_cost.py --reps 3 --rate 60 --window 60 --out evidence/track1
|
||||
fi
|
||||
run jobs-failed dc exec -T api python -m messenger jobs failed --limit 20
|
||||
run jobs-invariants dc exec -T api python -m messenger jobs invariants --settled --verify-bytes
|
||||
run migrations-rerun dc run --rm --no-deps migrate
|
||||
run load $PY tests/load.py --base-url "$B" --duration 30 --concurrency 4 --output evidence/load.json
|
||||
run test-observability-final $PY student-tests/test_observability.py
|
||||
run observability-final $PY research/obs_snapshot.py
|
||||
echo "evidence collected in evidence/"
|
||||
Reference in New Issue
Block a user