CalejoControl/deploy/test-deployment.sh

140 lines
3.9 KiB
Bash
Raw Normal View History

#!/bin/bash
# Calejo Control Adapter - Test Deployment Script
# This script tests the deployment of the dashboard and full application stack
echo "🚀 Starting Calejo Control Adapter Test Deployment"
echo "=================================================="
# Check if Docker is running
if ! docker info > /dev/null 2>&1; then
echo "❌ Docker is not running. Please start Docker and try again."
exit 1
fi
# Check if Docker Compose is available
if ! command -v docker-compose &> /dev/null; then
echo "❌ Docker Compose is not installed. Please install it first."
exit 1
fi
echo "✅ Docker and Docker Compose are available"
# Build the application
echo ""
echo "🔨 Building the application..."
docker-compose -f docker-compose.test.yml build app
if [ $? -ne 0 ]; then
echo "❌ Build failed"
exit 1
fi
echo "✅ Application built successfully"
# Start the services
echo ""
echo "🚀 Starting services..."
docker-compose -f docker-compose.test.yml up -d app
if [ $? -ne 0 ]; then
echo "❌ Failed to start services"
exit 1
fi
echo "✅ Services started successfully"
# Wait for the application to be ready
echo ""
echo "⏳ Waiting for application to be ready..."
for i in {1..30}; do
if curl -s http://localhost:8081/health > /dev/null 2>&1; then
echo "✅ Application is ready!"
break
fi
echo " Waiting... (attempt $i/30)"
sleep 2
if [ $i -eq 30 ]; then
echo "❌ Application failed to start within 60 seconds"
docker-compose -f docker-compose.test.yml logs app
exit 1
fi
done
# Test the dashboard
echo ""
echo "🧪 Testing dashboard access..."
DASHBOARD_RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8081/dashboard)
if [ "$DASHBOARD_RESPONSE" = "200" ]; then
echo "✅ Dashboard is accessible (HTTP 200)"
else
echo "❌ Dashboard returned HTTP $DASHBOARD_RESPONSE"
fi
# Test the dashboard API
echo ""
echo "🧪 Testing dashboard API..."
API_RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8081/api/v1/dashboard/status)
if [ "$API_RESPONSE" = "200" ]; then
echo "✅ Dashboard API is accessible (HTTP 200)"
else
echo "❌ Dashboard API returned HTTP $API_RESPONSE"
fi
# Test configuration endpoint
echo ""
echo "🧪 Testing configuration endpoint..."
CONFIG_RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8081/api/v1/dashboard/config)
if [ "$CONFIG_RESPONSE" = "200" ]; then
echo "✅ Configuration endpoint is accessible (HTTP 200)"
else
echo "❌ Configuration endpoint returned HTTP $CONFIG_RESPONSE"
fi
# Display access information
echo ""
echo "🎉 Deployment Test Complete!"
echo "============================"
echo ""
echo "📊 Access URLs:"
echo " Dashboard: http://localhost:8081/dashboard"
echo " REST API: http://localhost:8081"
echo " Health Check: http://localhost:8081/health"
echo ""
echo "🔍 View logs:"
echo " docker-compose -f docker-compose.test.yml logs app"
echo ""
echo "🛑 Stop services:"
echo " docker-compose -f docker-compose.test.yml down"
echo ""
echo "📋 Full stack deployment:"
echo " docker-compose up -d"
echo ""
# Run a quick health check
echo "🏥 Running health check..."
HEALTH=$(curl -s http://localhost:8081/health | jq -r '.status' 2>/dev/null || echo "unknown")
echo " Application status: $HEALTH"
# Test dashboard functionality
echo ""
echo "🧪 Testing dashboard functionality..."
if curl -s http://localhost:8081/dashboard | grep -q "Calejo Control Adapter Dashboard"; then
echo "✅ Dashboard HTML is loading correctly"
else
echo "❌ Dashboard HTML may not be loading correctly"
fi
if curl -s http://localhost:8081/static/dashboard.js | grep -q "showTab"; then
echo "✅ Dashboard JavaScript is loading correctly"
else
echo "❌ Dashboard JavaScript may not be loading correctly"
fi
echo ""
echo "✅ Test deployment completed successfully!"
echo " The dashboard and application are running correctly."