#!/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:8080/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:8080/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:8080/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:8080/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:8080/dashboard" echo " REST API: http://localhost:8080" echo " Health Check: http://localhost:8080/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:8080/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:8080/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:8080/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."