Makefile 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. # SeaweedFS Admin Integration Test Makefile
  2. # Tests the admin server and worker functionality using official weed commands
  3. .PHONY: help build build-and-restart restart-workers start stop restart logs clean status test admin-ui worker-logs master-logs admin-logs vacuum-test vacuum-demo vacuum-status vacuum-data vacuum-data-high vacuum-data-low vacuum-continuous vacuum-clean vacuum-help
  4. .DEFAULT_GOAL := help
  5. COMPOSE_FILE := docker-compose-ec-test.yml
  6. PROJECT_NAME := admin_integration
  7. build: ## Build SeaweedFS with latest changes and create Docker image
  8. @echo "🔨 Building SeaweedFS with latest changes..."
  9. @echo "1️⃣ Generating admin templates..."
  10. @cd ../../ && make admin-generate
  11. @echo "2️⃣ Building Docker image with latest changes..."
  12. @cd ../ && make build
  13. @echo "3️⃣ Copying binary for local docker-compose..."
  14. @cp ../weed ./weed-local
  15. @echo "✅ Build complete! Updated image: chrislusf/seaweedfs:local"
  16. @echo "💡 Run 'make restart' to apply changes to running services"
  17. build-and-restart: build ## Build with latest changes and restart services
  18. @echo "🔄 Recreating services with new image..."
  19. @echo "1️⃣ Recreating admin server with new image..."
  20. @docker-compose -f $(COMPOSE_FILE) up -d admin
  21. @sleep 5
  22. @echo "2️⃣ Recreating workers to reconnect..."
  23. @docker-compose -f $(COMPOSE_FILE) up -d worker1 worker2 worker3
  24. @echo "✅ All services recreated with latest changes!"
  25. @echo "🌐 Admin UI: http://localhost:23646/"
  26. @echo "💡 Workers will reconnect to the new admin server"
  27. restart-workers: ## Restart all workers to reconnect to admin server
  28. @echo "🔄 Restarting workers to reconnect to admin server..."
  29. @docker-compose -f $(COMPOSE_FILE) restart worker1 worker2 worker3
  30. @echo "✅ Workers restarted and will reconnect to admin server"
  31. help: ## Show this help message
  32. @echo "SeaweedFS Admin Integration Test"
  33. @echo "================================"
  34. @echo "Tests admin server task distribution to workers using official weed commands"
  35. @echo ""
  36. @echo "🏗️ Cluster Management:"
  37. @grep -E '^(start|stop|restart|clean|status|build):.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-18s %s\n", $$1, $$2}'
  38. @echo ""
  39. @echo "🧪 Testing:"
  40. @grep -E '^(test|demo|validate|quick-test):.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-18s %s\n", $$1, $$2}'
  41. @echo ""
  42. @echo "🗑️ Vacuum Testing:"
  43. @grep -E '^vacuum-.*:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-18s %s\n", $$1, $$2}'
  44. @echo ""
  45. @echo "📜 Monitoring:"
  46. @grep -E '^(logs|admin-logs|worker-logs|master-logs|admin-ui):.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-18s %s\n", $$1, $$2}'
  47. @echo ""
  48. @echo "🚀 Quick Start:"
  49. @echo " make start # Start cluster"
  50. @echo " make vacuum-test # Test vacuum tasks"
  51. @echo " make vacuum-help # Vacuum testing guide"
  52. @echo ""
  53. @echo "💡 For detailed vacuum testing: make vacuum-help"
  54. start: ## Start the complete SeaweedFS cluster with admin and workers
  55. @echo "🚀 Starting SeaweedFS cluster with admin and workers..."
  56. @docker-compose -f $(COMPOSE_FILE) up -d
  57. @echo "✅ Cluster started!"
  58. @echo ""
  59. @echo "📊 Access points:"
  60. @echo " • Admin UI: http://localhost:23646/"
  61. @echo " • Master UI: http://localhost:9333/"
  62. @echo " • Filer: http://localhost:8888/"
  63. @echo ""
  64. @echo "📈 Services starting up..."
  65. @echo " • Master server: ✓"
  66. @echo " • Volume servers: Starting (6 servers)..."
  67. @echo " • Filer: Starting..."
  68. @echo " • Admin server: Starting..."
  69. @echo " • Workers: Starting (3 workers)..."
  70. @echo ""
  71. @echo "⏳ Use 'make status' to check startup progress"
  72. @echo "💡 Use 'make logs' to watch the startup process"
  73. start-staged: ## Start services in proper order with delays
  74. @echo "🚀 Starting SeaweedFS cluster in stages..."
  75. @echo ""
  76. @echo "Stage 1: Starting Master server..."
  77. @docker-compose -f $(COMPOSE_FILE) up -d master
  78. @sleep 10
  79. @echo ""
  80. @echo "Stage 2: Starting Volume servers..."
  81. @docker-compose -f $(COMPOSE_FILE) up -d volume1 volume2 volume3 volume4 volume5 volume6
  82. @sleep 15
  83. @echo ""
  84. @echo "Stage 3: Starting Filer..."
  85. @docker-compose -f $(COMPOSE_FILE) up -d filer
  86. @sleep 10
  87. @echo ""
  88. @echo "Stage 4: Starting Admin server..."
  89. @docker-compose -f $(COMPOSE_FILE) up -d admin
  90. @sleep 15
  91. @echo ""
  92. @echo "Stage 5: Starting Workers..."
  93. @docker-compose -f $(COMPOSE_FILE) up -d worker1 worker2 worker3
  94. @sleep 10
  95. @echo ""
  96. @echo "Stage 6: Starting Load generator and Monitor..."
  97. @docker-compose -f $(COMPOSE_FILE) up -d load_generator monitor
  98. @echo ""
  99. @echo "✅ All services started!"
  100. @echo ""
  101. @echo "📊 Access points:"
  102. @echo " • Admin UI: http://localhost:23646/"
  103. @echo " • Master UI: http://localhost:9333/"
  104. @echo " • Filer: http://localhost:8888/"
  105. @echo ""
  106. @echo "⏳ Services are initializing... Use 'make status' to check progress"
  107. stop: ## Stop all services
  108. @echo "🛑 Stopping SeaweedFS cluster..."
  109. @docker-compose -f $(COMPOSE_FILE) down
  110. @echo "✅ Cluster stopped"
  111. restart: stop start ## Restart the entire cluster
  112. clean: ## Stop and remove all containers, networks, and volumes
  113. @echo "🧹 Cleaning up SeaweedFS test environment..."
  114. @docker-compose -f $(COMPOSE_FILE) down -v --remove-orphans
  115. @docker system prune -f
  116. @rm -rf data/
  117. @echo "✅ Environment cleaned"
  118. status: ## Check the status of all services
  119. @echo "📊 SeaweedFS Cluster Status"
  120. @echo "=========================="
  121. @docker-compose -f $(COMPOSE_FILE) ps
  122. @echo ""
  123. @echo "📋 Service Health:"
  124. @echo "Master:"
  125. @curl -s http://localhost:9333/cluster/status | jq '.IsLeader' 2>/dev/null || echo " ❌ Master not ready"
  126. @echo "Admin:"
  127. @curl -s http://localhost:23646/ | grep -q "Admin" && echo " ✅ Admin ready" || echo " ❌ Admin not ready"
  128. logs: ## Show logs from all services
  129. @echo "📜 Following logs from all services..."
  130. @echo "💡 Press Ctrl+C to stop following logs"
  131. @docker-compose -f $(COMPOSE_FILE) logs -f
  132. admin-logs: ## Show logs from admin server only
  133. @echo "📜 Admin server logs:"
  134. @docker-compose -f $(COMPOSE_FILE) logs -f admin
  135. worker-logs: ## Show logs from all workers
  136. @echo "📜 Worker logs:"
  137. @docker-compose -f $(COMPOSE_FILE) logs -f worker1 worker2 worker3
  138. master-logs: ## Show logs from master server
  139. @echo "📜 Master server logs:"
  140. @docker-compose -f $(COMPOSE_FILE) logs -f master
  141. admin-ui: ## Open admin UI in browser (macOS)
  142. @echo "🌐 Opening admin UI in browser..."
  143. @open http://localhost:23646/ || echo "💡 Manually open: http://localhost:23646/"
  144. test: ## Run integration test to verify task assignment and completion
  145. @echo "🧪 Running Admin-Worker Integration Test"
  146. @echo "========================================"
  147. @echo ""
  148. @echo "1️⃣ Checking cluster health..."
  149. @sleep 5
  150. @curl -s http://localhost:9333/cluster/status | jq '.IsLeader' > /dev/null && echo "✅ Master healthy" || echo "❌ Master not ready"
  151. @curl -s http://localhost:23646/ | grep -q "Admin" && echo "✅ Admin healthy" || echo "❌ Admin not ready"
  152. @echo ""
  153. @echo "2️⃣ Checking worker registration..."
  154. @sleep 10
  155. @echo "💡 Check admin UI for connected workers: http://localhost:23646/"
  156. @echo ""
  157. @echo "3️⃣ Generating load to trigger EC tasks..."
  158. @echo "📝 Creating test files to fill volumes..."
  159. @echo "Creating large files with random data to trigger EC (targeting ~60MB total to exceed 50MB limit)..."
  160. @for i in {1..12}; do \
  161. echo "Creating 5MB random file $$i..."; \
  162. docker run --rm --network admin_integration_seaweed_net -v /tmp:/tmp --entrypoint sh chrislusf/seaweedfs:local -c "dd if=/dev/urandom of=/tmp/largefile$$i.dat bs=1M count=5 2>/dev/null && weed upload -master=master:9333 /tmp/largefile$$i.dat && rm /tmp/largefile$$i.dat"; \
  163. sleep 3; \
  164. done
  165. @echo ""
  166. @echo "4️⃣ Waiting for volumes to process large files and reach 50MB limit..."
  167. @echo "This may take a few minutes as we're uploading 60MB of data..."
  168. @sleep 60
  169. @echo ""
  170. @echo "5️⃣ Checking for EC task creation and assignment..."
  171. @echo "💡 Monitor the admin UI to see:"
  172. @echo " • Tasks being created for volumes needing EC"
  173. @echo " • Workers picking up tasks"
  174. @echo " • Task progress (pending → running → completed)"
  175. @echo " • EC shards being distributed"
  176. @echo ""
  177. @echo "✅ Integration test setup complete!"
  178. @echo "📊 Monitor progress at: http://localhost:23646/"
  179. quick-test: ## Quick verification that core services are running
  180. @echo "⚡ Quick Health Check"
  181. @echo "===================="
  182. @echo "Master: $$(curl -s http://localhost:9333/cluster/status | jq -r '.IsLeader // "not ready"')"
  183. @echo "Admin: $$(curl -s http://localhost:23646/ | grep -q "Admin" && echo "ready" || echo "not ready")"
  184. @echo "Workers: $$(docker-compose -f $(COMPOSE_FILE) ps worker1 worker2 worker3 | grep -c Up) running"
  185. validate: ## Validate integration test configuration
  186. @echo "🔍 Validating Integration Test Configuration"
  187. @echo "==========================================="
  188. @chmod +x test-integration.sh
  189. @./test-integration.sh
  190. demo: start ## Start cluster and run demonstration
  191. @echo "🎭 SeaweedFS Admin-Worker Demo"
  192. @echo "============================="
  193. @echo ""
  194. @echo "⏳ Waiting for services to start..."
  195. @sleep 45
  196. @echo ""
  197. @echo "🎯 Demo Overview:"
  198. @echo " • 1 Master server (coordinates cluster)"
  199. @echo " • 6 Volume servers (50MB volume limit)"
  200. @echo " • 1 Admin server (task management)"
  201. @echo " • 3 Workers (execute EC tasks)"
  202. @echo " • Load generator (creates files continuously)"
  203. @echo ""
  204. @echo "📊 Watch the process:"
  205. @echo " 1. Visit: http://localhost:23646/"
  206. @echo " 2. Observe workers connecting"
  207. @echo " 3. Watch tasks being created and assigned"
  208. @echo " 4. See tasks progress from pending → completed"
  209. @echo ""
  210. @echo "🔄 The demo will:"
  211. @echo " • Fill volumes to 50MB limit"
  212. @echo " • Admin detects volumes needing EC"
  213. @echo " • Workers receive and execute EC tasks"
  214. @echo " • Tasks complete with shard distribution"
  215. @echo ""
  216. @echo "💡 Use 'make worker-logs' to see worker activity"
  217. @echo "💡 Use 'make admin-logs' to see admin task management"
  218. # Vacuum Testing Targets
  219. vacuum-test: ## Create test data with garbage and verify vacuum detection
  220. @echo "🧪 SeaweedFS Vacuum Task Testing"
  221. @echo "================================"
  222. @echo ""
  223. @echo "1️⃣ Checking cluster health..."
  224. @curl -s http://localhost:9333/cluster/status | jq '.IsLeader' > /dev/null && echo "✅ Master ready" || (echo "❌ Master not ready. Run 'make start' first." && exit 1)
  225. @curl -s http://localhost:23646/ | grep -q "Admin" && echo "✅ Admin ready" || (echo "❌ Admin not ready. Run 'make start' first." && exit 1)
  226. @echo ""
  227. @echo "2️⃣ Creating test data with garbage..."
  228. @docker-compose -f $(COMPOSE_FILE) exec vacuum-tester go run create_vacuum_test_data.go -files=25 -delete=0.5 -size=200
  229. @echo ""
  230. @echo "3️⃣ Configuration Instructions:"
  231. @echo " Visit: http://localhost:23646/maintenance/config/vacuum"
  232. @echo " Set for testing:"
  233. @echo " • Enable Vacuum Tasks: ✅ Checked"
  234. @echo " • Garbage Threshold: 0.20 (20%)"
  235. @echo " • Scan Interval: [30] [Seconds]"
  236. @echo " • Min Volume Age: [0] [Minutes]"
  237. @echo " • Max Concurrent: 2"
  238. @echo ""
  239. @echo "4️⃣ Monitor vacuum tasks at: http://localhost:23646/maintenance"
  240. @echo ""
  241. @echo "💡 Use 'make vacuum-status' to check volume garbage ratios"
  242. vacuum-demo: ## Run automated vacuum testing demonstration
  243. @echo "🎭 Vacuum Task Demo"
  244. @echo "=================="
  245. @echo ""
  246. @echo "⚠️ This demo requires user interaction for configuration"
  247. @echo "💡 Make sure cluster is running with 'make start'"
  248. @echo ""
  249. @docker-compose -f $(COMPOSE_FILE) exec vacuum-tester sh -c "chmod +x demo_vacuum_testing.sh && ./demo_vacuum_testing.sh"
  250. vacuum-status: ## Check current volume status and garbage ratios
  251. @echo "📊 Current Volume Status"
  252. @echo "======================="
  253. @docker-compose -f $(COMPOSE_FILE) exec vacuum-tester sh -c "chmod +x check_volumes.sh && ./check_volumes.sh"
  254. vacuum-data: ## Create test data with configurable parameters
  255. @echo "📁 Creating vacuum test data..."
  256. @echo "Usage: make vacuum-data [FILES=20] [DELETE=0.4] [SIZE=100]"
  257. @echo ""
  258. @docker-compose -f $(COMPOSE_FILE) exec vacuum-tester go run create_vacuum_test_data.go \
  259. -files=$${FILES:-20} \
  260. -delete=$${DELETE:-0.4} \
  261. -size=$${SIZE:-100}
  262. vacuum-data-high: ## Create high garbage ratio test data (should trigger vacuum)
  263. @echo "📁 Creating high garbage test data (70% garbage)..."
  264. @docker-compose -f $(COMPOSE_FILE) exec vacuum-tester go run create_vacuum_test_data.go -files=30 -delete=0.7 -size=150
  265. vacuum-data-low: ## Create low garbage ratio test data (should NOT trigger vacuum)
  266. @echo "📁 Creating low garbage test data (15% garbage)..."
  267. @docker-compose -f $(COMPOSE_FILE) exec vacuum-tester go run create_vacuum_test_data.go -files=30 -delete=0.15 -size=150
  268. vacuum-continuous: ## Generate garbage continuously for testing
  269. @echo "🔄 Generating continuous garbage for vacuum testing..."
  270. @echo "Creating 5 rounds of test data with 30-second intervals..."
  271. @for i in {1..5}; do \
  272. echo "Round $$i: Creating garbage..."; \
  273. docker-compose -f $(COMPOSE_FILE) exec vacuum-tester go run create_vacuum_test_data.go -files=10 -delete=0.6 -size=100; \
  274. echo "Waiting 30 seconds..."; \
  275. sleep 30; \
  276. done
  277. @echo "✅ Continuous test complete. Check vacuum task activity!"
  278. vacuum-clean: ## Clean up vacuum test data (removes all volumes!)
  279. @echo "🧹 Cleaning up vacuum test data..."
  280. @echo "⚠️ WARNING: This will delete ALL volumes!"
  281. @read -p "Are you sure? (y/N): " confirm && [ "$$confirm" = "y" ] || exit 1
  282. @echo "Stopping cluster..."
  283. @docker-compose -f $(COMPOSE_FILE) down
  284. @echo "Removing volume data..."
  285. @rm -rf data/volume*/
  286. @echo "Restarting cluster..."
  287. @docker-compose -f $(COMPOSE_FILE) up -d
  288. @echo "✅ Clean up complete. Fresh volumes ready for testing."
  289. vacuum-help: ## Show vacuum testing help and examples
  290. @echo "🧪 Vacuum Testing Commands (Docker-based)"
  291. @echo "=========================================="
  292. @echo ""
  293. @echo "Quick Start:"
  294. @echo " make start # Start SeaweedFS cluster with vacuum-tester"
  295. @echo " make vacuum-test # Create test data and instructions"
  296. @echo " make vacuum-status # Check volume status"
  297. @echo ""
  298. @echo "Data Generation:"
  299. @echo " make vacuum-data-high # High garbage (should trigger)"
  300. @echo " make vacuum-data-low # Low garbage (should NOT trigger)"
  301. @echo " make vacuum-continuous # Continuous garbage generation"
  302. @echo ""
  303. @echo "Monitoring:"
  304. @echo " make vacuum-status # Quick volume status check"
  305. @echo " make vacuum-demo # Full guided demonstration"
  306. @echo ""
  307. @echo "Configuration:"
  308. @echo " Visit: http://localhost:23646/maintenance/config/vacuum"
  309. @echo " Monitor: http://localhost:23646/maintenance"
  310. @echo ""
  311. @echo "Custom Parameters:"
  312. @echo " make vacuum-data FILES=50 DELETE=0.8 SIZE=200"
  313. @echo ""
  314. @echo "💡 All commands now run inside Docker containers"
  315. @echo "Documentation:"
  316. @echo " See: VACUUM_TEST_README.md for complete guide"