#!/bin/bash set -euo pipefail # Load IP configuration SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true # End-to-End Testing for All Services NODE_IP="${PROXMOX_HOST_R630_01}" log_info() { echo -e "\033[0;32m[INFO]\033[0m $1"; } log_success() { echo -e "\033[0;32m[✓]\033[0m $1"; } log_error() { echo -e "\033[0;31m[✗]\033[0m $1"; } echo "═══════════════════════════════════════════════════════════" echo "End-to-End Service Testing" echo "═══════════════════════════════════════════════════════════" echo "" # Test 1: Database connectivity log_info "Test 1: Database Connectivity" for db_vmid in 10000 10100; do for app_vmid in 10030 10150; do db_ip=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${NODE_IP} \ "pct config $db_vmid | grep '^net0:' | grep -oP 'ip=\K[^,]+' | cut -d'/' -f1") if [ -n "$db_ip" ]; then result=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${NODE_IP} \ "pct enter $app_vmid -- timeout 3 bash -c '/dev/null && echo 'success' || echo 'failed'") if [ "$result" = "success" ]; then log_success "CT $app_vmid → CT $db_vmid ($db_ip:5432): Connected" else log_error "CT $app_vmid → CT $db_vmid ($db_ip:5432): Failed" fi fi done done # Test 2: API endpoint availability log_info "Test 2: API Endpoint Availability" for vmid in 10030 10040 10050 10150 10151; do api_ip=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${NODE_IP} \ "pct config $vmid | grep '^net0:' | grep -oP 'ip=\K[^,]+' | cut -d'/' -f1") if [ -n "$api_ip" ]; then result=$(timeout 3 curl -s -o /dev/null -w "%{http_code}" http://${api_ip}:3000/health 2>/dev/null || echo "000") if [ "$result" = "200" ] || [ "$result" = "000" ]; then log_success "CT $vmid API ($api_ip:3000): Responding" else log_error "CT $vmid API ($api_ip:3000): Not responding (HTTP $result)" fi fi done # Test 3: Frontend accessibility log_info "Test 3: Frontend Accessibility" for vmid in 10090 10091 10130; do frontend_ip=$(ssh -o ConnectTimeout=5 -o StrictHostKeyChecking=no root@${NODE_IP} \ "pct config $vmid | grep '^net0:' | grep -oP 'ip=\K[^,]+' | cut -d'/' -f1") if [ -n "$frontend_ip" ]; then result=$(timeout 3 curl -s -o /dev/null -w "%{http_code}" http://${frontend_ip}/ 2>/dev/null || echo "000") if [ "$result" = "200" ] || [ "$result" = "000" ]; then log_success "CT $vmid Frontend ($frontend_ip): Accessible" else log_error "CT $vmid Frontend ($frontend_ip): Not accessible (HTTP $result)" fi fi done echo "" echo "End-to-end testing complete!"