Skip to content
This repository was archived by the owner on Oct 10, 2025. It is now read-only.

Commit eb44dd9

Browse files
committed
docs: update integration testing guide with SSL automation and fix inconsistencies
- Fix prerequisites command: 'make test-syntax' → 'make lint' - Add SSL/HTTPS testing section with self-signed certificate support - Update service ports and endpoints to reflect nginx reverse proxy - Add VM IP detection timing issue and workaround documentation - Update expected health check output (14 tests, MySQL instead of SQLite) - Add domain-based HTTPS testing instructions - Fix command format to include ENVIRONMENT=local parameter - Update service status table with current architecture - Add recent SSL automation updates section - Remove temporary analysis file Resolves inconsistencies between integration guide and E2E test script identified during manual validation testing.
1 parent 35755fc commit eb44dd9

File tree

1 file changed

+113
-34
lines changed

1 file changed

+113
-34
lines changed

docs/guides/integration-testing-guide.md

Lines changed: 113 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@ following twelve-factor principles for better maintainability and deployment rel
1818

1919
**Total Time**: ~5-8 minutes (streamlined with separated stages)
2020

21+
## Recent Updates
22+
23+
### SSL Certificate Automation
24+
25+
The deployment now includes **automatic SSL certificate generation** for HTTPS support:
26+
27+
- **Self-signed certificates**: Generated automatically for local testing
28+
- **HTTPS endpoints**: All services accessible via HTTPS with nginx reverse proxy
29+
- **Domain-based SSL**: Supports `tracker.test.local` and `grafana.test.local`
30+
- **Browser warnings**: Expected for self-signed certificates (click "Advanced" → "Proceed")
31+
32+
### Key Infrastructure Changes
33+
34+
- **Nginx reverse proxy**: All HTTP services now run behind nginx (ports 80/443)
35+
- **MySQL database**: Replaces SQLite for better production readiness
36+
- **Unified health checks**: All endpoints tested through nginx proxy
37+
- **Environment parameters**: All commands now require `ENVIRONMENT=local` parameter
38+
2139
---
2240

2341
## Automated Testing Alternative
@@ -31,12 +49,12 @@ following twelve-factor principles for better maintainability and deployment rel
3149

3250
The automated test script (`tests/test-e2e.sh`) follows the same steps described in this guide:
3351

34-
- **Step 1**: Prerequisites validation
35-
- **Step 2**: Infrastructure provisioning (`make infra-apply`)
36-
- **Step 3**: Application deployment (`make app-deploy`)
37-
- **Step 4**: Health validation (`make app-health-check`)
52+
- **Step 1**: Prerequisites validation (`make lint`)
53+
- **Step 2**: Infrastructure provisioning (`make infra-apply ENVIRONMENT=local`)
54+
- **Step 3**: Application deployment (`make app-deploy ENVIRONMENT=local`)
55+
- **Step 4**: Health validation (`make app-health-check ENVIRONMENT=local`)
3856
- **Step 5**: Smoke testing (basic functionality validation)
39-
- **Step 6**: Cleanup (`make infra-destroy`)
57+
- **Step 6**: Cleanup (`make infra-destroy ENVIRONMENT=local`)
4058

4159
**Benefits of the automated test**:
4260

@@ -72,7 +90,7 @@ Ensure you have completed the initial setup:
7290

7391
```bash
7492
# Verify prerequisites are met
75-
make test-syntax
93+
make lint
7694
```
7795

7896
**Expected Output**: All syntax validation should pass.
@@ -184,12 +202,26 @@ Provisioning infrastructure for local...
184202
make infra-status ENVIRONMENT=local
185203

