Skip to content

Commit 083187f

Browse files
committed
refactor k8s ci test
Signed-off-by: JaredforReal <[email protected]>
1 parent 7e639f4 commit 083187f

File tree

8 files changed

+1393
-975
lines changed

8 files changed

+1393
-975
lines changed

โ€Ž.github/workflows/k8s-integration-test.ymlโ€Ž

Lines changed: 25 additions & 975 deletions
Large diffs are not rendered by default.
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
# Kubernetes Integration Test Workflows
2+
3+
This directory contains modular GitHub Actions workflows for testing the semantic-router Kubernetes deployment.
4+
5+
## ๐Ÿ“ File Structure
6+
7+
```
8+
.github/workflows/k8s-integration/
9+
โ”œโ”€โ”€ README.md # This file
10+
โ”œโ”€โ”€ shared-config.yml # Shared configuration and templates
11+
โ”œโ”€โ”€ validate-manifests.yml # Kubernetes manifest validation
12+
โ”œโ”€โ”€ kind-integration-test.yml # Kind cluster integration testing
13+
โ”œโ”€โ”€ api-functionality-test.yml # Comprehensive API testing
14+
โ”œโ”€โ”€ config-test.yml # Configuration validation
15+
โ””โ”€โ”€ security-scan.yml # Security scanning
16+
```
17+
18+
## ๐Ÿ”„ Workflow Architecture
19+
20+
The main workflow (`k8s-integration-test.yml`) orchestrates the following modular workflows:
21+
22+
```mermaid
23+
graph TD
24+
A[Main Workflow] --> B[validate-manifests]
25+
A --> C[test-with-custom-config]
26+
A --> D[security-scan]
27+
B --> E[kind-integration-test]
28+
E --> F[test-api-functionality]
29+
B --> G[summary]
30+
C --> G
31+
D --> G
32+
F --> G
33+
```
34+
35+
## ๐Ÿ“‹ Workflow Modules
36+
37+
### 1. **validate-manifests.yml**
38+
39+
- **Purpose**: Validates Kubernetes manifests using kubeconform
40+
- **Dependencies**: None
41+
- **Outputs**: Validated manifest artifacts
42+
43+
### 2. **kind-integration-test.yml**
44+
45+
- **Purpose**: Tests deployment in a real kind cluster
46+
- **Dependencies**: validate-manifests
47+
- **Features**:
48+
- Creates CI-optimized kind cluster
49+
- Builds and loads Docker images
50+
- Deploys semantic-router
51+
- Tests service connectivity
52+
- Basic API functionality tests
53+
54+
### 3. **api-functionality-test.yml**
55+
56+
- **Purpose**: Comprehensive API testing with 14 test cases
57+
- **Dependencies**: kind-integration-test
58+
- **Features**:
59+
- Health check testing
60+
- Model endpoint testing
61+
- Classification API testing (intent, PII, security)
62+
- Batch processing testing
63+
- Error handling testing
64+
- Performance testing
65+
- Multi-category testing
66+
67+
### 4. **config-test.yml**
68+
69+
- **Purpose**: Configuration validation and overlay testing
70+
- **Dependencies**: validate-manifests
71+
- **Features**:
72+
- Kustomize overlay validation
73+
- ConfigMap generation testing
74+
- Observability stack validation
75+
- AI Gateway configuration validation
76+
77+
### 5. **security-scan.yml**
78+
79+
- **Purpose**: Security scanning of Kubernetes manifests
80+
- **Dependencies**: validate-manifests
81+
- **Features**:
82+
- Trivy security scanning
83+
- Checkov policy scanning
84+
- SARIF report generation
85+
86+
## ๐Ÿš€ Benefits of Modular Design
87+
88+
### **Maintainability**
89+
90+
- Each workflow has a single responsibility
91+
- Easier to debug and modify individual components
92+
- Clear separation of concerns
93+
94+
### **Reusability**
95+
96+
- Workflows can be reused in other contexts
97+
- Easy to add new test scenarios
98+
- Configurable parameters for different environments
99+
100+
### **Performance**
101+
102+
- Parallel execution where possible
103+
- Faster feedback on specific failures
104+
- Reduced resource usage through targeted testing
105+
106+
### **Debugging**
107+
108+
- Isolated failure points
109+
- Detailed logs for each component
110+
- Easier to identify and fix issues
111+
112+
## ๐Ÿ”ง Configuration
113+
114+
### **Environment Variables**
115+
116+
```yaml
117+
env:
118+
KIND_VERSION: v0.20.0
119+
KUBECTL_VERSION: v1.28.0
120+
KUSTOMIZE_VERSION: v5.7.1
121+
```
122+
123+
### **Workflow Inputs**
124+
125+
Each workflow accepts configurable inputs:
126+
127+
- `kind_version`: Kind cluster version
128+
- `kustomize_version`: Kustomize version
129+
- `kubectl_version`: kubectl version
130+
131+
## ๐Ÿ“Š Test Coverage
132+
133+
| Test Type | Coverage | Status |
134+
| -------------------- | ----------- | ------ |
135+
| Manifest Validation | โœ… Complete | Active |
136+
| Service Connectivity | โœ… Complete | Active |
137+
| API Functionality | โœ… 14 Tests | Active |
138+
| Configuration | โœ… Complete | Active |
139+
| Security Scanning | โœ… Complete | Active |
140+
| Error Handling | โœ… Complete | Active |
141+
| Performance | โœ… Complete | Active |
142+
143+
## ๐Ÿ› ๏ธ Usage
144+
145+
### **Running Individual Workflows**
146+
147+
```bash
148+
# Run only manifest validation
149+
gh workflow run validate-manifests.yml
150+
151+
# Run only API tests
152+
gh workflow run api-functionality-test.yml
153+
```
154+
155+
### **Running Full Test Suite**
156+
157+
```bash
158+
# Run complete integration test
159+
gh workflow run k8s-integration-test.yml
160+
```
161+
162+
## ๐Ÿ” Troubleshooting
163+
164+
### **Common Issues**
165+
166+
1. **Kustomize Version Issues**
167+
168+
- Check `shared-config.yml` for version compatibility
169+
- Update version in workflow inputs if needed
170+
171+
2. **Kind Cluster Issues**
172+
173+
- Verify Docker is running
174+
- Check available disk space
175+
- Review kind configuration in workflow
176+
177+
3. **API Test Failures**
178+
- Check pod logs for initialization issues
179+
- Verify model downloads completed
180+
- Review API endpoint responses
181+
182+
### **Debug Commands**
183+
184+
```bash
185+
# Check workflow status
186+
gh run list --workflow=k8s-integration-test.yml
187+
188+
# View specific run logs
189+
gh run view <run-id> --log
190+
191+
# Download artifacts
192+
gh run download <run-id>
193+
```
194+
195+
## ๐Ÿ“ˆ Performance Metrics
196+
197+
| Metric | Before | After | Improvement |
198+
| ------------------ | ---------- | ---------------- | ------------- |
199+
| File Size | 1124 lines | 150 lines (main) | 87% reduction |
200+
| Maintainability | Low | High | โœ… |
201+
| Debug Time | High | Low | โœ… |
202+
| Parallel Execution | Limited | Full | โœ… |
203+
| Reusability | None | High | โœ… |
204+
205+
## ๐Ÿ”ฎ Future Enhancements
206+
207+
- [ ] Add observability stack testing
208+
- [ ] Add AI Gateway end-to-end testing
209+
- [ ] Implement test result caching
210+
- [ ] Add performance benchmarking
211+
- [ ] Create test result dashboards
212+
213+
## ๐Ÿ“ Contributing
214+
215+
When adding new tests:
216+
217+
1. Create a new workflow file in this directory
218+
2. Update the main workflow to include the new module
219+
3. Update this README with the new workflow details
220+
4. Test the integration thoroughly
221+
222+
## ๐Ÿ“š References
223+
224+
- [GitHub Actions Reusable Workflows](https://docs.github.com/en/actions/using-workflows/reusing-workflows)
225+
- [Kind Documentation](https://kind.sigs.k8s.io/)
226+
- [Kustomize Documentation](https://kustomize.io/)
227+
- [Trivy Security Scanner](https://trivy.dev/)
228+
- [Checkov Policy Scanner](https://www.checkov.io/)

0 commit comments

Comments
ย (0)