48 lines
1.9 KiB
Bash
Executable File
48 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
# Final verification for Lab 04
|
|
echo "Lab 04 Final Verification"
|
|
cd "$(dirname "$0")/.."
|
|
pass=0; fail=0
|
|
check() { if eval "$1"; then echo "✓ $2"; ((pass++)); else echo "✗ $2"; ((fail++)); fi; }
|
|
|
|
cleanup() {
|
|
docker compose down >/dev/null 2>&1 || true
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
# Infrastructure checks
|
|
check "[[ -f docker-compose.yml ]]" "docker-compose.yml exists"
|
|
check "docker compose config &>/dev/null" "Syntax valid"
|
|
|
|
# Start services
|
|
docker compose down >/dev/null 2>&1 || true
|
|
docker compose up -d && sleep 8
|
|
|
|
# Volume checks
|
|
VOLUMES=$(docker volume ls --format '{{.Name}}' | grep -E '^lab-04-storage_(minio-data|db-data|test-data)$' | wc -l)
|
|
check "[[ $VOLUMES -eq 3 ]]" "Named volumes created ($VOLUMES/3)"
|
|
|
|
# MinIO checks
|
|
check "curl -sf http://127.0.0.1:9000/minio/health/live" "MinIO API accessible"
|
|
check "curl -sf http://127.0.0.1:9001 &>/dev/null" "MinIO console accessible"
|
|
|
|
# Persistence check - test volume
|
|
docker exec lab04-test sh -c "echo test > /test/file.txt"
|
|
docker compose restart test && sleep 3
|
|
check "docker exec lab04-test cat /test/file.txt | grep -q test" "Data persists after restart"
|
|
|
|
# Persistence check - MinIO data volume
|
|
docker exec lab04-minio sh -c "mkdir -p /data/tbf && echo ok > /data/tbf/probe.txt"
|
|
docker compose restart minio && sleep 5
|
|
check "docker exec lab04-minio sh -c 'cat /data/tbf/probe.txt' | grep -q ok" "MinIO data persists after restart"
|
|
|
|
# Persistence check - PostgreSQL data volume
|
|
docker exec lab04-db sh -c "psql -U lab04_user -d lab04_db -c \"create table if not exists tbf_probe(msg text); insert into tbf_probe values ('ok');\"" >/dev/null
|
|
docker compose restart db && sleep 5
|
|
DB_COUNT=$(docker exec lab04-db sh -c "psql -U lab04_user -d lab04_db -tAc \"select count(*) from tbf_probe where msg='ok';\"" | tr -d '[:space:]')
|
|
check "test ${DB_COUNT:-0} -ge 1" "Database data persists after restart"
|
|
|
|
echo "Passed: $pass, Failed: $fail"
|
|
[[ $fail -eq 0 ]] && exit 0 || exit 1
|