Makefile 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. # SeaweedFS KMS Integration Testing Makefile
  2. # Configuration
  3. OPENBAO_ADDR ?= http://127.0.0.1:8200
  4. OPENBAO_TOKEN ?= root-token-for-testing
  5. SEAWEEDFS_S3_ENDPOINT ?= http://127.0.0.1:8333
  6. TEST_TIMEOUT ?= 5m
  7. DOCKER_COMPOSE ?= docker-compose
  8. # Colors for output
  9. BLUE := \033[36m
  10. GREEN := \033[32m
  11. YELLOW := \033[33m
  12. RED := \033[31m
  13. NC := \033[0m # No Color
  14. .PHONY: help setup test test-unit test-integration test-e2e clean logs status
  15. help: ## Show this help message
  16. @echo "$(BLUE)SeaweedFS KMS Integration Testing$(NC)"
  17. @echo ""
  18. @echo "Available targets:"
  19. @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " $(GREEN)%-15s$(NC) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
  20. setup: ## Set up test environment (OpenBao + SeaweedFS)
  21. @echo "$(YELLOW)Setting up test environment...$(NC)"
  22. @chmod +x setup_openbao.sh
  23. @$(DOCKER_COMPOSE) up -d openbao
  24. @sleep 5
  25. @echo "$(BLUE)Configuring OpenBao...$(NC)"
  26. @OPENBAO_ADDR=$(OPENBAO_ADDR) OPENBAO_TOKEN=$(OPENBAO_TOKEN) ./setup_openbao.sh
  27. @echo "$(GREEN)✅ Test environment ready!$(NC)"
  28. test: setup test-unit test-integration ## Run all tests
  29. test-unit: ## Run unit tests for KMS providers
  30. @echo "$(YELLOW)Running KMS provider unit tests...$(NC)"
  31. @cd ../../ && go test -v -timeout=$(TEST_TIMEOUT) ./weed/kms/...
  32. test-integration: ## Run integration tests with OpenBao
  33. @echo "$(YELLOW)Running KMS integration tests...$(NC)"
  34. @cd ../../ && go test -v -timeout=$(TEST_TIMEOUT) ./test/kms/...
  35. test-benchmark: ## Run performance benchmarks
  36. @echo "$(YELLOW)Running KMS performance benchmarks...$(NC)"
  37. @cd ../../ && go test -v -timeout=$(TEST_TIMEOUT) -bench=. ./test/kms/...
  38. test-e2e: setup-seaweedfs ## Run end-to-end tests with SeaweedFS + KMS
  39. @echo "$(YELLOW)Running end-to-end KMS tests...$(NC)"
  40. @sleep 10 # Wait for SeaweedFS to be ready
  41. @./test_s3_kms.sh
  42. setup-seaweedfs: ## Start complete SeaweedFS cluster with KMS
  43. @echo "$(YELLOW)Starting SeaweedFS cluster...$(NC)"
  44. @$(DOCKER_COMPOSE) up -d
  45. @echo "$(BLUE)Waiting for services to be ready...$(NC)"
  46. @./wait_for_services.sh
  47. test-aws-compat: ## Test AWS KMS API compatibility
  48. @echo "$(YELLOW)Testing AWS KMS compatibility...$(NC)"
  49. @cd ../../ && go test -v -timeout=$(TEST_TIMEOUT) -run TestAWSKMSCompat ./test/kms/...
  50. clean: ## Clean up test environment
  51. @echo "$(YELLOW)Cleaning up test environment...$(NC)"
  52. @$(DOCKER_COMPOSE) down -v --remove-orphans
  53. @docker system prune -f
  54. @echo "$(GREEN)✅ Environment cleaned up!$(NC)"
  55. logs: ## Show logs from all services
  56. @$(DOCKER_COMPOSE) logs --tail=50 -f
  57. logs-openbao: ## Show OpenBao logs
  58. @$(DOCKER_COMPOSE) logs --tail=100 -f openbao
  59. logs-seaweedfs: ## Show SeaweedFS logs
  60. @$(DOCKER_COMPOSE) logs --tail=100 -f seaweedfs-filer seaweedfs-master seaweedfs-volume
  61. status: ## Show status of all services
  62. @echo "$(BLUE)Service Status:$(NC)"
  63. @$(DOCKER_COMPOSE) ps
  64. @echo ""
  65. @echo "$(BLUE)OpenBao Status:$(NC)"
  66. @curl -s $(OPENBAO_ADDR)/v1/sys/health | jq '.' || echo "OpenBao not accessible"
  67. @echo ""
  68. @echo "$(BLUE)SeaweedFS S3 Status:$(NC)"
  69. @curl -s $(SEAWEEDFS_S3_ENDPOINT) || echo "SeaweedFS S3 not accessible"
  70. debug: ## Debug test environment
  71. @echo "$(BLUE)Debug Information:$(NC)"
  72. @echo "OpenBao Address: $(OPENBAO_ADDR)"
  73. @echo "SeaweedFS S3 Endpoint: $(SEAWEEDFS_S3_ENDPOINT)"
  74. @echo "Docker Compose Status:"
  75. @$(DOCKER_COMPOSE) ps
  76. @echo ""
  77. @echo "Network connectivity:"
  78. @docker network ls | grep seaweedfs || echo "No SeaweedFS network found"
  79. @echo ""
  80. @echo "OpenBao health:"
  81. @curl -v $(OPENBAO_ADDR)/v1/sys/health 2>&1 || true
  82. # Development targets
  83. dev-openbao: ## Start only OpenBao for development
  84. @$(DOCKER_COMPOSE) up -d openbao
  85. @sleep 5
  86. @OPENBAO_ADDR=$(OPENBAO_ADDR) OPENBAO_TOKEN=$(OPENBAO_TOKEN) ./setup_openbao.sh
  87. dev-test: dev-openbao ## Quick test with just OpenBao
  88. @cd ../../ && go test -v -timeout=30s -run TestOpenBaoKMSProvider_Integration ./test/kms/
  89. # Utility targets
  90. install-deps: ## Install required dependencies
  91. @echo "$(YELLOW)Installing test dependencies...$(NC)"
  92. @which docker > /dev/null || (echo "$(RED)Docker not found$(NC)" && exit 1)
  93. @which docker-compose > /dev/null || (echo "$(RED)Docker Compose not found$(NC)" && exit 1)
  94. @which jq > /dev/null || (echo "$(RED)jq not found - please install jq$(NC)" && exit 1)
  95. @which curl > /dev/null || (echo "$(RED)curl not found$(NC)" && exit 1)
  96. @echo "$(GREEN)✅ All dependencies available$(NC)"
  97. check-env: ## Check test environment setup
  98. @echo "$(BLUE)Environment Check:$(NC)"
  99. @echo "OPENBAO_ADDR: $(OPENBAO_ADDR)"
  100. @echo "OPENBAO_TOKEN: $(OPENBAO_TOKEN)"
  101. @echo "SEAWEEDFS_S3_ENDPOINT: $(SEAWEEDFS_S3_ENDPOINT)"
  102. @echo "TEST_TIMEOUT: $(TEST_TIMEOUT)"
  103. @make install-deps
  104. # CI targets
  105. ci-test: ## Run tests in CI environment
  106. @echo "$(YELLOW)Running CI tests...$(NC)"
  107. @make setup
  108. @make test-unit
  109. @make test-integration
  110. @make clean
  111. ci-e2e: ## Run end-to-end tests in CI
  112. @echo "$(YELLOW)Running CI end-to-end tests...$(NC)"
  113. @make setup-seaweedfs
  114. @make test-e2e
  115. @make clean