186204
# [PROJECT_ROOT] Test SSH connectivity
187-
make vm-ssh
205+
make vm-ssh ENVIRONMENT=local
188206
# (type 'exit' to return)
189207
```
190208

191209
**Expected Output**: VM IP address and successful SSH connection.
192210

211+
**⚠️ VM IP Detection Issue**: If `make infra-status` shows "No IP assigned yet" but you can
212+
see the VM is running (`virsh list`), you may need to refresh the infrastructure state:
213+
214+
```bash
215+
# [PROJECT_ROOT] Refresh infrastructure state to detect VM IP
216+
make infra-refresh-state ENVIRONMENT=local
217+
218+
# [PROJECT_ROOT] Check status again
219+
make infra-status ENVIRONMENT=local
220+
```
221+
222+
This happens because the VM gets its IP from DHCP after cloud-init completes,
223+
but the infrastructure state may not automatically detect this change.
224+
193225
---
194226

195227
## Step 3: Application Deployment - Deploy Application
@@ -275,27 +307,27 @@ Running health check for local...
275307
[INFO] Testing Docker services
276308
✅ Docker daemon
277309
✅ Docker Compose services accessible
278-
✅ Services are running (6 services)
310+
✅ Services are running (5 services)
279311
[INFO] Testing application endpoints
280-
✅ Health check endpoint (port 1313)
281-
✅ API stats endpoint (port 1212)
282-
✅ HTTP tracker endpoint (port 7070)
283-
✅ Grafana endpoint (port 3000)
312+
✅ Health check endpoint (nginx proxy)
313+
✅ API stats endpoint (nginx proxy)
314+
✅ HTTP tracker endpoint (nginx proxy)
315+
✅ Grafana endpoint (port 3100)
284316
[INFO] Testing UDP tracker connectivity
285317
✅ UDP tracker port 6868
286318
✅ UDP tracker port 6969
287319
[INFO] Testing storage and persistence
288320
✅ Storage directory exists
289-
SQLite database file exists
321+
MySQL database connectivity
290322
[INFO] Testing logging and monitoring
291323
✅ Prometheus metrics endpoint
292324
✅ Docker logs accessible
293325
294326
=== HEALTH CHECK REPORT ===
295327
Environment: local
296328
VM IP: 192.168.122.XXX
297-
Total Tests: 12
298-
Passed: 12
329+
Total Tests: 14
330+
Passed: 14
299331
Failed: 0
300332
Success Rate: 100%
301333
@@ -308,7 +340,7 @@ Success Rate: 100%
308340

309341
```bash
310342
# [PROJECT_ROOT] SSH into VM for manual inspection
311-
make ssh
343+
make vm-ssh ENVIRONMENT=local
312344

313345
# [VM] Check service status
314346
cd /home/torrust/github/torrust/torrust-tracker-demo/application
@@ -317,12 +349,20 @@ docker compose ps
317349
# [VM] Check application logs
318350
docker compose logs --tail=20
319351

