#!/bin/bash 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 echo -e "${BLUE}πŸ§ͺ SeaweedFS EC Worker Testing Environment${NC}" echo -e "${BLUE}===========================================${NC}" # Check if docker-compose is available if ! command -v docker-compose &> /dev/null; then echo -e "${RED}❌ docker-compose is required but not installed${NC}" exit 1 fi # Create necessary directories echo -e "${YELLOW}πŸ“ Creating required directories...${NC}" mkdir -p monitor-data admin-config # Make scripts executable echo -e "${YELLOW}πŸ”§ Making scripts executable...${NC}" chmod +x *.sh # Stop any existing containers echo -e "${YELLOW}πŸ›‘ Stopping any existing containers...${NC}" docker-compose -f docker-compose-ec-test.yml down -v 2>/dev/null || true # Build and start the environment echo -e "${GREEN}πŸš€ Starting SeaweedFS EC testing environment...${NC}" echo -e "${BLUE}This will start:${NC}" echo -e " β€’ 1 Master server (port 9333)" echo -e " β€’ 6 Volume servers (ports 8080-8085) with 50MB volume limit" echo -e " β€’ 1 Filer (port 8888)" echo -e " β€’ 1 Admin server (port 9900)" echo -e " β€’ 3 EC Workers" echo -e " β€’ 1 Load generator (continuous read/write)" echo -e " β€’ 1 Monitor (port 9999)" echo "" docker-compose -f docker-compose-ec-test.yml up --build -d echo -e "${GREEN}βœ… Environment started successfully!${NC}" echo "" echo -e "${BLUE}πŸ“Š Monitoring URLs:${NC}" echo -e " β€’ Master UI: http://localhost:9333" echo -e " β€’ Filer: http://localhost:8888" echo -e " β€’ Admin Server: http://localhost:9900/status" echo -e " β€’ Monitor: http://localhost:9999/status" echo "" echo -e "${BLUE}πŸ“ˆ Volume Servers:${NC}" echo -e " β€’ Volume1: http://localhost:8080/status" echo -e " β€’ Volume2: http://localhost:8081/status" echo -e " β€’ Volume3: http://localhost:8082/status" echo -e " β€’ Volume4: http://localhost:8083/status" echo -e " β€’ Volume5: http://localhost:8084/status" echo -e " β€’ Volume6: http://localhost:8085/status" echo "" echo -e "${YELLOW}⏳ Waiting for services to be ready...${NC}" sleep 10 # Check service health echo -e "${BLUE}πŸ” Checking service health...${NC}" check_service() { local name=$1 local url=$2 if curl -s "$url" > /dev/null 2>&1; then echo -e " βœ… $name: ${GREEN}Healthy${NC}" return 0 else echo -e " ❌ $name: ${RED}Not responding${NC}" return 1 fi } check_service "Master" "http://localhost:9333/cluster/status" check_service "Filer" "http://localhost:8888/" check_service "Admin" "http://localhost:9900/health" check_service "Monitor" "http://localhost:9999/health" echo "" echo -e "${GREEN}🎯 Test Environment is Ready!${NC}" echo "" echo -e "${BLUE}What's happening:${NC}" echo -e " 1. πŸ“ Load generator continuously writes 1-5MB files at 10 files/sec" echo -e " 2. πŸ—‘οΈ Load generator deletes files at 2 files/sec" echo -e " 3. πŸ“Š Volumes fill up to 50MB limit and trigger EC conversion" echo -e " 4. 🏭 Admin server detects volumes needing EC and assigns to workers" echo -e " 5. ⚑ Workers perform comprehensive EC (copyβ†’encodeβ†’distribute)" echo -e " 6. πŸ“ˆ Monitor tracks all activity and volume states" echo "" echo -e "${YELLOW}πŸ“‹ Useful Commands:${NC}" echo -e " β€’ View logs: docker-compose -f docker-compose-ec-test.yml logs -f [service]" echo -e " β€’ Check worker status: docker-compose -f docker-compose-ec-test.yml logs worker1" echo -e " β€’ Stop environment: docker-compose -f docker-compose-ec-test.yml down -v" echo -e " β€’ Monitor logs: docker-compose -f docker-compose-ec-test.yml logs -f monitor" echo "" echo -e "${GREEN}πŸ”₯ The test will run for 1 hour by default${NC}" echo -e "${BLUE}Monitor progress at: http://localhost:9999/status${NC}"