Testing App
Test Three-Tier Stack
In this section of the lab, we will test the following:
- Test the complete application flow from HAProxy through
Node.jsapp to Postgres database - Verify connectivity, data persistence, and load balancing functionality.
Verify VM Connectivity
Confirm all three VMs are running and network accessible from your workstation:
-
Get IP addresses from Prism UI (Compute > VMs) or SSH into each
-
SSH test from HAProxy VM to app and DB:
# On haproxy-user01-01 ssh ubuntu@fe-user01-01 "curl -I http://localhost:3000" ssh ubuntu@db-user01-01 "sudo netstat -tlnp | grep 5432"All VMs must resolve via DHCP hostnames or update /etc/hosts on each VM.
Load Balancing Test
-
Install wrk tool on your jumphost VM
-
Test multiple requests:
Check HAProxy stats for even distribution of traffic.
Let it run for a few minutes or so and observe.
Performance Validation
Monitor resource usage in Prism UI (Compute > VMs > Analyze):
-
App VM: CPU < 50%, Memory < 3GB during load tests
-
DB VM: Disk IOPS low, connections = active users
-
HAProxy: Minimal CPU/RAM usage
Success criteria: 100% API uptime, data persistence, HAProxy health checks green.
Troubleshooting
Open VSCode > Terminal on your jumphost
Check logs and ensure functionality:
ssh ubuntu@haproxy-user01-01-user01 'sudo journalctl -u haproxy -f' # HAProxy logs
ssh ubuntu@fe-user01-01 'pm2 logs' # App logs
ssh ubuntu@db-user01-01-user01 'sudo tail -f /var/log/postgresql/*.log' # Postgres logs
Common issues:
| Issue | Symptoms | Fix |
|---|---|---|
| 502 Bad Gateway | HAProxy can't reach app | Verify app:3000, firewall, hostname resolution confluence.atlassian |
| DB Connection Failed | App logs show Postgres errors | Check postgres service, password, todos DB exists github |
| No HAProxy response | Port 80 blocked | sudo ufw allow 80 or disable firewall |