Makefile 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. .PHONY: build run clean test deps proto integration-test test-all
  2. # Build the telemetry server
  3. build:
  4. go build -o telemetry-server .
  5. # Run the server in development mode
  6. run:
  7. go run . -port=8080 -dashboard=true -cleanup=1h -max-age=24h
  8. # Run the server in production mode
  9. run-prod:
  10. ./telemetry-server -port=8080 -dashboard=true -cleanup=24h -max-age=720h
  11. # Clean build artifacts
  12. clean:
  13. rm -f telemetry-server
  14. rm -f ../test/telemetry-server-test.log
  15. go clean
  16. # Run unit tests
  17. test:
  18. go test ./...
  19. # Run integration tests
  20. integration-test:
  21. @echo "🧪 Running telemetry integration tests..."
  22. cd ../../ && go run telemetry/test/integration.go
  23. # Run all tests (unit + integration)
  24. test-all: test integration-test
  25. # Install dependencies
  26. deps:
  27. go mod download
  28. go mod tidy
  29. # Generate protobuf code (requires protoc)
  30. proto:
  31. cd .. && protoc --go_out=. --go_opt=paths=source_relative proto/telemetry.proto
  32. # Build Docker image
  33. docker-build:
  34. docker build -t seaweedfs-telemetry .
  35. # Run with Docker
  36. docker-run:
  37. docker run -p 8080:8080 seaweedfs-telemetry -port=8080 -dashboard=true
  38. # Development with auto-reload (requires air: go install github.com/cosmtrek/air@latest)
  39. dev:
  40. air
  41. # Check if protoc is available
  42. check-protoc:
  43. @which protoc > /dev/null || (echo "protoc is required for proto generation. Install from https://grpc.io/docs/protoc-installation/" && exit 1)
  44. # Full development setup
  45. setup: check-protoc deps proto build
  46. # Run a quick smoke test
  47. smoke-test: build
  48. @echo "🔥 Running smoke test..."
  49. @timeout 10s ./telemetry-server -port=18081 > /dev/null 2>&1 & \
  50. SERVER_PID=$$!; \
  51. sleep 2; \
  52. if curl -s http://localhost:18081/health > /dev/null; then \
  53. echo "✅ Smoke test passed - server responds to health check"; \
  54. else \
  55. echo "❌ Smoke test failed - server not responding"; \
  56. exit 1; \
  57. fi; \
  58. kill $$SERVER_PID 2>/dev/null || true
  59. # Continuous integration target
  60. ci: deps proto build test integration-test
  61. @echo "🎉 All CI tests passed!"
  62. # Help
  63. help:
  64. @echo "Available targets:"
  65. @echo " build - Build the telemetry server binary"
  66. @echo " run - Run server in development mode"
  67. @echo " run-prod - Run server in production mode"
  68. @echo " clean - Clean build artifacts"
  69. @echo " test - Run unit tests"
  70. @echo " integration-test- Run integration tests"
  71. @echo " test-all - Run all tests (unit + integration)"
  72. @echo " deps - Install Go dependencies"
  73. @echo " proto - Generate protobuf code"
  74. @echo " docker-build - Build Docker image"
  75. @echo " docker-run - Run with Docker"
  76. @echo " dev - Run with auto-reload (requires air)"
  77. @echo " smoke-test - Quick server health check"
  78. @echo " setup - Full development setup"
  79. @echo " ci - Continuous integration (all tests)"
  80. @echo " help - Show this help"