#!/bin/bash # E2E test: Complete deployment workflow set -euo pipefail test_complete_deployment() { echo "Testing complete deployment workflow..." # Step 1: Clean environment docker compose down -v 2>/dev/null || true docker system prune -f 2>/dev/null || true # Step 2: Run deployment script if ./scripts/demo-stack.sh deploy; then echo "PASS: Deployment script execution" else echo "FAIL: Deployment script execution" return 1 fi # Step 3: Wait for services sleep 60 # Step 4: Validate all services are healthy local unhealthy_count unhealthy_count=$(docker compose ps | grep -c "unhealthy\|exited" || echo "0") if [[ $unhealthy_count -eq 0 ]]; then echo "PASS: All services healthy" else echo "FAIL: $unhealthy_count services unhealthy" return 1 fi # Step 5: Validate all ports accessible local failed_ports=0 local ports=(4000 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4017 4018) for port in "${ports[@]}"; do if ! curl -f -s --max-time 5 "http://localhost:$port" >/dev/null 2>&1; then ((failed_ports++)) fi done if [[ $failed_ports -eq 0 ]]; then echo "PASS: All ports accessible" else echo "FAIL: $failed_ports ports inaccessible" return 1 fi echo "PASS: Complete deployment workflow" return 0 } test_complete_deployment