diff options
Diffstat (limited to 'test/s3/iam/Makefile.docker')
| -rw-r--r-- | test/s3/iam/Makefile.docker | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/test/s3/iam/Makefile.docker b/test/s3/iam/Makefile.docker new file mode 100644 index 000000000..0e175a1aa --- /dev/null +++ b/test/s3/iam/Makefile.docker @@ -0,0 +1,166 @@ +# 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" |
