Files
loc_az_hci/scripts/validate/validate-deployment.sh
defiQUG c39465c2bd
Some checks failed
Test / test (push) Has been cancelled
Initial commit: loc_az_hci (smom-dbis-138 excluded via .gitignore)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-08 09:04:46 -08:00

157 lines
3.7 KiB
Bash
Executable File

#!/bin/bash
source ~/.bashrc
# Validate Deployment
# Post-deployment validation and configuration drift detection
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_check() {
echo -e "${BLUE}[CHECK]${NC} $1"
}
validate_prerequisites() {
log_check "Validating prerequisites..."
if [ -f "$PROJECT_ROOT/scripts/utils/prerequisites-check.sh" ]; then
"$PROJECT_ROOT/scripts/utils/prerequisites-check.sh"
else
log_warn "Prerequisites check script not found"
fi
}
validate_connections() {
log_check "Validating connections..."
local all_valid=true
# Check Proxmox
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 connections valid"
else
log_error "✗ Proxmox connections invalid"
all_valid=false
fi
fi
# Check Cloudflare
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 connection valid"
else
log_warn "⚠ Cloudflare connection invalid (may not be configured)"
fi
fi
if [ "$all_valid" = false ]; then
return 1
fi
return 0
}
validate_health() {
log_check "Validating component health..."
if [ -f "$PROJECT_ROOT/scripts/health/health-check-all.sh" ]; then
if "$PROJECT_ROOT/scripts/health/health-check-all.sh" > /dev/null 2>&1; then
log_info "✓ All components healthy"
return 0
else
log_error "✗ Some components unhealthy"
return 1
fi
else
log_warn "Health check script not found"
return 0
fi
}
validate_services() {
log_check "Validating services..."
if ! command -v kubectl &> /dev/null; then
log_warn "kubectl not found, skipping service validation"
return 0
fi
if kubectl get nodes &> /dev/null 2>&1; then
log_info "✓ Kubernetes cluster accessible"
# Check for expected namespaces
local namespaces=("blockchain" "monitoring" "hc-stack")
for ns in "${namespaces[@]}"; do
if kubectl get namespace "$ns" &> /dev/null 2>&1; then
log_info "✓ Namespace $ns exists"
else
log_warn "⚠ Namespace $ns not found"
fi
done
else
log_warn "⚠ Kubernetes cluster not accessible"
fi
return 0
}
main() {
echo "========================================="
echo "Deployment Validation"
echo "========================================="
echo ""
local validation_passed=true
validate_prerequisites
echo ""
if ! validate_connections; then
validation_passed=false
fi
echo ""
if ! validate_health; then
validation_passed=false
fi
echo ""
validate_services
echo ""
echo "========================================="
echo "Validation Summary"
echo "========================================="
if [ "$validation_passed" = true ]; then
log_info "✓ Deployment validation passed"
exit 0
else
log_error "✗ Deployment validation failed"
exit 1
fi
}
main "$@"