forked from mtusi2026/mtusi2026lab2
Bring the application, own tests, Dockerfile, toolchain, compose stack,
HAProxy, k6, RustFS and RabbitMQ configuration, migrations, hooks,
scenario scripts and the CI job from the lab 5 solution commit 64d5c67,
keep the lab 5 Makefile targets on top of the unchanged skeleton
targets, and append the lab 5 solution variables to the skeleton
.env.example. The package and the application follow the contract
version 1.6.0, and the image, the throwaway test containers and the
broker vhost description are tagged lab6 so they do not collide with a
lab 5 stand on the same host.
This is the starting point of the lab 6 cycle: lint, own tests and the
offline skeleton check pass before any lab 6 change.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
41 lines
2.9 KiB
Bash
Executable File
41 lines
2.9 KiB
Bash
Executable File
#!/bin/sh
|
||
set -eu
|
||
cd "$(dirname "$0")/.."
|
||
psql() { docker compose exec -T postgres psql -U messenger -d messenger -X -c "$1"; }
|
||
value() { docker compose exec -T postgres psql -U messenger -d messenger -X -tA -c "$1"; }
|
||
cli() { docker compose run --rm --no-deps -T s3-cli "$@"; }
|
||
bucket=${S3_BUCKET:-messenger-attachments}
|
||
{
|
||
echo "date: $(date -u +%FT%TZ) commit: $(git rev-parse --short HEAD)"
|
||
echo "\$ docker compose ps --format '{{.Service}} {{.Status}} {{.Ports}}'"
|
||
docker compose ps -a --format '{{.Service}} {{.Status}} {{.Ports}}'
|
||
for table in attachments message_attachments; do
|
||
echo "\$ psql -c '\\d $table'"
|
||
psql "\\d $table"
|
||
done
|
||
echo "\$ psql: столбцы bytea во всей схеме (хеши токенов и отпечатки, не файлы)"
|
||
psql "SELECT table_name, column_name FROM information_schema.columns WHERE table_schema = 'public' AND data_type = 'bytea' ORDER BY 1, 2"
|
||
echo "\$ psql: вложения по статусу и максимальный размер строки attachments"
|
||
psql "SELECT status, count(*), max(pg_column_size(a.*)) AS max_row_bytes FROM attachments a GROUP BY status"
|
||
echo "\$ rc object list --recursive root/$bucket/attachments/ | count"
|
||
cli object list --recursive "root/$bucket/attachments/" --json | grep -c '"key"' || true
|
||
echo "\$ rc object list root/$bucket/ (первые 3 объекта, ключи назначены сервером)"
|
||
cli object list --recursive "root/$bucket/attachments/" | head -3
|
||
row=$(value "SELECT object_key || ' ' || sha256 || ' ' || size_bytes FROM attachments WHERE status = 'ready' ORDER BY created_at DESC LIMIT 1")
|
||
key=${row%% *}
|
||
echo "\$ сверка вне API: sha256 и размер последнего ready-вложения в PostgreSQL против байтов объекта в bucket"
|
||
echo "postgres: ${row#* }"
|
||
echo "s3: $(cli sh -c "rc object show root/$bucket/$key | sha256sum | cut -d' ' -f1") $(cli sh -c "rc object show root/$bucket/$key | wc -c" | tr -d ' ')"
|
||
echo "\$ docker inspect api: ReadonlyRootfs, tmpfs, volumes/bind mounts"
|
||
for id in $(docker compose ps -q api); do
|
||
docker inspect -f '{{.Config.Hostname}} ro={{.HostConfig.ReadonlyRootfs}} tmpfs={{json .HostConfig.Tmpfs}} mounts={{range .Mounts}}{{.Type}}:{{.Destination}} {{end}}' "$id"
|
||
done
|
||
echo "\$ docker inspect s3: volume данных"
|
||
docker inspect -f '{{range .Mounts}}{{.Type}}:{{.Name}}:{{.Destination}} {{end}}' "$(docker compose ps -q s3)"
|
||
echo "\$ секреты сервисов: root-ключи S3 только у s3/s3-init/s3-cli"
|
||
docker compose config --format json | python3 -c 'import json,sys
|
||
for name, service in sorted(json.load(sys.stdin)["services"].items()):
|
||
print(name, sorted(s["source"] for s in service.get("secrets", [])))'
|
||
} > evidence/storage-layout.txt
|
||
cat evidence/storage-layout.txt
|