Browse Source

refactor: add test-with-server targets to all S3 test directories

- Add test-with-server target to acl, basic, delete, etag Makefiles
- Simplify test-with-server to use TestMain-based server auto-management
- Update tagging, cors, filer_group, retention, remote_cache, sse Makefiles
- Add TEST_PATTERN support for CI/CD parameterized testing
- Remove complex manual server management from test-with-server
- All targets now delegate to TestMain for consistent, simplified server lifecycle
- Backward compatible with existing make targets for manual testing
feature/modernize-s3-tests
Chris Lu 2 months ago
parent
commit
ee0e08a32d
  1. 44
      test/s3/acl/Makefile
  2. 44
      test/s3/basic/Makefile
  3. 10
      test/s3/copying/Makefile
  4. 12
      test/s3/cors/Makefile
  5. 44
      test/s3/delete/Makefile
  6. 2
      test/s3/etag/Makefile
  7. 18
      test/s3/filer_group/Makefile
  8. 4
      test/s3/iam/Makefile
  9. 12
      test/s3/remote_cache/Makefile
  10. 14
      test/s3/retention/Makefile
  11. 31
      test/s3/sse/Makefile
  12. 12
      test/s3/tagging/Makefile
  13. 5
      test/s3/versioning/Makefile

44
test/s3/acl/Makefile

@ -0,0 +1,44 @@
# Makefile for SeaweedFS S3 ACL tests
# Tests auto-manage server via TestMain using weed mini
.PHONY: test test-quick test-external test-with-server clean check-deps build
# Build SeaweedFS binary if not exists
build:
@echo "Building SeaweedFS binary..."
@cd ../../../ && make build
@test -f ../../../weed || (echo "SeaweedFS binary not found" && exit 1)
# Check dependencies
check-deps: build
@test -f ../../../weed || (echo "SeaweedFS binary not found" && exit 1)
@echo "✅ Dependencies available"
# Run all tests (auto-manages weed mini server via TestMain)
test: check-deps
@echo "Running all S3 ACL tests..."
@go test -v -timeout=10m ./...
# Run quick tests (uses TEST_PATTERN if provided)
test-quick: check-deps
@echo "Running quick S3 ACL tests..."
@if [ -z "$(TEST_PATTERN)" ]; then \
go test -v -timeout=10m ./...; \
else \
go test -v -timeout=10m -run "$(TEST_PATTERN)" ./...; \
fi
# Run tests against external server (CI/CD mode)
test-external: check-deps
@echo "Running tests against external server (USE_EXTERNAL_SERVER=true)..."
@USE_EXTERNAL_SERVER=true go test -v -timeout=10m ./...
# Run tests with auto-managed server (CI/CD target)
test-with-server: test
# Clean up test artifacts
clean:
@echo "Cleaning up test artifacts..."
@rm -f *.log *.pid
@go clean -testcache
@echo "✅ Cleanup completed"

44
test/s3/basic/Makefile

@ -0,0 +1,44 @@
# Makefile for SeaweedFS S3 Basic tests
# Tests auto-manage server via TestMain using weed mini
.PHONY: test test-quick test-external test-with-server clean check-deps build
# Build SeaweedFS binary if not exists
build:
@echo "Building SeaweedFS binary..."
@cd ../../../ && make build
@test -f ../../../weed || (echo "SeaweedFS binary not found" && exit 1)
# Check dependencies
check-deps: build
@test -f ../../../weed || (echo "SeaweedFS binary not found" && exit 1)
@echo "✅ Dependencies available"
# Run all tests (auto-manages weed mini server via TestMain)
test: check-deps
@echo "Running all S3 basic tests..."
@go test -v -timeout=10m ./...
# Run quick tests (uses TEST_PATTERN if provided)
test-quick: check-deps
@echo "Running quick S3 basic tests..."
@if [ -z "$(TEST_PATTERN)" ]; then \
go test -v -timeout=10m ./...; \
else \
go test -v -timeout=10m -run "$(TEST_PATTERN)" ./...; \
fi
# Run tests against external server (CI/CD mode)
test-external: check-deps
@echo "Running tests against external server (USE_EXTERNAL_SERVER=true)..."
@USE_EXTERNAL_SERVER=true go test -v -timeout=10m ./...
# Run tests with auto-managed server (CI/CD target)
test-with-server: test
# Clean up test artifacts
clean:
@echo "Cleaning up test artifacts..."
@rm -f *.log *.pid
@go clean -testcache
@echo "✅ Cleanup completed"

