Some checks failed
Test / test (push) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
207 lines
5.5 KiB
Bash
Executable File
207 lines
5.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# End-to-End Full Stack Test
|
|
# Tests the complete infrastructure stack
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
log_info() {
|
|
echo -e "${GREEN}[INFO]${NC} $1"
|
|
}
|
|
|
|
log_warn() {
|
|
echo -e "${YELLOW}[WARN]${NC} $1"
|
|
}
|
|
|
|
log_error() {
|
|
echo -e "${RED}[ERROR]${NC} $1"
|
|
}
|
|
|
|
log_test() {
|
|
echo -e "${BLUE}[TEST]${NC} $1"
|
|
}
|
|
|
|
test_proxmox() {
|
|
log_test "Testing Proxmox cluster..."
|
|
|
|
if [ -f "$PROJECT_ROOT/scripts/utils/test-proxmox-connection.sh" ]; then
|
|
if "$PROJECT_ROOT/scripts/utils/test-proxmox-connection.sh" > /dev/null 2>&1; then
|
|
log_info "✓ Proxmox cluster accessible"
|
|
return 0
|
|
else
|
|
log_error "✗ Proxmox cluster not accessible"
|
|
return 1
|
|
fi
|
|
else
|
|
log_warn "⚠ Proxmox test script not found"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
test_azure_arc() {
|
|
log_test "Testing Azure Arc connectivity..."
|
|
|
|
# Check if Azure CLI is available
|
|
if ! command -v az &> /dev/null; then
|
|
log_warn "⚠ Azure CLI not found, skipping Azure Arc test"
|
|
return 0
|
|
fi
|
|
|
|
# Check if logged in
|
|
if az account show &> /dev/null; then
|
|
log_info "✓ Azure CLI authenticated"
|
|
|
|
# Try to list Arc resources
|
|
if az connectedmachine list --resource-group HC-Stack &> /dev/null 2>&1; then
|
|
log_info "✓ Azure Arc resources accessible"
|
|
return 0
|
|
else
|
|
log_warn "⚠ Azure Arc resources not found (may not be deployed)"
|
|
return 0
|
|
fi
|
|
else
|
|
log_warn "⚠ Azure CLI not authenticated"
|
|
return 0
|
|
fi
|
|
}
|
|
|
|
test_kubernetes() {
|
|
log_test "Testing Kubernetes cluster..."
|
|
|
|
if ! command -v kubectl &> /dev/null; then
|
|
log_warn "⚠ kubectl not found, skipping Kubernetes test"
|
|
return 0
|
|
fi
|
|
|
|
# Check if kubeconfig is set
|
|
if [ -z "$KUBECONFIG" ] && [ ! -f "$HOME/.kube/config" ]; then
|
|
log_warn "⚠ KUBECONFIG not set, skipping Kubernetes test"
|
|
return 0
|
|
fi
|
|
|
|
if kubectl get nodes &> /dev/null 2>&1; then
|
|
log_info "✓ Kubernetes cluster accessible"
|
|
local node_count=$(kubectl get nodes --no-headers 2>/dev/null | wc -l)
|
|
log_info " Nodes: $node_count"
|
|
return 0
|
|
else
|
|
log_error "✗ Kubernetes cluster not accessible"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
test_cloudflare() {
|
|
log_test "Testing Cloudflare Tunnel..."
|
|
|
|
if [ -f "$PROJECT_ROOT/scripts/utils/test-cloudflare-connection.sh" ]; then
|
|
if "$PROJECT_ROOT/scripts/utils/test-cloudflare-connection.sh" > /dev/null 2>&1; then
|
|
log_info "✓ Cloudflare API accessible"
|
|
return 0
|
|
else
|
|
log_warn "⚠ Cloudflare API not accessible (may not be configured)"
|
|
return 0
|
|
fi
|
|
else
|
|
log_warn "⚠ Cloudflare test script not found"
|
|
return 0
|
|
fi
|
|
}
|
|
|
|
test_network() {
|
|
log_test "Testing network connectivity..."
|
|
|
|
# Test basic connectivity
|
|
local test_ips=("192.168.1.206" "192.168.1.49")
|
|
local all_reachable=true
|
|
|
|
for ip in "${test_ips[@]}"; do
|
|
if ping -c 1 -W 2 "$ip" &> /dev/null; then
|
|
log_info "✓ $ip is reachable"
|
|
else
|
|
log_warn "⚠ $ip is not reachable"
|
|
all_reachable=false
|
|
fi
|
|
done
|
|
|
|
if [ "$all_reachable" = true ]; then
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
test_services() {
|
|
log_test "Testing HC Stack services..."
|
|
|
|
if ! command -v kubectl &> /dev/null; then
|
|
log_warn "⚠ kubectl not found, skipping service tests"
|
|
return 0
|
|
fi
|
|
|
|
local services=("besu" "firefly" "chainlink-ccip" "blockscout" "cacti" "nginx-proxy")
|
|
local found=0
|
|
|
|
for service in "${services[@]}"; do
|
|
if kubectl get deployment "$service" --all-namespaces &> /dev/null 2>&1; then
|
|
log_info "✓ $service is deployed"
|
|
found=$((found + 1))
|
|
fi
|
|
done
|
|
|
|
if [ $found -eq 0 ]; then
|
|
log_warn "⚠ No HC Stack services found (may not be deployed)"
|
|
else
|
|
log_info " Found $found service(s)"
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
main() {
|
|
echo "========================================="
|
|
echo "Full Stack End-to-End Test"
|
|
echo "========================================="
|
|
echo ""
|
|
|
|
local tests_passed=0
|
|
local tests_failed=0
|
|
local tests_skipped=0
|
|
|
|
# Run tests
|
|
test_proxmox && tests_passed=$((tests_passed + 1)) || tests_failed=$((tests_failed + 1))
|
|
test_azure_arc && tests_passed=$((tests_passed + 1)) || tests_skipped=$((tests_skipped + 1))
|
|
test_kubernetes && tests_passed=$((tests_passed + 1)) || tests_failed=$((tests_failed + 1))
|
|
test_cloudflare && tests_passed=$((tests_passed + 1)) || tests_skipped=$((tests_skipped + 1))
|
|
test_network && tests_passed=$((tests_passed + 1)) || tests_failed=$((tests_failed + 1))
|
|
test_services && tests_passed=$((tests_passed + 1)) || tests_skipped=$((tests_skipped + 1))
|
|
|
|
echo ""
|
|
echo "========================================="
|
|
echo "Test Summary"
|
|
echo "========================================="
|
|
log_info "Passed: $tests_passed"
|
|
log_warn "Skipped: $tests_skipped"
|
|
log_error "Failed: $tests_failed"
|
|
echo ""
|
|
|
|
if [ $tests_failed -eq 0 ]; then
|
|
log_info "✓ All critical tests passed"
|
|
exit 0
|
|
else
|
|
log_error "✗ Some tests failed"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
main "$@"
|
|
|