mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-22 07:06:51 +00:00
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
This commit is contained in:
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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"
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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) ./...
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
+8
-23
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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..."
|
||||
|
||||
Reference in New Issue
Block a user