diff --git a/docker-compose.test.yml b/docker-compose.test.yml new file mode 100644 index 0000000..64f7e82 --- /dev/null +++ b/docker-compose.test.yml @@ -0,0 +1,39 @@ +version: '3.8' + +services: + app: + build: + context: . + dockerfile: Dockerfile + ports: + - "8080:8080" + environment: + - DB_HOST=localhost + - DB_PORT=5432 + - DB_NAME=calejo + - DB_USER=calejo + - DB_PASSWORD=password + - OPCUA_ENABLED=true + - OPCUA_PORT=4840 + - MODBUS_ENABLED=true + - MODBUS_PORT=502 + - REST_API_ENABLED=true + - REST_API_PORT=8080 + - HEALTH_MONITOR_PORT=9090 + - LOG_LEVEL=INFO + volumes: + - ./static:/app/static + - ./logs:/app/logs + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8080/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + restart: unless-stopped + networks: + - calejo-network + +networks: + calejo-network: + driver: bridge \ No newline at end of file diff --git a/test-deployment.sh b/test-deployment.sh new file mode 100755 index 0000000..1eae0fe --- /dev/null +++ b/test-deployment.sh @@ -0,0 +1,140 @@ +#!/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." \ No newline at end of file