# SeaweedFS EC Worker Testing Environment Makefile # Usage: make .PHONY: help start stop clean logs status monitor health up down restart scale docs test # Default target .DEFAULT_GOAL := help # Docker compose file COMPOSE_FILE := docker-compose-ec-test.yml # Color codes for output GREEN := \033[32m YELLOW := \033[33m BLUE := \033[34m RED := \033[31m NC := \033[0m # No Color help: ## Show this help message @echo "$(BLUE)๐Ÿงช SeaweedFS EC Worker Testing Environment$(NC)" @echo "$(BLUE)===========================================$(NC)" @echo "" @echo "$(YELLOW)Available targets:$(NC)" @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " $(GREEN)%-15s$(NC) %s\n", $$1, $$2}' $(MAKEFILE_LIST) @echo "" @echo "$(YELLOW)Quick start:$(NC) make start" @echo "$(YELLOW)Monitor:$(NC) make monitor" @echo "$(YELLOW)Cleanup:$(NC) make clean" start: ## Start the complete EC testing environment @echo "$(GREEN)๐Ÿš€ Starting SeaweedFS EC testing environment...$(NC)" @echo "$(BLUE)This will start:$(NC)" @echo " โ€ข 1 Master server (port 9333)" @echo " โ€ข 6 Volume servers (ports 8080-8085) with 50MB volume limit" @echo " โ€ข 1 Filer (port 8888)" @echo " โ€ข 1 Admin server (port 9900)" @echo " โ€ข 3 EC Workers" @echo " โ€ข 1 Load generator (continuous read/write)" @echo " โ€ข 1 Monitor (port 9999)" @echo "" @mkdir -p monitor-data admin-config @chmod +x *.sh 2>/dev/null || true @docker-compose -f $(COMPOSE_FILE) down -v 2>/dev/null || true @docker-compose -f $(COMPOSE_FILE) up --build -d @echo "" @echo "$(GREEN)โœ… Environment started successfully!$(NC)" @echo "" @$(MAKE) urls @echo "" @echo "$(YELLOW)โณ Waiting for services to be ready...$(NC)" @sleep 10 @$(MAKE) health stop: ## Stop all services @echo "$(YELLOW)๐Ÿ›‘ Stopping all services...$(NC)" @docker-compose -f $(COMPOSE_FILE) stop @echo "$(GREEN)โœ… All services stopped$(NC)" down: ## Stop and remove all containers @echo "$(YELLOW)๐Ÿ›‘ Stopping and removing containers...$(NC)" @docker-compose -f $(COMPOSE_FILE) down @echo "$(GREEN)โœ… Containers stopped and removed$(NC)" clean: ## Stop and remove all containers, networks, volumes, and images @echo "$(RED)๐Ÿงน Cleaning up entire environment...$(NC)" @docker-compose -f $(COMPOSE_FILE) down -v --rmi all 2>/dev/null || true @docker system prune -f @echo "$(GREEN)โœ… Environment cleaned up$(NC)" restart: ## Restart all services @echo "$(YELLOW)๐Ÿ”„ Restarting all services...$(NC)" @docker-compose -f $(COMPOSE_FILE) restart @echo "$(GREEN)โœ… All services restarted$(NC)" up: start ## Alias for start status: ## Show status of all services @echo "$(BLUE)๐Ÿ“Š Service Status:$(NC)" @docker-compose -f $(COMPOSE_FILE) ps logs: ## Show logs from all services @echo "$(BLUE)๐Ÿ“‹ Showing logs from all services (Ctrl+C to exit):$(NC)" @docker-compose -f $(COMPOSE_FILE) logs -f logs-admin: ## Show admin server logs @echo "$(BLUE)๐Ÿ“‹ Admin Server Logs:$(NC)" @docker-compose -f $(COMPOSE_FILE) logs -f admin logs-workers: ## Show all worker logs @echo "$(BLUE)๐Ÿ“‹ Worker Logs:$(NC)" @docker-compose -f $(COMPOSE_FILE) logs -f worker1 worker2 worker3 logs-worker1: ## Show worker1 logs @docker-compose -f $(COMPOSE_FILE) logs -f worker1 logs-worker2: ## Show worker2 logs @docker-compose -f $(COMPOSE_FILE) logs -f worker2 logs-worker3: ## Show worker3 logs @docker-compose -f $(COMPOSE_FILE) logs -f worker3 logs-load: ## Show load generator logs @echo "$(BLUE)๐Ÿ“‹ Load Generator Logs:$(NC)" @docker-compose -f $(COMPOSE_FILE) logs -f load_generator logs-monitor: ## Show monitor logs @echo "$(BLUE)๐Ÿ“‹ Monitor Logs:$(NC)" @docker-compose -f $(COMPOSE_FILE) logs -f monitor logs-master: ## Show master logs @docker-compose -f $(COMPOSE_FILE) logs -f master logs-volumes: ## Show all volume server logs @echo "$(BLUE)๐Ÿ“‹ Volume Server Logs:$(NC)" @docker-compose -f $(COMPOSE_FILE) logs -f volume1 volume2 volume3 volume4 volume5 volume6 urls: ## Show monitoring URLs @echo "$(BLUE)๐Ÿ“Š Monitoring URLs:$(NC)" @echo " โ€ข Master UI: http://localhost:9333" @echo " โ€ข Filer: http://localhost:8888" @echo " โ€ข Admin Server: http://localhost:9900/status" @echo " โ€ข Monitor: http://localhost:9999/status" @echo "" @echo "$(BLUE)๐Ÿ“ˆ Volume Servers:$(NC)" @echo " โ€ข Volume1: http://localhost:8080/status" @echo " โ€ข Volume2: http://localhost:8081/status" @echo " โ€ข Volume3: http://localhost:8082/status" @echo " โ€ข Volume4: http://localhost:8083/status" @echo " โ€ข Volume5: http://localhost:8084/status" @echo " โ€ข Volume6: http://localhost:8085/status" health: ## Check health of all services @echo "$(BLUE)๐Ÿ” Checking service health...$(NC)" @echo -n " Master: "; \ if curl -s http://localhost:9333/cluster/status > /dev/null 2>&1; then \ echo "$(GREEN)โœ… Healthy$(NC)"; \ else \ echo "$(RED)โŒ Not responding$(NC)"; \ fi @echo -n " Filer: "; \ if curl -s http://localhost:8888/ > /dev/null 2>&1; then \ echo "$(GREEN)โœ… Healthy$(NC)"; \ else \ echo "$(RED)โŒ Not responding$(NC)"; \ fi @echo -n " Admin: "; \ if curl -s http://localhost:9900/health > /dev/null 2>&1; then \ echo "$(GREEN)โœ… Healthy$(NC)"; \ else \ echo "$(RED)โŒ Not responding$(NC)"; \ fi @echo -n " Monitor: "; \ if curl -s http://localhost:9999/health > /dev/null 2>&1; then \ echo "$(GREEN)โœ… Healthy$(NC)"; \ else \ echo "$(RED)โŒ Not responding$(NC)"; \ fi monitor: ## Open monitor dashboard in browser @echo "$(BLUE)๐Ÿ“Š Opening monitor dashboard...$(NC)" @echo "Monitor URL: http://localhost:9999/status" @command -v open >/dev/null 2>&1 && open http://localhost:9999/status || \ command -v xdg-open >/dev/null 2>&1 && xdg-open http://localhost:9999/status || \ echo "Please open http://localhost:9999/status in your browser" monitor-status: ## Show current monitoring status via API @echo "$(BLUE)๐Ÿ“Š Current Monitor Status:$(NC)" @curl -s http://localhost:9999/status | jq . 2>/dev/null || \ curl -s http://localhost:9999/status 2>/dev/null || \ echo "Monitor not available" volume-status: ## Show volume status from master @echo "$(BLUE)๐Ÿ’พ Volume Status:$(NC)" @curl -s http://localhost:9333/vol/status | jq . 2>/dev/null || \ curl -s http://localhost:9333/vol/status 2>/dev/null || \ echo "Master not available" admin-status: ## Show admin server status @echo "$(BLUE)๐Ÿญ Admin Server Status:$(NC)" @curl -s http://localhost:9900/status | jq . 2>/dev/null || \ curl -s http://localhost:9900/status 2>/dev/null || \ echo "Admin server not available" cluster-status: ## Show complete cluster status @echo "$(BLUE)๐ŸŒ Cluster Status:$(NC)" @curl -s http://localhost:9333/cluster/status | jq . 2>/dev/null || \ curl -s http://localhost:9333/cluster/status 2>/dev/null || \ echo "Master not available" scale-workers: ## Scale workers (usage: make scale-workers WORKERS=5) @echo "$(YELLOW)โš–๏ธ Scaling workers to $(or $(WORKERS),3)...$(NC)" @docker-compose -f $(COMPOSE_FILE) up -d --scale worker2=$(or $(WORKERS),3) scale-load: ## Restart load generator with higher rate (usage: make scale-load RATE=20) @echo "$(YELLOW)๐Ÿ“ˆ Scaling load generation to $(or $(RATE),20) files/sec...$(NC)" @docker-compose -f $(COMPOSE_FILE) stop load_generator @docker-compose -f $(COMPOSE_FILE) run -d --name temp_load_generator \ -e WRITE_RATE=$(or $(RATE),20) -e DELETE_RATE=$(or $(shell expr $(or $(RATE),20) / 4),5) \ load_generator @echo "$(GREEN)โœ… Load generator restarted with higher rate$(NC)" test-ec: ## Run a focused EC test scenario @echo "$(YELLOW)๐Ÿงช Running focused EC test...$(NC)" @$(MAKE) scale-load RATE=25 @echo "$(BLUE)Monitoring EC detection...$(NC)" @echo "Watch for volumes >40MB that trigger EC conversion" @echo "Monitor at: http://localhost:9999/status" shell-admin: ## Open shell in admin container @docker-compose -f $(COMPOSE_FILE) exec admin /bin/sh shell-worker1: ## Open shell in worker1 container @docker-compose -f $(COMPOSE_FILE) exec worker1 /bin/sh shell-master: ## Open shell in master container @docker-compose -f $(COMPOSE_FILE) exec master /bin/sh docs: ## Show documentation @echo "$(BLUE)๐Ÿ“– EC Testing Documentation:$(NC)" @echo "" @cat EC-TESTING-README.md build: ## Build all Docker images without starting @echo "$(YELLOW)๐Ÿ”จ Building all Docker images...$(NC)" @docker-compose -f $(COMPOSE_FILE) build @echo "$(GREEN)โœ… All images built$(NC)" pull: ## Pull latest SeaweedFS image @echo "$(YELLOW)๐Ÿ“ฅ Pulling latest SeaweedFS image...$(NC)" @docker pull chrislusf/seaweedfs:latest @echo "$(GREEN)โœ… Latest image pulled$(NC)" debug: ## Show debug information @echo "$(BLUE)๐Ÿ” Debug Information:$(NC)" @echo "" @echo "$(YELLOW)Docker Compose Version:$(NC)" @docker-compose --version @echo "" @echo "$(YELLOW)Docker Version:$(NC)" @docker --version @echo "" @echo "$(YELLOW)Current Directory:$(NC)" @pwd @echo "" @echo "$(YELLOW)Available Files:$(NC)" @ls -la *.yml *.sh *.md 2>/dev/null || echo "No config files found" @echo "" @echo "$(YELLOW)Running Containers:$(NC)" @docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" # Targets for development and testing dev-start: ## Start with development settings (faster iteration) @echo "$(YELLOW)๐Ÿ› ๏ธ Starting development environment...$(NC)" @mkdir -p monitor-data admin-config @WRITE_RATE=50 DELETE_RATE=10 docker-compose -f $(COMPOSE_FILE) up --build -d @echo "$(GREEN)โœ… Development environment started with high load$(NC)" dev-stop: stop ## Stop development environment # Clean specific components clean-volumes: ## Remove only data volumes @echo "$(YELLOW)๐Ÿ—„๏ธ Removing data volumes...$(NC)" @docker-compose -f $(COMPOSE_FILE) down -v @echo "$(GREEN)โœ… Data volumes removed$(NC)" clean-images: ## Remove built images @echo "$(YELLOW)๐Ÿ–ผ๏ธ Removing built images...$(NC)" @docker-compose -f $(COMPOSE_FILE) down --rmi local @echo "$(GREEN)โœ… Built images removed$(NC)" # Backup and restore backup-logs: ## Backup all service logs @echo "$(YELLOW)๐Ÿ’พ Backing up service logs...$(NC)" @mkdir -p logs-backup @docker-compose -f $(COMPOSE_FILE) logs admin > logs-backup/admin.log 2>&1 @docker-compose -f $(COMPOSE_FILE) logs worker1 > logs-backup/worker1.log 2>&1 @docker-compose -f $(COMPOSE_FILE) logs worker2 > logs-backup/worker2.log 2>&1 @docker-compose -f $(COMPOSE_FILE) logs worker3 > logs-backup/worker3.log 2>&1 @docker-compose -f $(COMPOSE_FILE) logs monitor > logs-backup/monitor.log 2>&1 @docker-compose -f $(COMPOSE_FILE) logs load_generator > logs-backup/load_generator.log 2>&1 @echo "$(GREEN)โœ… Logs backed up to logs-backup/$(NC)" # Quick troubleshooting troubleshoot: ## Run troubleshooting checks @echo "$(BLUE)๐Ÿ”ง Running troubleshooting checks...$(NC)" @echo "" @echo "$(YELLOW)1. Checking required ports:$(NC)" @for port in 9333 8888 9900 9999 8080 8081 8082 8083 8084 8085; do \ echo -n " Port $$port: "; \ if lsof -i :$$port >/dev/null 2>&1; then \ echo "$(RED)โŒ In use$(NC)"; \ else \ echo "$(GREEN)โœ… Available$(NC)"; \ fi; \ done @echo "" @echo "$(YELLOW)2. Docker resources:$(NC)" @docker system df @echo "" @echo "$(YELLOW)3. Service health:$(NC)" @$(MAKE) health