Skip to content

Commit 357fdf2

Browse files
committed
refactor: reorganize tests into three-layer architecture
- Move Docker Compose tests to application/tests/ layer - Move Makefile and project-wide tests to tests/ layer - Keep infrastructure tests in infrastructure/tests/ layer - Create comprehensive test organization documentation - Add layer-specific test scripts and README files - Establish clear separation of concerns for test responsibilities This fixes the mixed-layer test organization where infrastructure/tests/ contained tests belonging to different architectural layers, violating the separation of concerns principle. New test structure: - infrastructure/tests/ - Infrastructure provisioning validation - application/tests/ - Application deployment validation - tests/ - Project-wide and cross-cutting validation Includes governance documentation to prevent future misorganization.
1 parent f6f7a93 commit 357fdf2

File tree

8 files changed

+1624
-200
lines changed

8 files changed

+1624
-200
lines changed

application/tests/README.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Application Tests
2+
3+
This directory contains tests specific to application deployment and configuration validation.
4+
5+
## Purpose
6+
7+
Tests in this directory focus on:
8+
9+
- **Application configuration validation** (Docker Compose, environment files)
10+
- **Application directory structure verification**
11+
- **Deployment script validation**
12+
- **Service configuration testing** (Grafana, monitoring configs)
13+
14+
## Test Scope
15+
16+
These tests validate application components **without performing actual deployment**.
17+
They are static validation tests that ensure:
18+
19+
- Configuration files are syntactically correct
20+
- Required files and directories exist
21+
- Scripts have proper permissions
22+
- Service configurations are valid
23+
24+
## Test Organization
25+
26+
### Current Tests
27+
28+
- `test-unit-application.sh` - Main application validation test suite
29+
30+
### Test Categories
31+
32+
1. **Docker Compose Validation** - Ensures `compose.yaml` is valid
33+
2. **Configuration Validation** - Checks `.env` templates and config files
34+
3. **Structure Validation** - Verifies application directory structure
35+
4. **Script Validation** - Checks deployment scripts exist and are executable
36+
5. **Service Configuration** - Validates Grafana dashboards and other service configs
37+
38+
## Usage
39+
40+
```bash
41+
# Run all application tests
42+
./test-unit-application.sh
43+
44+
# Run specific test categories
45+
./test-unit-application.sh docker # Docker Compose only
46+
./test-unit-application.sh config # Configuration only
47+
./test-unit-application.sh structure # Structure only
48+
./test-unit-application.sh scripts # Scripts only
49+
./test-unit-application.sh grafana # Grafana config only
50+
```
51+
52+
## Test Organization Guidelines
53+
54+
### What Belongs Here
55+
56+
**Application layer tests**:
57+
58+
- Docker Compose file validation
59+
- Application configuration files (`.env`, service configs)
60+
- Application deployment scripts
61+
- Service-specific configurations (Grafana, Prometheus configs)
62+
- Application directory structure
63+
64+
### What Does NOT Belong Here
65+
66+
**Infrastructure tests** (belong in `infrastructure/tests/`):
67+
68+
- Terraform/OpenTofu configurations
69+
- Cloud-init templates
70+
- Infrastructure provisioning scripts
71+
- VM-level configurations
72+
73+
**Project-wide tests** (belong in `tests/` at project root):
74+
75+
- Root-level Makefile
76+
- Project structure spanning multiple layers
77+
- Tool availability checks
78+
- Cross-cutting documentation
79+
80+
## Integration with Other Test Layers
81+
82+
This test suite is part of a three-layer testing architecture:
83+
84+
1. **Infrastructure Tests** (`infrastructure/tests/`) - Infrastructure provisioning
85+
2. **Application Tests** (`application/tests/`) - Application deployment (this directory)
86+
3. **Project Tests** (`tests/`) - Cross-cutting project validation
87+
88+
Each layer focuses on its specific concerns and can be run independently.
89+
90+
## Adding New Tests
91+
92+
When adding new application tests:
93+
94+
1. **Categorize correctly** - Ensure the test belongs to the application layer
95+
2. **Follow naming conventions** - Use `test_function_name()` format
96+
3. **Add to main suite** - Include in `run_application_tests()` function
97+
4. **Update help** - Add command options if needed
98+
5. **Document purpose** - Explain what the test validates
99+
100+
### Example Test Function
101+
102+
```bash
103+
test_new_application_feature() {
104+
log_info "Testing new application feature..."
105+
106+
local failed=0
107+
# Test implementation here
108+
109+
if [[ ${failed} -eq 0 ]]; then
110+
log_success "New application feature validation passed"
111+
fi
112+
113+
return ${failed}
114+
}
115+
```
116+
117+
## Related Documentation
118+
119+
- [Infrastructure Tests](../infrastructure/tests/README.md)
120+
- [Project Tests](../tests/README.md)
121+
- [Testing Strategy](../docs/testing/test-strategy.md)

0 commit comments

Comments
 (0)