This document describes the automated testing strategy for the Torrust Tracker Demo project.
The project follows a layered testing approach that separates concerns and provides different levels of validation.
Purpose: Validate the complete twelve-factor deployment workflow
Location: tests/test-e2e.sh
Command: make test
What it tests:
- Complete infrastructure provisioning (
make infra-apply) - Application deployment (
make app-deploy) - Health validation (
make health-check) - Mandatory smoke testing (tracker functionality validation)
- Cleanup (
make infra-destroy)
Follows: Exactly mirrors docs/guides/integration-testing-guide.md
Duration: ~5-8 minutes
Cost: High (deploys real infrastructure)
Value: High (validates entire system)
# Run E2E test
make test ENVIRONMENT=local
# Run E2E test without cleanup (for debugging)
SKIP_CLEANUP=true make test ENVIRONMENT=localPurpose: Validate individual components without infrastructure deployment
Location: infrastructure/tests/test-unit-*.sh
Command: make test-unit
Script: test-unit-config.sh
What it tests:
- Terraform/OpenTofu configuration validation
- Docker Compose syntax validation
- Makefile syntax validation
- Project structure validation
- Required tools availability
- Configuration template processing
Note: YAML and shell script syntax validation is handled by ./scripts/lint.sh
# Run all unit tests
make test-unit
# Run only configuration tests
infrastructure/tests/test-unit-config.sh
# Run specific syntax tests
infrastructure/tests/test-unit-config.sh terraform
infrastructure/tests/test-unit-config.sh dockerScript: test-unit-scripts.sh
What it tests:
- Script existence and permissions
- Script help functionality
- Parameter validation
- Coding standards compliance
- Directory structure
# Run script unit tests
infrastructure/tests/test-unit-scripts.sh
# Test specific script
infrastructure/tests/test-unit-scripts.sh provision
infrastructure/tests/test-unit-scripts.sh deployDuration: ~1-2 minutes
Cost: Low (no infrastructure deployment)
Value: Medium (catches syntax and configuration errors early)
Purpose: Fast feedback on code quality
Command: make test-syntax or make lint
What it tests:
- All file syntax using
scripts/lint.sh - YAML, Shell, Markdown validation
- Code quality standards
# Run syntax validation
make test-syntax
# Or using alias
make lintDuration: ~30 seconds
Cost: Very low
Value: High (prevents broken commits)
Purpose: Human validation and exploratory testing
Location: docs/guides/integration-testing-guide.md
When to use:
- Testing new features manually
- Validating complex user workflows
- Debugging deployment issues
- Training and documentation
# 1. Fast feedback during development
make test-syntax
# 2. Validate changes without deployment
make test-unit
# 3. Full validation before commit/PR
make test ENVIRONMENT=local- E2E tests use the exact same commands as the integration guide
- No duplication of deployment logic
- Tests what users actually do
- Unit tests provide fast feedback without infrastructure
- Syntax tests catch errors in seconds
- Developers can test locally without waiting
- Tests use existing scripts and commands
- Changes to deployment automatically reflected in tests
- Clear separation of concerns
- Unit tests run without infrastructure costs
- E2E tests only when needed (PRs, releases)
- Syntax tests run on every commit
test-integration.sh- DEPRECATED: Usetest-e2e.shtest-local-setup.sh- DEPRECATED: Usetest-unit-config.sh+test-unit-scripts.sh
# OLD: Complex integration test
infrastructure/tests/test-integration.sh
# NEW: E2E test following integration guide
make test
# OLD: Mixed infrastructure/syntax test
infrastructure/tests/test-local-setup.sh
# NEW: Focused unit tests
make test-unitLegacy tests are maintained for compatibility but marked as deprecated:
# Still works but shows deprecation warning
make test-legacyE2E test fails with infrastructure errors:
# Check prerequisites
make test-syntax
# Check VM status
make infra-status
# Clean up and retry
make infra-destroy && make testUnit tests fail with tool missing:
# Install missing tools
make install-deps
# Check tool availability
infrastructure/tests/test-unit-config.sh toolsSyntax tests fail:
# Run specific linting
./scripts/lint.sh --yaml
./scripts/lint.sh --shell
./scripts/lint.sh --markdownAll tests generate detailed logs:
- E2E:
/tmp/torrust-e2e-test.log - Unit Config:
/tmp/torrust-unit-config-test.log - Unit Scripts:
/tmp/torrust-unit-scripts-test.log
When adding new functionality:
- Add unit tests first - Test configuration and scripts
- Update E2E test if needed - Usually automatic if using make commands
- Update documentation - Keep integration guide current
- Test all levels - Syntax → Unit → E2E
This layered approach ensures fast feedback during development while maintaining comprehensive validation of the complete system.