# Makefile for SeaweedFS S3 IAM Integration Tests with Docker Compose .PHONY: help docker-build docker-up docker-down docker-logs docker-test docker-clean docker-status docker-keycloak-setup # Default target .DEFAULT_GOAL := help # Docker Compose configuration COMPOSE_FILE := docker-compose.yml PROJECT_NAME := seaweedfs-iam-test help: ## Show this help message @echo "SeaweedFS S3 IAM Integration Tests - Docker Compose" @echo "" @echo "Available commands:" @echo "" @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) @echo "" @echo "Environment:" @echo " COMPOSE_FILE: $(COMPOSE_FILE)" @echo " PROJECT_NAME: $(PROJECT_NAME)" docker-build: ## Build local SeaweedFS image for testing @echo "๐Ÿ”จ Building local SeaweedFS image..." @echo "Creating build directory..." @cd ../../.. && mkdir -p .docker-build @echo "Building weed binary..." @cd ../../.. && cd weed && go build -o ../.docker-build/weed @echo "Copying required files to build directory..." @cd ../../.. && cp docker/filer.toml .docker-build/ && cp docker/entrypoint.sh .docker-build/ @echo "Building Docker image..." @cd ../../.. && docker build -f docker/Dockerfile.local -t local/seaweedfs:latest .docker-build/ @echo "Cleaning up build directory..." @cd ../../.. && rm -rf .docker-build @echo "โœ… Built local/seaweedfs:latest" docker-up: ## Start all services with Docker Compose @echo "๐Ÿš€ Starting SeaweedFS S3 IAM integration environment..." @docker-compose -p $(PROJECT_NAME) -f $(COMPOSE_FILE) up -d @echo "" @echo "โœ… Environment started! Services will be available at:" @echo " ๐Ÿ” Keycloak: http://localhost:8080 (admin/admin)" @echo " ๐Ÿ—„๏ธ S3 API: http://localhost:8333" @echo " ๐Ÿ“ Filer: http://localhost:8888" @echo " ๐ŸŽฏ Master: http://localhost:9333" @echo "" @echo "โณ Waiting for all services to be healthy..." @docker-compose -p $(PROJECT_NAME) -f $(COMPOSE_FILE) ps docker-down: ## Stop and remove all containers @echo "๐Ÿ›‘ Stopping SeaweedFS S3 IAM integration environment..." @docker-compose -p $(PROJECT_NAME) -f $(COMPOSE_FILE) down -v @echo "โœ… Environment stopped and cleaned up" docker-restart: docker-down docker-up ## Restart the entire environment docker-logs: ## Show logs from all services @docker-compose -p $(PROJECT_NAME) -f $(COMPOSE_FILE) logs -f docker-logs-s3: ## Show logs from S3 service only @docker-compose -p $(PROJECT_NAME) -f $(COMPOSE_FILE) logs -f weed-s3 docker-logs-keycloak: ## Show logs from Keycloak service only @docker-compose -p $(PROJECT_NAME) -f $(COMPOSE_FILE) logs -f keycloak docker-status: ## Check status of all services @echo "๐Ÿ“Š Service Status:" @docker-compose -p $(PROJECT_NAME) -f $(COMPOSE_FILE) ps @echo "" @echo "๐Ÿฅ Health Checks:" @docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" | grep $(PROJECT_NAME) || true docker-test: docker-wait-healthy ## Run integration tests against Docker environment @echo "๐Ÿงช Running SeaweedFS S3 IAM integration tests..." @echo "" @KEYCLOAK_URL=http://localhost:8080 go test -v -timeout 10m ./... docker-test-single: ## Run a single test (use TEST_NAME=TestName) @if [ -z "$(TEST_NAME)" ]; then \ echo "โŒ Please specify TEST_NAME, e.g., make docker-test-single TEST_NAME=TestKeycloakAuthentication"; \ exit 1; \ fi @echo "๐Ÿงช Running single test: $(TEST_NAME)" @KEYCLOAK_URL=http://localhost:8080 go test -v -run "$(TEST_NAME)" -timeout 5m ./... docker-keycloak-setup: ## Manually run Keycloak setup (usually automatic) @echo "๐Ÿ”ง Running Keycloak setup manually..." @docker-compose -p $(PROJECT_NAME) -f $(COMPOSE_FILE) run --rm keycloak-setup docker-clean: ## Clean up everything (containers, volumes, images) @echo "๐Ÿงน Cleaning up Docker environment..." @docker-compose -p $(PROJECT_NAME) -f $(COMPOSE_FILE) down -v --remove-orphans @docker system prune -f @echo "โœ… Cleanup complete" docker-shell-s3: ## Get shell access to S3 container @docker-compose -p $(PROJECT_NAME) -f $(COMPOSE_FILE) exec weed-s3 sh docker-shell-keycloak: ## Get shell access to Keycloak container @docker-compose -p $(PROJECT_NAME) -f $(COMPOSE_FILE) exec keycloak bash docker-debug: ## Show debug information @echo "๐Ÿ” Docker Environment Debug Information" @echo "" @echo "๐Ÿ“‹ Docker Compose Config:" @docker-compose -p $(PROJECT_NAME) -f $(COMPOSE_FILE) config @echo "" @echo "๐Ÿ“Š Container Status:" @docker-compose -p $(PROJECT_NAME) -f $(COMPOSE_FILE) ps @echo "" @echo "๐ŸŒ Network Information:" @docker network ls | grep $(PROJECT_NAME) || echo "No networks found" @echo "" @echo "๐Ÿ’พ Volume Information:" @docker volume ls | grep $(PROJECT_NAME) || echo "No volumes found" # Quick test targets docker-test-auth: ## Quick test of authentication only @KEYCLOAK_URL=http://localhost:8080 go test -v -run "TestKeycloakAuthentication" -timeout 2m ./... docker-test-roles: ## Quick test of role mapping only @KEYCLOAK_URL=http://localhost:8080 go test -v -run "TestKeycloakRoleMapping" -timeout 2m ./... docker-test-s3ops: ## Quick test of S3 operations only @KEYCLOAK_URL=http://localhost:8080 go test -v -run "TestKeycloakS3Operations" -timeout 2m ./... # Development workflow docker-dev: docker-down docker-up docker-test ## Complete dev workflow: down -> up -> test # Show service URLs for easy access docker-urls: ## Display all service URLs @echo "๐ŸŒ Service URLs:" @echo "" @echo " ๐Ÿ” Keycloak Admin: http://localhost:8080 (admin/admin)" @echo " ๐Ÿ” Keycloak Realm: http://localhost:8080/realms/seaweedfs-test" @echo " ๐Ÿ“ S3 API: http://localhost:8333" @echo " ๐Ÿ“‚ Filer UI: http://localhost:8888" @echo " ๐ŸŽฏ Master UI: http://localhost:9333" @echo " ๐Ÿ’พ Volume Server: http://localhost:8080" @echo "" @echo " ๐Ÿ“– Test Users:" @echo " โ€ข admin-user (password: adminuser123) - s3-admin role" @echo " โ€ข read-user (password: readuser123) - s3-read-only role" @echo " โ€ข write-user (password: writeuser123) - s3-read-write role" @echo " โ€ข write-only-user (password: writeonlyuser123) - s3-write-only role" # Wait targets for CI/CD docker-wait-healthy: ## Wait for all services to be healthy @echo "โณ Waiting for all services to be healthy..." @timeout 300 bash -c ' \ required_services="keycloak weed-master weed-volume weed-filer weed-s3"; \ while true; do \ all_healthy=true; \ for service in $$required_services; do \ if ! docker-compose -p $(PROJECT_NAME) -f $(COMPOSE_FILE) ps $$service | grep -q "healthy"; then \ echo "Waiting for $$service to be healthy..."; \ all_healthy=false; \ break; \ fi; \ done; \ if [ "$$all_healthy" = "true" ]; then \ break; \ fi; \ sleep 5; \ done \ ' @echo "โœ… All required services are healthy"