fix: S3 copying test Makefile syntax and add S3_ENDPOINT env support (#8042)
* fix: S3 copying test Makefile syntax and add S3_ENDPOINT env support * fix: add weed mini to stop-seaweedfs target Ensure weed mini process is properly killed when stopping SeaweedFS, matching the process started in start-seaweedfs target. * Clean up PID file in stop-seaweedfs and clean targets Address review feedback to ensure /tmp/weed-mini.pid is removed for a clean state after tests.
This commit is contained in:
@@ -65,24 +65,13 @@ start-seaweedfs: check-binary
|
||||
@pkill -f "weed s3" || true
|
||||
@pkill -f "weed mini" || true
|
||||
@sleep 2
|
||||
|
||||
# Create necessary directories
|
||||
@mkdir -p /tmp/seaweedfs-test-copying
|
||||
|
||||
# Start weed mini
|
||||
@echo "Starting weed mini with dir=/tmp/seaweedfs-test-copying"
|
||||
@export AWS_ACCESS_KEY_ID=$(ACCESS_KEY) && \
|
||||
export AWS_SECRET_ACCESS_KEY=$(SECRET_KEY) && \
|
||||
# Start weed mini with S3 configuration
|
||||
@echo "Starting weed mini..."
|
||||
@nohup $(SEAWEEDFS_BINARY) mini \
|
||||
@AWS_ACCESS_KEY_ID=$(ACCESS_KEY) AWS_SECRET_ACCESS_KEY=$(SECRET_KEY) nohup $(SEAWEEDFS_BINARY) mini \
|
||||
-dir=/tmp/seaweedfs-test-copying \
|
||||
-s3.port=$(S3_PORT) \
|
||||
-s3.config=/tmp/seaweedfs-s3.json \
|
||||
-ip=127.0.0.1 \
|
||||
> /tmp/seaweedfs-mini.log 2>&1 & echo $$! > /tmp/weed-mini.pid 5
|
||||
|
||||
# Wait for S3 service to be ready
|
||||
> /tmp/seaweedfs-mini.log 2>&1 & echo $$! > /tmp/weed-mini.pid
|
||||
@echo "$(YELLOW)Waiting for S3 service to be ready...$(NC)"
|
||||
@for i in $$(seq 1 30); do \
|
||||
if curl -s -f http://127.0.0.1:$(S3_PORT) > /dev/null 2>&1; then \
|
||||
@@ -92,8 +81,6 @@ start-seaweedfs: check-binary
|
||||
echo "Waiting for S3 service... ($$i/30)"; \
|
||||
sleep 1; \
|
||||
done
|
||||
# Additional wait for filer gRPC to be ready
|
||||
@echo "$(YELLOW)Waiting for filer gRPC to be ready...$(NC)"
|
||||
@sleep 2
|
||||
@echo "$(GREEN)SeaweedFS server started successfully$(NC)"
|
||||
@echo "Mini Log: /tmp/seaweedfs-mini.log"
|
||||
@@ -105,7 +92,9 @@ stop-seaweedfs:
|
||||
@pkill -f "weed volume" || true
|
||||
@pkill -f "weed filer" || true
|
||||
@pkill -f "weed s3" || true
|
||||
@pkill -f "weed mini" || true
|
||||
@sleep 2
|
||||
@rm -f /tmp/weed-mini.pid
|
||||
@echo "$(GREEN)SeaweedFS server stopped$(NC)"
|
||||
|
||||
clean:
|
||||
@@ -113,6 +102,7 @@ clean:
|
||||
@rm -rf /tmp/seaweedfs-test-copying-*
|
||||
@rm -f /tmp/seaweedfs-*.log
|
||||
@rm -f /tmp/seaweedfs-s3.json
|
||||
@rm -f /tmp/weed-mini.pid
|
||||
@echo "$(GREEN)Cleanup completed$(NC)"
|
||||
|
||||
test-basic: check-binary
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"io"
|
||||
mathrand "math/rand"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -43,9 +44,11 @@ var defaultConfig = &S3TestConfig{
|
||||
SkipVerifySSL: true,
|
||||
}
|
||||
|
||||
// Initialize math/rand with current time to ensure randomness
|
||||
func init() {
|
||||
mathrand.Seed(time.Now().UnixNano())
|
||||
if endpoint := os.Getenv("S3_ENDPOINT"); endpoint != "" {
|
||||
defaultConfig.Endpoint = endpoint
|
||||
}
|
||||
}
|
||||
|
||||
// getS3Client creates an AWS S3 client for testing
|
||||
|
||||
Reference in New Issue
Block a user