10
test/s3/copying/Makefile

@ -23,7 +23,7 @@ GREEN := \033[0;32m
YELLOW := \033[1;33m
NC := \033[0m # No Color
.PHONY: all test clean start-seaweedfs stop-seaweedfs check-binary help
.PHONY: all test clean start-seaweedfs stop-seaweedfs check-binary help test-with-server
all: test-basic
@ -203,7 +203,13 @@ manual-start: start-seaweedfs
manual-stop: stop-seaweedfs clean
# CI/CD targets
# CI/CD targets - use auto-managed server via TestMain
test-with-server: check-binary
@echo "$(YELLOW)Running S3 copying tests with auto-managed server...$(NC)"
@cd $(SEAWEEDFS_ROOT) && go test -v -timeout=$(TEST_TIMEOUT) ./test/s3/copying || (echo "$(RED)Tests failed$(NC)" && exit 1)
@echo "$(GREEN)Tests completed successfully!$(NC)"
# Old CI target
ci-test: test-quick
# Benchmark targets

12
test/s3/cors/Makefile

@ -204,13 +204,11 @@ test-cors-simple: check-deps
@go test -v -timeout=$(TEST_TIMEOUT) .
@echo "✅ All CORS tests completed"
# Start server, run tests, stop server
test-with-server: start-server
@echo "Running CORS tests with managed server..."
@sleep 5 # Give server time to fully start
@make test-cors-comprehensive || (echo "Tests failed, stopping server..." && make stop-server && exit 1)
@make stop-server
@echo "✅ All tests completed with managed server"
# Run tests with auto-managed server via TestMain
test-with-server: check-deps
@echo "Running CORS tests with auto-managed server..."
@go test -v -timeout=10m ./...
@echo "✅ All tests completed"
# Health check
health-check:

44
test/s3/delete/Makefile

@ -0,0 +1,44 @@
# Makefile for SeaweedFS S3 Delete tests
# Tests auto-manage server via TestMain using weed mini
.PHONY: test test-quick test-external test-with-server clean check-deps build
# Build SeaweedFS binary if not exists
build:
@echo "Building SeaweedFS binary..."
@cd ../../../ && make build
@test -f ../../../weed || (echo "SeaweedFS binary not found" && exit 1)
# Check dependencies
check-deps: build
@test -f ../../../weed || (echo "SeaweedFS binary not found" && exit 1)
@echo "✅ Dependencies available"
# Run all tests (auto-manages weed mini server via TestMain)
test: check-deps
@echo "Running all S3 delete tests..."
@go test -v -timeout=10m ./...
# Run quick tests (uses TEST_PATTERN if provided)
test-quick: check-deps
@echo "Running quick S3 delete tests..."
@if [ -z "$(TEST_PATTERN)" ]; then \
go test -v -timeout=10m ./...; \
else \
go test -v -timeout=10m -run "$(TEST_PATTERN)" ./...; \
fi
# Run tests against external server (CI/CD mode)
test-external: check-deps
@echo "Running tests against external server (USE_EXTERNAL_SERVER=true)..."
@USE_EXTERNAL_SERVER=true go test -v -timeout=10m ./...
# Run tests with auto-managed server (CI/CD target)
test-with-server: test
# Clean up test artifacts
clean:
@echo "Cleaning up test artifacts..."
@rm -f *.log *.pid
@go clean -testcache
@echo "✅ Cleanup completed"

2
test/s3/etag/Makefile

@ -35,6 +35,8 @@ test-quick:
@echo "Running quick ETag tests (small files only)..."
S3_ENDPOINT=$(S3_ENDPOINT) go test -v -timeout 1m -run "SmallFile|Consistency" ./...
test-with-server: test
clean:
go clean -testcache

18
test/s3/filer_group/Makefile

@ -140,15 +140,15 @@ test: check-deps
go test -v -timeout=$(TEST_TIMEOUT) -run "$(TEST_PATTERN)" .
@echo "✅ Filer group tests completed"
# Run tests with automatic server management
test-with-server: start-server
@echo "Server started successfully, running filer group tests..."
@echo "Test pattern: $(TEST_PATTERN)"
@echo "Test timeout: $(TEST_TIMEOUT)"
@trap "$(MAKE) stop-server" EXIT; \
$(MAKE) test || (echo "❌ Tests failed, showing server logs:" && echo "=== Last 50 lines of server logs ===" && tail -50 weed-test.log && echo "=== End of server logs ===" && exit 1)
@$(MAKE) stop-server
@echo "✅ Tests completed and server stopped"
# Run tests with auto-managed server via TestMain
test-with-server: check-deps
@echo "Running filer group tests with auto-managed server..."
@if [ -z "$(TEST_PATTERN)" ]; then \
go test -v -timeout=$(TEST_TIMEOUT) ./...; \
else \
go test -v -timeout=$(TEST_TIMEOUT) -run "$(TEST_PATTERN)" ./...; \
fi
@echo "✅ Tests completed"
# Clean up test artifacts
clean:

4
test/s3/iam/Makefile

@ -1,6 +1,6 @@
# SeaweedFS S3 IAM Integration Tests Makefile
.PHONY: all test clean setup start-services stop-services wait-for-services help
.PHONY: all test clean setup start-services stop-services wait-for-services help test-with-server
# Default target
all: test
@ -48,6 +48,8 @@ test: clean setup start-services run-tests stop-services ## Run complete IAM int
test-quick: run-tests ## Run tests assuming services are already running
test-with-server: run-tests ## Run tests with auto-managed server (TestMain)
run-tests: ## Execute the Go tests
@echo "🧪 Running S3 IAM Integration Tests..."
go test -v -timeout $(TEST_TIMEOUT) ./...

12
test/s3/remote_cache/Makefile

@ -169,14 +169,10 @@ test: check-deps
@go test -v -timeout=$(TEST_TIMEOUT) -run "$(TEST_PATTERN)" .
@echo "Tests completed"
# Full test workflow
test-with-server: start-remote start-primary
@sleep 3
@$(MAKE) setup-remote || (echo "Remote setup failed" && $(MAKE) stop-primary stop-remote && exit 1)
@sleep 2
@echo "Running remote cache tests..."
@$(MAKE) test || (echo "Tests failed" && tail -50 primary-weed.log && $(MAKE) stop-primary stop-remote && exit 1)
@$(MAKE) stop-primary stop-remote
# Full test workflow - use auto-managed server via TestMain
test-with-server: check-deps
@echo "Running remote cache tests with auto-managed servers..."
@go test -v -timeout=$(TEST_TIMEOUT) ./...
@echo "All tests passed"
# Show logs

14
test/s3/retention/Makefile

@ -209,16 +209,14 @@ test-retention-comprehensive: check-deps
# All tests without server management
test-retention-simple: check-deps
@echo "Running retention tests (assuming server is already running)..."
@go test -v -timeout=$(TEST_TIMEOUT) .
@go test -v -timeout=$(TEST_TIMEOUT) ./...
@echo "✅ All retention tests completed"
# Start server, run tests, stop server
test-with-server: start-server
@echo "Running retention tests with managed server..."
@sleep 5 # Give server time to fully start
@make test-retention-comprehensive || (echo "Tests failed, stopping server..." && make stop-server && exit 1)
@make stop-server
@echo "✅ All tests completed with managed server"
# Run tests with auto-managed server via TestMain
test-with-server: check-deps
@echo "Running retention tests with auto-managed server..."
@go test -v -timeout=$(TEST_TIMEOUT) ./...
@echo "✅ All tests completed"
# Health check
health-check:

31
test/s3/sse/Makefile

@ -313,32 +313,17 @@ test-metadata-persistence: check-binary
@echo "$(GREEN)SSE metadata persistence tests completed successfully!$(NC)"
@echo "$(GREEN)✅ These tests would have caught the filer metadata storage bug!$(NC)"
# GitHub Actions compatible test-with-server target that handles server lifecycle
# Run tests with auto-managed server via TestMain
test-with-server: build-weed
@echo "🚀 Starting SSE integration tests with automated server management..."
@echo "Starting SeaweedFS cluster..."
@# Use the CI-safe startup directly without aggressive cleanup
@if $(MAKE) start-seaweedfs-ci > weed-test.log 2>&1; then \
echo "✅ SeaweedFS cluster started successfully"; \
echo "Running SSE integration tests..."; \
trap '$(MAKE) -C $(TEST_DIR) stop-seaweedfs-safe || true' EXIT; \
if [ -n "$(TEST_PATTERN)" ]; then \
echo "🔍 Running tests matching pattern: $(TEST_PATTERN)"; \
cd $(SEAWEEDFS_ROOT) && go test -v -timeout=$(TEST_TIMEOUT) -run "$(TEST_PATTERN)" ./test/s3/sse || exit 1; \
else \
echo "🔍 Running all SSE integration tests"; \
cd $(SEAWEEDFS_ROOT) && go test -v -timeout=$(TEST_TIMEOUT) -run "TestSSE.*Integration" ./test/s3/sse || exit 1; \
fi; \
echo "✅ All tests completed successfully"; \
$(MAKE) -C $(TEST_DIR) stop-seaweedfs-safe || true; \
@echo "🚀 Starting SSE integration tests with auto-managed server..."
@if [ -n "$(TEST_PATTERN)" ]; then \
echo "🔍 Running tests matching pattern: $(TEST_PATTERN)"; \
go test -v -timeout=$(TEST_TIMEOUT) -run "$(TEST_PATTERN)" ./...; \
else \
echo "❌ Failed to start SeaweedFS cluster"; \
echo "=== Server startup logs ==="; \
tail -100 weed-test.log 2>/dev/null || echo "No startup log available"; \
echo "=== System information ==="; \
ps aux | grep -E "weed|make" | grep -v grep || echo "No relevant processes found"; \
exit 1; \
echo "🔍 Running all SSE integration tests"; \
go test -v -timeout=$(TEST_TIMEOUT) ./...; \
fi
@echo "✅ All tests completed successfully"
# CI-safe server startup that avoids process conflicts
start-seaweedfs-ci: check-binary

12
test/s3/tagging/Makefile

@ -208,13 +208,11 @@ test-tagging-simple: check-deps
@go test -v -timeout=$(TEST_TIMEOUT) .
@echo "✅ All tagging tests completed"
# Start server, run tests, stop server
test-with-server: start-server
@echo "Running tagging tests with managed server..."
@sleep 5 # Give server time to fully start
@make test-tagging-comprehensive || (echo "Tests failed, stopping server..." && make stop-server && exit 1)
@make stop-server
@echo "✅ All tests completed with managed server"
# Run tests with auto-managed server via TestMain
test-with-server: check-deps
@echo "Running tagging tests with auto-managed server..."
@go test -v -timeout=10m ./...
@echo "✅ All tests completed"
# Health check
health-check:

5
test/s3/versioning/Makefile

@ -1,7 +1,7 @@
# Makefile for SeaweedFS S3 API versioning tests
# Tests auto-manage server via TestMain using weed mini
.PHONY: test test-quick test-stress test-external clean check-deps build
.PHONY: test test-quick test-stress test-external test-with-server clean check-deps build
# Build SeaweedFS binary if not exists
build:
@ -34,6 +34,9 @@ test-external: check-deps
@echo "Running tests against external server (USE_EXTERNAL_SERVER=true)..."
@USE_EXTERNAL_SERVER=true go test -v -timeout=15m ./...
# Run tests with auto-managed server (alias to test for CI/CD)
test-with-server: test
# Clean up test artifacts
clean:
@echo "Cleaning up test artifacts..."

Loading…
Cancel
Save