diff --git a/.env.test b/.env.test new file mode 100644 index 0000000..d52ef45 --- /dev/null +++ b/.env.test @@ -0,0 +1,38 @@ +# Test Environment Configuration +# Enable protocol servers for testing + +# Database configuration +DB_HOST=calejo-postgres-test +DB_PORT=5432 +DB_NAME=calejo_test +DB_USER=calejo +DB_PASSWORD=password + +# Enable internal protocol servers for testing +OPCUA_ENABLED=true +MODBUS_ENABLED=true + +# REST API configuration +REST_API_ENABLED=true +REST_API_HOST=0.0.0.0 +REST_API_PORT=8081 + +# Health monitoring +HEALTH_MONITOR_PORT=9091 + +# Logging +LOG_LEVEL=DEBUG +LOG_FORMAT=json +ENVIRONMENT=test + +# Security +API_KEY=test_api_key +JWT_SECRET_KEY=test_jwt_secret_key + +# Auto-discovery +AUTO_DISCOVERY_ENABLED=true +AUTO_DISCOVERY_REFRESH_MINUTES=30 + +# Optimization +OPTIMIZATION_MONITORING_ENABLED=false +OPTIMIZATION_REFRESH_SECONDS=60 \ No newline at end of file diff --git a/deploy/ssh/deploy-remote.sh b/deploy/ssh/deploy-remote.sh index 580a85f..1f4acf2 100755 --- a/deploy/ssh/deploy-remote.sh +++ b/deploy/ssh/deploy-remote.sh @@ -331,17 +331,26 @@ build_and_start_services() { # Build services execute_remote "cd $TARGET_DIR && sudo docker-compose build" "Building Docker images" - # Start services - use production compose file if available + # Start services - use environment-specific compose file if available if [[ "$ENVIRONMENT" == "production" ]] && execute_remote "cd $TARGET_DIR && test -f docker-compose.production.yml" "Checking for production compose file" 2>/dev/null; then execute_remote "cd $TARGET_DIR && sudo docker-compose -f docker-compose.production.yml up -d" "Starting services with production configuration" + elif [[ "$ENVIRONMENT" == "test" ]] && execute_remote "cd $TARGET_DIR && test -f docker-compose.test.yml" "Checking for test compose file" 2>/dev/null; then + execute_remote "cd $TARGET_DIR && sudo docker-compose -f docker-compose.test.yml up -d" "Starting services with test configuration" else execute_remote "cd $TARGET_DIR && sudo docker-compose up -d" "Starting services" fi # Wait for services to be ready print_status "Waiting for services to start..." + + # Determine health check port based on environment + local health_port="8080" + if [[ "$ENVIRONMENT" == "test" ]]; then + health_port="8081" + fi + for i in {1..30}; do - if execute_remote "curl -s http://localhost:8080/health > /dev/null" "Checking service health" 2>/dev/null; then + if execute_remote "curl -s http://localhost:$health_port/health > /dev/null" "Checking service health" 2>/dev/null; then print_success "Services started successfully" break fi @@ -370,8 +379,14 @@ validate_deployment() { # Test key endpoints local endpoints=("/health" "/dashboard" "/api/v1/status") + # Determine validation port based on environment + local validation_port="8080" + if [[ "$ENVIRONMENT" == "test" ]]; then + validation_port="8081" + fi + for endpoint in "${endpoints[@]}"; do - if execute_remote "curl -s -f http://localhost:8080$endpoint > /dev/null" "Testing endpoint: $endpoint" 2>/dev/null; then + if execute_remote "curl -s -f http://localhost:$validation_port$endpoint > /dev/null" "Testing endpoint: $endpoint" 2>/dev/null; then print_success "Endpoint $endpoint is accessible" else print_error "Endpoint $endpoint is not accessible" @@ -392,9 +407,14 @@ display_deployment_summary() { echo "📁 Application: $TARGET_DIR" echo "" echo "🔗 Access URLs:" - echo " Dashboard: http://$SSH_HOST:8080/dashboard" - echo " REST API: http://$SSH_HOST:8080" - echo " Health Check: http://$SSH_HOST:8080/health" + # Determine port based on environment + local summary_port="8080" + if [[ "$ENVIRONMENT" == "test" ]]; then + summary_port="8081" + fi + echo " Dashboard: http://$SSH_HOST:$summary_port/dashboard" + echo " REST API: http://$SSH_HOST:$summary_port" + echo " Health Check: http://$SSH_HOST:$summary_port/health" echo "" echo "🔧 Management Commands:" echo " View logs: ssh -i $SSH_KEY_FILE $SSH_USERNAME@$SSH_HOST 'cd $TARGET_DIR && docker-compose logs -f'"