320-
# [VM] Test endpoints manually
321-
curl http://localhost:1313/health_check
322-
curl http://localhost:1212/api/v1/stats
323-
324352
# Exit back to host
325353
exit
354+
355+
# [PROJECT_ROOT] Test endpoints from host machine
356+
VM_IP=$(cd infrastructure/terraform && tofu output -raw vm_ip)
357+
echo "Testing VM at IP: $VM_IP"
358+
359+
# Test HTTP endpoints
360+
curl http://$VM_IP/health_check
361+
curl "http://$VM_IP/api/v1/stats?token=MyAccessToken"
362+
363+
# Test HTTPS endpoints (expect certificate warnings)
364+
curl -sk https://$VM_IP/health_check
365+
curl -sk "https://$VM_IP/api/v1/stats?token=MyAccessToken"
326366
```
327367

328368
---
@@ -333,27 +373,66 @@ exit
333373

334374
After successful deployment, you should see these services running:
335375

336-
| Service | Port | Status | Purpose |
337-
| ------------------------ | ---------- | ---------- | --------------------- |
338-
| Torrust Tracker (Health) | 1313 | ✅ Running | Health check endpoint |
339-
| Torrust Tracker (API) | 1212 | ✅ Running | REST API and stats |
340-
| Torrust Tracker (HTTP) | 7070 | ✅ Running | HTTP tracker protocol |
341-
| Torrust Tracker (UDP) | 6868, 6969 | ✅ Running | UDP tracker protocol |
342-
| Grafana | 3000 | ✅ Running | Monitoring dashboard |
343-
| Prometheus | 9090 | ✅ Running | Metrics collection |
376+
| Service | Port/Access | Status | Purpose |
377+
| ---------------------- | ------------------------- | ---------- | ---------------------------------- |
378+
| Nginx Proxy | 80 (HTTP), 443 (HTTPS) | ✅ Running | Reverse proxy with SSL termination |
379+
| Torrust Tracker (API) | 1212, via nginx on 80/443 | ✅ Running | REST API and stats |
380+
| Torrust Tracker (HTTP) | 7070, via nginx on 80/443 | ✅ Running | HTTP tracker protocol |
381+
| Torrust Tracker (UDP) | 6868, 6969 | ✅ Running | UDP tracker protocol |
382+
| MySQL Database | 3306 | ✅ Running | Persistent data storage |
383+
| Grafana | 3100, via nginx on 80/443 | ✅ Running | Monitoring dashboard |
384+
| Prometheus | 9090 | ✅ Running | Metrics collection |
385+
386+
**Key Changes from Previous Version**:
387+
388+
- All HTTP services now run behind nginx reverse proxy (ports 80/443)
389+
- SSL/HTTPS support with self-signed certificates for local testing
390+
- MySQL replaces SQLite for better production readiness
391+
- Health check endpoints accessible via nginx proxy
344392

345-
### 5.2 Test Endpoints
393+
### 5.2 SSL/HTTPS Testing
346394

347-
You can test these endpoints from the host machine:
395+
The local environment automatically generates self-signed SSL certificates for testing HTTPS functionality:
348396

349397
```bash
350398
# Get VM IP first
351399
VM_IP=$(cd infrastructure/terraform && tofu output -raw vm_ip)
400+
echo "Testing VM at IP: $VM_IP"
401+
402+
# Test HTTP endpoints
403+
curl http://$VM_IP/health_check
404+
curl "http://$VM_IP/api/v1/stats?token=MyAccessToken"
405+
406+
# Test HTTPS endpoints (expect certificate warnings)
407+
curl -sk https://$VM_IP/health_check
408+
curl -sk "https://$VM_IP/api/v1/stats?token=MyAccessToken"
409+
410+
# Test Grafana (HTTP and HTTPS)
411+
curl -s http://$VM_IP:3100/login | grep -q "Grafana" && echo "✅ Grafana HTTP accessible"
412+
curl -sk https://$VM_IP:3100/login | grep -q "Grafana" && echo "✅ Grafana HTTPS accessible"
413+
```
414+
415+
**Expected Results**:
416+
417+
- HTTP endpoints: Should return "healthy" or JSON responses
418+
- HTTPS endpoints: Should work but show certificate warnings in browsers
419+
- All services accessible through nginx reverse proxy
420+
421+
**Note**: Self-signed certificates will show security warnings in browsers.
422+
Click "Advanced" → "Proceed to site" to continue.
423+
424+
### 5.3 Domain-Based HTTPS Testing (Optional)
425+
426+
For testing domain-based SSL certificates, add entries to your `/etc/hosts` file:
427+
428+
```bash
429+
# Add to /etc/hosts (requires sudo)
430+
echo "$VM_IP tracker.test.local" | sudo tee -a /etc/hosts
431+
echo "$VM_IP grafana.test.local" | sudo tee -a /etc/hosts
352432

353-
# Test endpoints (replace with actual VM IP)
354-
curl http://$VM_IP:1313/health_check
355-
curl http://$VM_IP:1212/api/v1/stats
356-
curl http://$VM_IP:7070
433+
# Test domain-based endpoints
434+
curl -sk https://tracker.test.local/health_check
435+
curl -sk https://grafana.test.local/login
357436
```
358437

359438
---

0 commit comments

Comments
 (0)