This directory contains tests specific to infrastructure provisioning and configuration validation.
Tests in this directory focus on:
- Infrastructure configuration validation (Terraform/OpenTofu, cloud-init)
- Infrastructure directory structure verification
- Infrastructure script validation
- Infrastructure template processing
These tests validate infrastructure components without performing actual deployment. They are static validation tests that ensure:
- Configuration files are syntactically correct
- Required infrastructure files and directories exist
- Scripts have proper permissions
- Templates are processable
test-unit-config.sh- Main infrastructure configuration validation test suitetest-unit-infrastructure.sh- Infrastructure components validationtest-unit-scripts.sh- Infrastructure scripts validation
- Terraform/OpenTofu Validation - Ensures infrastructure code is valid
- Cloud-init Template Validation - Checks provisioning templates
- Infrastructure Script Validation - Verifies infrastructure automation scripts
- Configuration Template Processing - Tests infrastructure config generation
- Infrastructure Structure Validation - Verifies infrastructure directory layout
# Run all infrastructure tests
./test-unit-config.sh
# Run specific test categories
./test-unit-config.sh terraform # Terraform/OpenTofu only
./test-unit-config.sh templates # Config templates only
./test-unit-config.sh structure # Structure only
./test-unit-config.sh cloud-init # Cloud-init templates only
./test-unit-config.sh scripts # Infrastructure scripts only✅ Infrastructure layer tests:
- Terraform/OpenTofu configuration validation
- Cloud-init template validation
- Infrastructure provisioning scripts
- Infrastructure configuration templates
- Infrastructure directory structure
- VM-level configurations
❌ Application tests (belong in application/tests/):
- Docker Compose file validation
- Application configuration files
- Application deployment scripts
- Service-specific configurations
❌ Project-wide tests (belong in tests/ at project root):
- Root-level Makefile
- Project structure spanning multiple layers
- Tool availability checks
- Cross-cutting documentation
This test suite is part of a three-layer testing architecture:
- Infrastructure Tests (
infrastructure/tests/) - Infrastructure provisioning (this directory) - Application Tests (
application/tests/) - Application deployment - Project Tests (
tests/) - Cross-cutting project validation
Each layer focuses on its specific concerns and can be run independently.
When adding new infrastructure tests:
- Categorize correctly - Ensure the test belongs to the infrastructure layer
- Follow naming conventions - Use
test_function_name()format - Add to main suite - Include in
run_infrastructure_tests()function - Update help - Add command options if needed
- Document purpose - Explain what the test validates
test_new_infrastructure_feature() {
log_info "Testing new infrastructure feature..."
local failed=0
# Test implementation here
if [[ ${failed} -eq 0 ]]; then
log_success "New infrastructure feature validation passed"
fi
return ${failed}
}All tests generate detailed logs in /tmp/:
- E2E:
/tmp/torrust-e2e-test.log - Unit Config:
/tmp/torrust-unit-config-test.log - Unit Scripts:
/tmp/torrust-unit-scripts-test.log
See docs/testing/test-strategy.md for complete testing strategy and documentation.