forked from mtusi2026/mtusi2026lab5
Bring the application, own tests, Dockerfile, toolchain, compose stack, HAProxy, k6 and RustFS configuration, migrations, hooks, evidence and scenario scripts and the CI job from the lab 4 solution commit d2744bc, merge the lab 4 Makefile targets into the lab 5 skeleton Makefile without touching its targets, and append the lab 4 solution variables to the skeleton .env.example. The package and the application follow the contract version 1.5.0, and the image and the throwaway test containers are tagged lab5 so they do not collide with a lab 4 stand on the same host. This is the starting point of the lab 5 cycle: lint, own tests and the offline skeleton check pass before any lab 5 change. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
45 lines
2.3 KiB
Bash
Executable File
45 lines
2.3 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
psql() { docker compose exec -T postgres psql -U messenger -d messenger -c "$1"; }
|
|
header() { echo "date: $(date -u +%FT%TZ) commit: $(git rev-parse --short HEAD)"; }
|
|
counts="SELECT (SELECT count(*) FROM users) users, (SELECT count(*) FROM sessions) sessions, (SELECT count(*) FROM chats) chats, (SELECT count(*) FROM chat_members) members, (SELECT count(*) FROM messages) messages, (SELECT count(*) FROM idempotency_keys) keys, (SELECT count(*) FROM attachments) attachments, (SELECT count(*) FROM message_attachments) links, (SELECT count(*) FROM schema_migrations) versions"
|
|
kdf="SELECT substring(password_hash from '^[$]argon2id[$]v=[0-9]+[$]m=[0-9]+,t=[0-9]+,p=[0-9]+[$]') AS kdf_prefix, count(*) AS users, min(length(password_hash)) AS hash_length FROM users GROUP BY 1"
|
|
tokens="SELECT octet_length(token_hash) AS stored_bytes, count(*) AS sessions FROM sessions GROUP BY 1"
|
|
{
|
|
header
|
|
for table in users sessions chats chat_members messages idempotency_keys attachments message_attachments schema_migrations; do
|
|
echo "\$ psql -c '\\d+ $table'"
|
|
psql "\\d+ $table"
|
|
done
|
|
echo "\$ psql -c 'SELECT version, left(checksum, 12), applied_at FROM schema_migrations'"
|
|
psql "SELECT version, left(checksum, 12) AS checksum, applied_at FROM schema_migrations"
|
|
} > evidence/schema.txt
|
|
{
|
|
header
|
|
echo "\$ psql -c \"$counts\""
|
|
psql "$counts"
|
|
echo "\$ make migrate"
|
|
docker compose run --rm migrate 2>/dev/null
|
|
echo "\$ psql -c \"$counts\""
|
|
psql "$counts"
|
|
} > evidence/migrations.txt
|
|
{
|
|
header
|
|
echo "\$ psql -c \"$kdf\""
|
|
psql "$kdf"
|
|
echo "\$ psql -c \"$tokens\""
|
|
psql "$tokens"
|
|
} > evidence/kdf.txt
|
|
{
|
|
header
|
|
echo "\$ git ls-files secrets .env backups volumes"
|
|
git ls-files secrets .env backups volumes
|
|
echo "(пусто: секретов, .env, дампов и volumes в Git нет)"
|
|
echo "\$ git check-ignore -v secrets/database_url secrets/postgres_password secrets/s3_root_password secrets/s3_secret_access_key .env backups/"
|
|
git check-ignore -v secrets/database_url secrets/postgres_password secrets/s3_root_password secrets/s3_secret_access_key .env backups/
|
|
echo "\$ docker volume ls --filter name=mtusi2026lab5"
|
|
docker volume ls --filter name=mtusi2026lab5
|
|
} > evidence/secrets.txt
|
|
echo "evidence/{schema,migrations,kdf,secrets}.txt обновлены"
|