7.8 KiB
phase, plan, type, wave, depends_on, files_modified, autonomous, requirements, user_setup, must_haves
| phase | plan | type | wave | depends_on | files_modified | autonomous | requirements | user_setup | must_haves | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 04-lab-03-compute-ec2 | 01 | execute | 0 |
|
true |
|
|
Purpose: Establish verification foundation before implementing compute infrastructure. Tests fail initially (RED phase) and pass after implementation (GREEN phase in Plan 04-03).
Output: 6 bash test scripts covering resource limits validation, healthcheck testing, enforcement verification, and final verification for students.
<execution_context> @/home/luca/.claude/get-shit-done/workflows/execute-plan.md @/home/luca/.claude/get-shit-done/templates/summary.md </execution_context>
@.planning/REQUIREMENTS.md @.planning/phases/04-lab-03-compute-ec2/04-RESEARCH.md @.planning/phases/04-lab-03-compute-ec2/04-VALIDATION.md @.planning/phases/03-lab-02-network-vpc/03-01-PLAN.mdTest Patterns from Phase 2 and 3
From labs/lab-01-iam/tests/99-final-verification.sh:
- Use
set -euo pipefailfor error handling - Color-coded output (GREEN for pass, RED for fail, BLUE for info)
- Summary with pass/fail counts
- Exit code 0 for all pass, 1 for any failure
From labs/lab-02-network/tests/04-verify-infrastructure.sh:
- Parse docker-compose.yml with
docker compose config - Use jq for JSON parsing when needed
- Verify compliance with grep patterns
- Use awk for robust counting
Key Docker Commands for Testing
Resource Limits Verification
# Check if service has CPU limit
docker compose config | grep -A 10 "service_name:" | grep -c "cpus:"
# Check if service has memory limit
docker compose config | grep -A 10 "service_name:" | grep -c "memory:"
# Get container limits
docker inspect container_name --format '{{.HostConfig.NanoCpus}}'
docker inspect container_name --format '{{.HostConfig.Memory}}'
Healthcheck Verification
# Check if service has healthcheck
docker compose config | grep -A 20 "service_name:" | grep -c "healthcheck:"
# Get container health status
docker inspect container_name --format '{{.State.Health.Status}}'
Resource Monitoring
# Get live stats
docker stats --no-stream
# Get specific container stats
docker stats container_name --no-stream --format "{{.CPUPerc}}\t{{.MemUsage}}"
Testing Strategy
Test 1: Resource Limits Configuration
Purpose: Verify docker-compose.yml has resource limits defined Expected Result: FAIL initially (no limits configured) Pass Criteria After Implementation: All services have cpus and memory limits
Test 2: Healthcheck Configuration
Purpose: Verify services have healthchecks defined Expected Result: FAIL initially (no healthchecks configured) Pass Criteria After Implementation: All services have valid healthchecks
Test 3: Resource Enforcement
Purpose: Deploy test container and verify limits are enforced Expected Result: FAIL initially (no test container defined) Pass Criteria After Implementation: docker stats shows enforcement
Test 4: INF-03 Compliance
Purpose: Verify mandatory resource limits for all services Expected Result: FAIL initially Pass Criteria After Implementation: 100% compliance
Implementation Notes
- Directory Structure:
labs/lab-03-compute/
├── tests/
│ ├── 01-resource-limits-test.sh
│ ├── 02-healthcheck-test.sh
│ ├── 03-enforcement-test.sh
│ ├── 99-final-verification.sh
│ ├── 99-final-verification.sh
│ └── 99-final-verification.sh
├── docker-compose.yml (created in 04-03)
└── README.md
-
Test Execution Order:
- 01-resource-limits-test.sh: Parse compose file for limits
- 02-healthcheck-test.sh: Parse compose file for healthchecks
- 03-enforcement-test.sh: Deploy test and verify enforcement
- 99-final-verification.sh: End-to-end student verification
-
Error Handling:
- Each test should be independent
- Use descriptive error messages
- Provide remediation hints
-
Color Coding:
RED='\033[0;31m' GREEN='\033[0;32m' BLUE='\033[0;34m' BOLD='\033[1m' NC='\033[0m'
Success Criteria
Plan 04-01 is complete when:
- All 6 test scripts created
- Each script meets minimum line requirements
- Tests fail when executed on empty/non-existent lab-03-compute
- 99-final-verification.sh executes all tests in sequence
- Tests cover: resource limits, healthchecks, enforcement, INF-03