blob: 0e175a1aafac8b86da9e5e9e0c7a3ccc2e5d89a9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
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"
|