Test Scripts (7 files, 1000+ lines): - 01-database-creation-test.sh: PostgreSQL creation and initialization - 02-private-network-test.sh: Private network isolation (INF-02) - 03-persistence-test.sh: Data persistence verification (INF-04) - 04-security-test.sh: Security compliance (INF-01, INF-02, INF-03) - 99-final-verification.sh: End-to-end student verification - run-all-tests.sh: Test orchestration with fail-fast - quick-test.sh: Quick validation (< 30s) Tests verify: - PostgreSQL in private network → RDS in VPC - Named volume → EBS volume - Resource limits → DB instance class - All INF requirements (01-04) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
94 lines
2.3 KiB
Bash
Executable File
94 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# Lab 05 - Database & RDS
|
|
# Test Orchestration Script
|
|
# Esegue tutti i test con fail-fast behavior
|
|
|
|
set -euo pipefail
|
|
|
|
# Colori per output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
# Directory corrente
|
|
TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
cd "$TEST_DIR"
|
|
|
|
# Contatori globali
|
|
global_pass=0
|
|
global_fail=0
|
|
global_skip=0
|
|
|
|
# Funzioni helper
|
|
inc_global_pass() { ((global_pass++)) || true; }
|
|
inc_global_fail() { ((global_fail++)) || true; }
|
|
inc_global_skip() { ((global_skip++)) || true; }
|
|
|
|
echo "=========================================="
|
|
echo "Lab 05 - Test Suite Orchestration"
|
|
echo "=========================================="
|
|
echo ""
|
|
|
|
# Array dei test da eseguire
|
|
declare -a tests=(
|
|
"$TEST_DIR/01-database-creation-test.sh"
|
|
"$TEST_DIR/02-private-network-test.sh"
|
|
"$TEST_DIR/03-persistence-test.sh"
|
|
"$TEST_DIR/04-security-test.sh"
|
|
"$TEST_DIR/99-final-verification.sh"
|
|
)
|
|
|
|
# Esegui tutti i test
|
|
for test_script in "${tests[@]}"; do
|
|
test_name=$(basename "$test_script")
|
|
|
|
echo -e "${BLUE}Eseguendo: $test_name${NC}"
|
|
echo "----------------------------------------"
|
|
|
|
if [ ! -f "$test_script" ]; then
|
|
echo -e "${RED}ERRORE: Test non trovato: $test_script${NC}"
|
|
inc_global_fail
|
|
continue
|
|
fi
|
|
|
|
# Rendi eseguibile
|
|
chmod +x "$test_script"
|
|
|
|
# Esegui il test e cattura l'exit code
|
|
if bash "$test_script"; then
|
|
test_result=$?
|
|
echo -e "${GREEN}✓ $test_name PASS${NC}"
|
|
echo ""
|
|
else
|
|
test_result=$?
|
|
echo -e "${RED}✗ $test_name FAIL${NC}"
|
|
echo ""
|
|
|
|
# Fail-fast: esci al primo test fallito
|
|
echo -e "${RED}FAIL-FAST: Interrompo esecuzione per errore critico${NC}"
|
|
inc_global_fail
|
|
break
|
|
fi
|
|
done
|
|
|
|
echo "=========================================="
|
|
echo "RIEPILOGO COMPLETO"
|
|
echo "=========================================="
|
|
echo "Test PASS: $global_pass"
|
|
echo "Test FAIL: $global_fail"
|
|
echo "Test SKIP: $global_skip"
|
|
echo "=========================================="
|
|
|
|
if [ $global_fail -gt 0 ]; then
|
|
echo ""
|
|
echo -e "${RED}✗ TEST SUITE FALLITA${NC}"
|
|
echo "Risolvere gli errori e ripetere"
|
|
exit 1
|
|
else
|
|
echo ""
|
|
echo -e "${GREEN}✓ TEST SUITE COMPLETATA CON SUCCESSO${NC}"
|
|
exit 0
|
|
fi
|