Files
laboratori-cloud/labs/lab-03-compute/tests/run-all-tests.sh
Luca Sacchi Ricciardi 23a9ffe443 feat(lab-03): complete Phase 4 - Compute & EC2 lab
Phase Plans (5 files):
- 04-RESEARCH.md: Domain research on Docker limits, healthchecks, EC2 parallels
- 04-VALIDATION.md: Success criteria and validation strategy
- 04-01-PLAN.md: Test infrastructure (RED phase)
- 04-02-PLAN.md: Diátxis documentation
- 04-03-PLAN.md: Infrastructure implementation (GREEN phase)

Test Scripts (6 files, 1300+ lines):
- 01-resource-limits-test.sh: Validate INF-03 compliance
- 02-healthcheck-test.sh: Validate healthcheck configuration
- 03-enforcement-test.sh: Verify resource limits with docker stats
- 04-verify-infrastructure.sh: Infrastructure verification
- 99-final-verification.sh: End-to-end student verification
- run-all-tests.sh: Test orchestration with fail-fast
- quick-test.sh: Fast validation (<30s)

Documentation (11 files, 2500+ lines):
Tutorials (3):
- 01-set-resource-limits.md: EC2 instance types, Docker limits syntax
- 02-implement-healthchecks.md: ELB health check parallels
- 03-dependencies-with-health.md: depends_on with service_healthy

How-to Guides (4):
- check-resource-usage.md: docker stats monitoring
- test-limits-enforcement.md: Stress testing CPU/memory
- custom-healthcheck.md: HTTP, TCP, database healthchecks
- instance-type-mapping.md: Docker limits → EC2 mapping

Reference (3):
- compose-resources-syntax.md: Complete deploy.resources reference
- healthcheck-syntax.md: All healthcheck parameters
- ec2-instance-mapping.md: Instance type mapping table

Explanation (1):
- compute-ec2-parallels.md: Container=EC2, Limits=Instance Type, Healthcheck=ELB

Infrastructure:
- docker-compose.yml: 5 services (web, app, worker, db, stress-test)
  All services: INF-03 compliant (cpus + memory limits)
  All services: healthcheck configured
  EC2 parallels: t2.nano, t2.micro, t2.small, t2.medium, m5.large
- Dockerfile: Alpine 3.19 + stress tools + non-root user

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-03 15:16:58 +02:00

139 lines
4.6 KiB
Bash
Executable File

#!/bin/bash
# Run All Tests - Lab 03: Compute & EC2
# Executes all test scripts in sequence with fail-fast behavior
# Usage: bash labs/lab-03-compute/tests/run-all-tests.sh
set -euo pipefail
# Color definitions
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
BOLD='\033[1m'
NC='\033[0m'
# Get script directory
TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
LAB_DIR="$(cd "$TEST_DIR/.." && pwd)"
# Counter helpers
total_passed=0
total_failed=0
tests_run=0
# Helper functions
print_header() {
echo -e "${BLUE}╔═══════════════════════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}${NC} ${BOLD}$1${NC}"
echo -e "${BLUE}╚═══════════════════════════════════════════════════════════════╝${NC}"
}
print_section() {
echo -e "\n${BLUE}═══════════════════════════════════════════════════════════════${NC}"
echo -e "${BLUE} $1${NC}"
echo -e "${BLUE}═══════════════════════════════════════════════════════════════${NC}\n"
}
print_pass() {
echo -e "${GREEN}${NC} $1"
}
print_fail() {
echo -e "${RED}${NC} $1"
}
# Main execution
print_header "Lab 03 Test Suite - Compute & EC2"
cd "$LAB_DIR"
echo -e "${BLUE}Running all tests in sequence...${NC}\n"
# Test 1: Resource Limits Configuration
print_section "Test 1/4: Resource Limits Configuration"
if bash "$TEST_DIR/01-resource-limits-test.sh"; then
print_pass "Resource limits tests PASSED"
((total_passed++)) || true
else
print_fail "Resource limits tests FAILED"
((total_failed++)) || true
echo -e "\n${YELLOW}Stopping at first failure (fail-fast mode)${NC}"
echo -e "Run individual tests to debug:"
echo -e " bash tests/01-resource-limits-test.sh"
exit 1
fi
((tests_run++)) || true
# Test 2: Healthcheck Configuration
print_section "Test 2/4: Healthcheck Configuration"
if bash "$TEST_DIR/02-healthcheck-test.sh"; then
print_pass "Healthcheck tests PASSED"
((total_passed++)) || true
else
print_fail "Healthcheck tests FAILED"
((total_failed++)) || true
echo -e "\n${YELLOW}Stopping at first failure (fail-fast mode)${NC}"
echo -e "Run individual tests to debug:"
echo -e " bash tests/02-healthcheck-test.sh"
exit 1
fi
((tests_run++)) || true
# Test 3: Resource Enforcement
print_section "Test 3/4: Resource Enforcement Verification"
if bash "$TEST_DIR/03-enforcement-test.sh"; then
print_pass "Resource enforcement tests PASSED"
((total_passed++)) || true
else
print_fail "Resource enforcement tests FAILED"
((total_failed++)) || true
echo -e "\n${YELLOW}Stopping at first failure (fail-fast mode)${NC}"
echo -e "Run individual tests to debug:"
echo -e " bash tests/03-enforcement-test.sh"
exit 1
fi
((tests_run++)) || true
# Test 4: Final Verification
print_section "Test 4/4: Final Verification"
if bash "$TEST_DIR/99-final-verification.sh"; then
print_pass "Final verification PASSED"
((total_passed++)) || true
else
print_fail "Final verification FAILED"
((total_failed++)) || true
echo -e "\n${YELLOW}Stopping at first failure (fail-fast mode)${NC}"
echo -e "Run individual tests to debug:"
echo -e " bash tests/99-final-verification.sh"
exit 1
fi
((tests_run++)) || true
# Summary
print_header "Test Suite Summary"
echo -e "Tests run: $tests_run"
echo -e "${GREEN}Passed: $total_passed${NC}"
if [[ $total_failed -gt 0 ]]; then
echo -e "${RED}Failed: $total_failed${NC}"
fi
if [[ $total_failed -eq 0 ]]; then
echo -e "\n${GREEN}${BOLD}✓✓✓ ALL TESTS PASSED ✓✓✓${NC}\n"
echo -e "Your Lab 03 infrastructure is ready!"
echo -e "Proceed with the tutorials to learn more about:"
echo -e " • EC2 instance type parallels"
echo -e " • Resource limits enforcement"
echo -e " • Healthcheck implementation"
exit 0
else
echo -e "\n${RED}Some tests failed${NC}\n"
echo -e "Run individual tests for details:"
echo -e " bash tests/01-resource-limits-test.sh"
echo -e " bash tests/02-healthcheck-test.sh"
echo -e " bash tests/03-enforcement-test.sh"
echo -e " bash tests/99-final-verification.sh"
exit 1
fi