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 s3" || true
|
||||||
@pkill -f "weed mini" || true
|
@pkill -f "weed mini" || true
|
||||||
@sleep 2
|
@sleep 2
|
||||||
|
|
||||||
# Create necessary directories
|
|
||||||
@mkdir -p /tmp/seaweedfs-test-copying
|
@mkdir -p /tmp/seaweedfs-test-copying
|
||||||
|
|
||||||
# Start weed mini
|
|
||||||
@echo "Starting weed mini with dir=/tmp/seaweedfs-test-copying"
|
@echo "Starting weed mini with dir=/tmp/seaweedfs-test-copying"
|
||||||
@export AWS_ACCESS_KEY_ID=$(ACCESS_KEY) && \
|
@AWS_ACCESS_KEY_ID=$(ACCESS_KEY) AWS_SECRET_ACCESS_KEY=$(SECRET_KEY) nohup $(SEAWEEDFS_BINARY) mini \
|
||||||
export AWS_SECRET_ACCESS_KEY=$(SECRET_KEY) && \
|
-dir=/tmp/seaweedfs-test-copying \
|
||||||
# Start weed mini with S3 configuration
|
-s3.port=$(S3_PORT) \
|
||||||
@echo "Starting weed mini..."
|
-ip=127.0.0.1 \
|
||||||
@nohup $(SEAWEEDFS_BINARY) mini \
|
> /tmp/seaweedfs-mini.log 2>&1 & echo $$! > /tmp/weed-mini.pid
|
||||||
-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
|
|
||||||
@echo "$(YELLOW)Waiting for S3 service to be ready...$(NC)"
|
@echo "$(YELLOW)Waiting for S3 service to be ready...$(NC)"
|
||||||
@for i in $$(seq 1 30); do \
|
@for i in $$(seq 1 30); do \
|
||||||
if curl -s -f http://127.0.0.1:$(S3_PORT) > /dev/null 2>&1; then \
|
if curl -s -f http://127.0.0.1:$(S3_PORT) > /dev/null 2>&1; then \
|
||||||
@@ -92,10 +81,8 @@ start-seaweedfs: check-binary
|
|||||||
echo "Waiting for S3 service... ($$i/30)"; \
|
echo "Waiting for S3 service... ($$i/30)"; \
|
||||||
sleep 1; \
|
sleep 1; \
|
||||||
done
|
done
|
||||||
# Additional wait for filer gRPC to be ready
|
@sleep 2
|
||||||
@echo "$(YELLOW)Waiting for filer gRPC to be ready...$(NC)"
|
@echo "$(GREEN)SeaweedFS server started successfully$(NC)"
|
||||||
@sleep 2
|
|
||||||
@echo "$(GREEN)SeaweedFS server started successfully$(NC)"
|
|
||||||
@echo "Mini Log: /tmp/seaweedfs-mini.log"
|
@echo "Mini Log: /tmp/seaweedfs-mini.log"
|
||||||
@echo "S3: http://localhost:$(S3_PORT)"
|
@echo "S3: http://localhost:$(S3_PORT)"
|
||||||
|
|
||||||
@@ -105,7 +92,9 @@ stop-seaweedfs:
|
|||||||
@pkill -f "weed volume" || true
|
@pkill -f "weed volume" || true
|
||||||
@pkill -f "weed filer" || true
|
@pkill -f "weed filer" || true
|
||||||
@pkill -f "weed s3" || true
|
@pkill -f "weed s3" || true
|
||||||
|
@pkill -f "weed mini" || true
|
||||||
@sleep 2
|
@sleep 2
|
||||||
|
@rm -f /tmp/weed-mini.pid
|
||||||
@echo "$(GREEN)SeaweedFS server stopped$(NC)"
|
@echo "$(GREEN)SeaweedFS server stopped$(NC)"
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@@ -113,6 +102,7 @@ clean:
|
|||||||
@rm -rf /tmp/seaweedfs-test-copying-*
|
@rm -rf /tmp/seaweedfs-test-copying-*
|
||||||
@rm -f /tmp/seaweedfs-*.log
|
@rm -f /tmp/seaweedfs-*.log
|
||||||
@rm -f /tmp/seaweedfs-s3.json
|
@rm -f /tmp/seaweedfs-s3.json
|
||||||
|
@rm -f /tmp/weed-mini.pid
|
||||||
@echo "$(GREEN)Cleanup completed$(NC)"
|
@echo "$(GREEN)Cleanup completed$(NC)"
|
||||||
|
|
||||||
test-basic: check-binary
|
test-basic: check-binary
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
mathrand "math/rand"
|
mathrand "math/rand"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@@ -43,9 +44,11 @@ var defaultConfig = &S3TestConfig{
|
|||||||
SkipVerifySSL: true,
|
SkipVerifySSL: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize math/rand with current time to ensure randomness
|
|
||||||
func init() {
|
func init() {
|
||||||
mathrand.Seed(time.Now().UnixNano())
|
mathrand.Seed(time.Now().UnixNano())
|
||||||
|
if endpoint := os.Getenv("S3_ENDPOINT"); endpoint != "" {
|
||||||
|
defaultConfig.Endpoint = endpoint
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// getS3Client creates an AWS S3 client for testing
|
// getS3Client creates an AWS S3 client for testing
|
||||||
|
|||||||
Reference in New Issue
Block a user