feat: Add test environment deployment support
- Created test.yml configuration file for test environment - Created .env.test environment file with protocol servers enabled - Updated deployment script to handle test environment - Test environment uses port 8081 and enables protocol servers for testing
This commit is contained in:
parent
ce08cf846d
commit
84fc7f66cb
|
|
@ -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
|
||||||
|
|
@ -331,17 +331,26 @@ build_and_start_services() {
|
||||||
# Build services
|
# Build services
|
||||||
execute_remote "cd $TARGET_DIR && sudo docker-compose build" "Building Docker images"
|
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
|
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"
|
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
|
else
|
||||||
execute_remote "cd $TARGET_DIR && sudo docker-compose up -d" "Starting services"
|
execute_remote "cd $TARGET_DIR && sudo docker-compose up -d" "Starting services"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Wait for services to be ready
|
# Wait for services to be ready
|
||||||
print_status "Waiting for services to start..."
|
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
|
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"
|
print_success "Services started successfully"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
@ -370,8 +379,14 @@ validate_deployment() {
|
||||||
# Test key endpoints
|
# Test key endpoints
|
||||||
local endpoints=("/health" "/dashboard" "/api/v1/status")
|
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
|
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"
|
print_success "Endpoint $endpoint is accessible"
|
||||||
else
|
else
|
||||||
print_error "Endpoint $endpoint is not accessible"
|
print_error "Endpoint $endpoint is not accessible"
|
||||||
|
|
@ -392,9 +407,14 @@ display_deployment_summary() {
|
||||||
echo "📁 Application: $TARGET_DIR"
|
echo "📁 Application: $TARGET_DIR"
|
||||||
echo ""
|
echo ""
|
||||||
echo "🔗 Access URLs:"
|
echo "🔗 Access URLs:"
|
||||||
echo " Dashboard: http://$SSH_HOST:8080/dashboard"
|
# Determine port based on environment
|
||||||
echo " REST API: http://$SSH_HOST:8080"
|
local summary_port="8080"
|
||||||
echo " Health Check: http://$SSH_HOST:8080/health"
|
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 ""
|
||||||
echo "🔧 Management Commands:"
|
echo "🔧 Management Commands:"
|
||||||
echo " View logs: ssh -i $SSH_KEY_FILE $SSH_USERNAME@$SSH_HOST 'cd $TARGET_DIR && docker-compose logs -f'"
|
echo " View logs: ssh -i $SSH_KEY_FILE $SSH_USERNAME@$SSH_HOST 'cd $TARGET_DIR && docker-compose logs -f'"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue