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>
80 lines
2.4 KiB
Bash
Executable File
80 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# Quick Test - Lab 03: Compute & EC2
|
|
# Fast validation for development (< 30 seconds)
|
|
# Usage: bash labs/lab-03-compute/tests/quick-test.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)"
|
|
|
|
# Quick checks (no verbose output)
|
|
echo -e "${BLUE}Quick Test - Lab 03: Compute & EC2${NC}\n"
|
|
|
|
# Check 1: File exists
|
|
if [[ ! -f "$LAB_DIR/docker-compose.yml" ]]; then
|
|
echo -e "${RED}✗ docker-compose.yml not found${NC}"
|
|
exit 1
|
|
fi
|
|
echo -e "${GREEN}✓${NC} docker-compose.yml exists"
|
|
|
|
# Check 2: Syntax valid
|
|
if ! docker compose config &> /dev/null; then
|
|
echo -e "${RED}✗ docker-compose.yml syntax error${NC}"
|
|
exit 1
|
|
fi
|
|
echo -e "${GREEN}✓${NC} Syntax valid"
|
|
|
|
# Check 3: Services defined
|
|
SERVICES=$(docker compose config --services 2>/dev/null)
|
|
SERVICE_COUNT=$(echo "$SERVICES" | wc -l)
|
|
if [[ $SERVICE_COUNT -lt 3 ]]; then
|
|
echo -e "${RED}✗ Only $SERVICE_COUNT services (need 3+)${NC}"
|
|
exit 1
|
|
fi
|
|
echo -e "${GREEN}✓${NC} $SERVICE_COUNT services defined"
|
|
|
|
# Check 4: Resource limits (INF-03)
|
|
NON_COMPLIANT=0
|
|
for service in $SERVICES; do
|
|
has_cpu=$(docker compose config 2>/dev/null | grep -A 30 "^$service:" | grep -c "cpus:" || echo "0")
|
|
has_mem=$(docker compose config 2>/dev/null | grep -A 30 "^$service:" | grep -c "memory:" || echo "0")
|
|
if [[ $has_cpu -eq 0 || $has_mem -eq 0 ]]; then
|
|
((NON_COMPLIANT++)) || true
|
|
fi
|
|
done
|
|
if [[ $NON_COMPLIANT -gt 0 ]]; then
|
|
echo -e "${RED}✗ $NON_COMPLIANT services missing resource limits (INF-03)${NC}"
|
|
exit 1
|
|
fi
|
|
echo -e "${GREEN}✓${NC} INF-03 compliant (all services have limits)"
|
|
|
|
# Check 5: Healthchecks
|
|
MISSING_HC=0
|
|
for service in $SERVICES; do
|
|
has_hc=$(docker compose config 2>/dev/null | grep -A 50 "^$service:" | grep -c "healthcheck:" || echo "0")
|
|
if [[ $has_hc -eq 0 ]]; then
|
|
((MISSING_HC++)) || true
|
|
fi
|
|
done
|
|
if [[ $MISSING_HC -gt 0 ]]; then
|
|
echo -e "${YELLOW}⚠ $MISSING_HC services missing healthchecks${NC}"
|
|
else
|
|
echo -e "${GREEN}✓${NC} All services have healthchecks"
|
|
fi
|
|
|
|
# Summary
|
|
echo -e "\n${GREEN}${BOLD}✓ Quick test PASSED${NC}\n"
|
|
echo -e "For full verification, run:"
|
|
echo -e " bash tests/run-all-tests.sh"
|
|
echo -e " bash tests/99-final-verification.sh"
|