#!/bin/bash # Deployment Smoke Test Runner # Run this script after deployment to verify the deployment was successful set -e # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Function to print colored output print_status() { echo -e "${BLUE}[INFO]${NC} $1" } print_success() { echo -e "${GREEN}[SUCCESS]${NC} $1" } print_warning() { echo -e "${YELLOW}[WARNING]${NC} $1" } print_error() { echo -e "${RED}[ERROR]${NC} $1" } # Default configuration BASE_URL="http://localhost:8080" SCADA_URL="http://localhost:8081" OPTIMIZER_URL="http://localhost:8082" # Parse command line arguments while [[ $# -gt 0 ]]; do case $1 in --base-url) BASE_URL="$2" shift 2 ;; --scada-url) SCADA_URL="$2" shift 2 ;; --optimizer-url) OPTIMIZER_URL="$2" shift 2 ;; -h|--help) echo "Usage: $0 [OPTIONS]" echo "" echo "Options:" echo " --base-url URL Base URL for main application (default: http://localhost:8080)" echo " --scada-url URL SCADA service URL (default: http://localhost:8081)" echo " --optimizer-url URL Optimizer service URL (default: http://localhost:8082)" echo " -h, --help Show this help message" echo "" echo "Examples:" echo " $0 # Test local deployment" echo " $0 --base-url http://example.com # Test remote deployment" exit 0 ;; *) print_error "Unknown option: $1" exit 1 ;; esac done print_status "Starting deployment smoke tests..." print_status "Testing environment:" print_status " Main Application: $BASE_URL" print_status " SCADA Service: $SCADA_URL" print_status " Optimizer Service: $OPTIMIZER_URL" # Set environment variables for the Python script export DEPLOYMENT_BASE_URL="$BASE_URL" export DEPLOYMENT_SCADA_URL="$SCADA_URL" export DEPLOYMENT_OPTIMIZER_URL="$OPTIMIZER_URL" # Run the smoke tests python tests/deployment/smoke_tests.py # Check the exit code if [ $? -eq 0 ]; then print_success "All smoke tests passed! Deployment appears successful." exit 0 else print_error "Some smoke tests failed. Please investigate deployment issues." exit 1 fi