aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2025-06-23 11:20:58 -0700
committerchrislu <chris.lu@gmail.com>2025-06-23 11:20:58 -0700
commit6a9707945488ca606598b896daeabf52e49ce4b5 (patch)
tree91fb4414286c247c79a4ec5de7ddf11672f80f4d
parent1c879148d81580fa1c0d9d25c984895a36479a73 (diff)
downloadseaweedfs-6a9707945488ca606598b896daeabf52e49ce4b5.tar.xz
seaweedfs-6a9707945488ca606598b896daeabf52e49ce4b5.zip
running
-rw-r--r--test/mq/Dockerfile.test18
-rw-r--r--test/mq/Makefile60
-rw-r--r--test/mq/README.md56
-rw-r--r--test/mq/docker-compose.cluster.yml167
-rw-r--r--test/mq/docker-compose.production.yml262
5 files changed, 547 insertions, 16 deletions
diff --git a/test/mq/Dockerfile.test b/test/mq/Dockerfile.test
index dfd6b799c..8902df6af 100644
--- a/test/mq/Dockerfile.test
+++ b/test/mq/Dockerfile.test
@@ -1,4 +1,4 @@
-FROM golang:1.21-alpine
+FROM golang:1.24-alpine
# Install necessary tools
RUN apk add --no-cache \
@@ -9,21 +9,22 @@ RUN apk add --no-cache \
build-base
# Set working directory
-WORKDIR /app
+WORKDIR /workspace
# Copy go mod files first for better caching
COPY go.mod go.sum ./
RUN go mod download
-# Copy the entire source code
-COPY . .
+# Copy only the necessary source code for building and testing
+COPY weed/ ./weed/
+COPY test/mq/integration/ ./test/mq/integration/
# Install test dependencies
RUN go install github.com/onsi/ginkgo/v2/ginkgo@latest
-RUN go install github.com/stretchr/testify@latest
+# Note: testify is a library, not a binary, so it's installed via go mod download
-# Build the weed binary for testing
-RUN go build -o weed weed/weed.go
+# Build the weed binary for testing (optional - tests can use external cluster)
+RUN cd weed && go build -o ../weed .
# Create test results directory
RUN mkdir -p /test-results
@@ -33,5 +34,8 @@ ENV CGO_ENABLED=1
ENV GOOS=linux
ENV GO111MODULE=on
+# Default working directory for tests
+WORKDIR /workspace
+
# Entry point for running tests
ENTRYPOINT ["/bin/bash"] \ No newline at end of file
diff --git a/test/mq/Makefile b/test/mq/Makefile
index 05521a91d..f2c4bbba7 100644
--- a/test/mq/Makefile
+++ b/test/mq/Makefile
@@ -1,22 +1,32 @@
-.PHONY: help test test-basic test-performance test-failover test-agent clean up down logs
+.PHONY: help build test test-basic test-performance test-failover test-agent clean up down logs
# Default target
help:
@echo "SeaweedMQ Integration Test Suite"
@echo ""
@echo "Available targets:"
+ @echo " build - Build SeaweedFS Docker images"
@echo " test - Run all integration tests"
@echo " test-basic - Run basic pub/sub tests"
@echo " test-performance - Run performance tests"
@echo " test-failover - Run failover tests"
@echo " test-agent - Run agent tests"
- @echo " up - Start test environment"
+ @echo " up - Start test environment (local build)"
+ @echo " up-prod - Start test environment (production images)"
+ @echo " up-cluster - Start cluster only (no test runner)"
@echo " down - Stop test environment"
@echo " clean - Clean up test environment and results"
@echo " logs - Show container logs"
+# Build SeaweedFS Docker images
+build:
+ @echo "Building SeaweedFS Docker image..."
+ cd ../.. && docker build -f docker/Dockerfile.go_build -t chrislusf/seaweedfs:local .
+ @echo "Building test runner image..."
+ cd ../.. && docker build -f test/mq/Dockerfile.test -t seaweedfs-test-runner .
+
# Start the test environment
-up:
+up: build
@echo "Starting SeaweedMQ test environment..."
docker-compose -f docker-compose.test.yml up -d master0 master1 master2
@echo "Waiting for masters to be ready..."
@@ -32,10 +42,54 @@ up:
sleep 20
@echo "Test environment is ready!"
+# Start the test environment with production images (no build required)
+up-prod: build-test-runner
+ @echo "Starting SeaweedMQ test environment with production images..."
+ docker-compose -f docker-compose.production.yml up -d master0 master1 master2
+ @echo "Waiting for masters to be ready..."
+ sleep 10
+ docker-compose -f docker-compose.production.yml up -d volume1 volume2 volume3
+ @echo "Waiting for volumes to be ready..."
+ sleep 10
+ docker-compose -f docker-compose.production.yml up -d filer1 filer2
+ @echo "Waiting for filers to be ready..."
+ sleep 15
+ docker-compose -f docker-compose.production.yml up -d broker1 broker2 broker3
+ @echo "Waiting for brokers to be ready..."
+ sleep 20
+ @echo "Test environment is ready!"
+
+# Build only the test runner image (for production setup)
+build-test-runner:
+ @echo "Building test runner image..."
+ cd ../.. && docker build -f test/mq/Dockerfile.test -t seaweedfs-test-runner .
+
+# Start cluster only (no test runner, no build required)
+up-cluster:
+ @echo "Starting SeaweedMQ cluster only..."
+ docker-compose -f docker-compose.cluster.yml up -d master0 master1 master2
+ @echo "Waiting for masters to be ready..."
+ sleep 10
+ docker-compose -f docker-compose.cluster.yml up -d volume1 volume2 volume3
+ @echo "Waiting for volumes to be ready..."
+ sleep 10
+ docker-compose -f docker-compose.cluster.yml up -d filer1 filer2
+ @echo "Waiting for filers to be ready..."
+ sleep 15
+ docker-compose -f docker-compose.cluster.yml up -d broker1 broker2 broker3
+ @echo "Waiting for brokers to be ready..."
+ sleep 20
+ @echo "SeaweedMQ cluster is ready!"
+ @echo "Masters: http://localhost:19333, http://localhost:19334, http://localhost:19335"
+ @echo "Filers: http://localhost:18888, http://localhost:18889"
+ @echo "Brokers: localhost:17777, localhost:17778, localhost:17779"
+
# Stop the test environment
down:
@echo "Stopping SeaweedMQ test environment..."
docker-compose -f docker-compose.test.yml down
+ docker-compose -f docker-compose.production.yml down
+ docker-compose -f docker-compose.cluster.yml down
# Clean up everything
clean:
diff --git a/test/mq/README.md b/test/mq/README.md
index b84f624d3..6f3f7e5fd 100644
--- a/test/mq/README.md
+++ b/test/mq/README.md
@@ -43,31 +43,75 @@ The test environment consists of:
### Basic Usage
+Choose one of three approaches:
+
+#### Option 1: Quick Cluster Setup (Fastest)
+Just starts a SeaweedMQ cluster - no test runner, no build required.
+
+1. **Start Cluster**:
+ ```bash
+ cd test/mq
+ make up-cluster
+ ```
+
+2. **Test manually** or with your own code against:
+ - Masters: http://localhost:19333, http://localhost:19334, http://localhost:19335
+ - Brokers: localhost:17777, localhost:17778, localhost:17779
+ - Filers: http://localhost:18888, http://localhost:18889
+
+#### Option 2: Use Production Images (Recommended for testing)
+Uses official SeaweedFS images from Docker Hub with test runner.
+
1. **Start Test Environment**:
```bash
cd test/mq
- make up
+ make up-prod
```
-2. **Run All Tests**:
+2. **Run Tests**:
```bash
- make test
+ make test-basic # Basic pub/sub tests
```
-3. **Run Specific Test Categories**:
+#### Option 3: Build from Source (Development)
+Builds SeaweedFS from your local source code to test latest changes.
+
+1. **Start Test Environment**:
+ ```bash
+ cd test/mq
+ make up # This will build and start
+ ```
+
+2. **Run Tests**:
```bash
make test-basic # Basic pub/sub tests
+ ```
+
+#### Common Commands
+
+3. **Run All Tests**:
+ ```bash
+ make test
+ ```
+
+4. **Run Specific Test Categories**:
+ ```bash
make test-performance # Performance tests
make test-failover # Failover tests
make test-agent # Agent tests
```
-4. **Quick Smoke Test**:
+5. **Quick Smoke Test**:
```bash
make smoke-test
```
-5. **Clean Up**:
+6. **Check Health**:
+ ```bash
+ make health
+ ```
+
+7. **Clean Up**:
```bash
make down
```
diff --git a/test/mq/docker-compose.cluster.yml b/test/mq/docker-compose.cluster.yml
new file mode 100644
index 000000000..4fdf55465
--- /dev/null
+++ b/test/mq/docker-compose.cluster.yml
@@ -0,0 +1,167 @@
+version: '3.8'
+
+services:
+ # Masters
+ master0:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "19333:9333"
+ volumes:
+ - /tmp/seaweedfs-test/master0:/data
+ command: "master -port=9333 -mdir=/data -peers=master0:9333,master1:9334,master2:9335 -ip=master0 -defaultReplication=001"
+ networks:
+ - seaweedfs-test
+ healthcheck:
+ test: ["CMD", "curl", "-f", "http://localhost:9333/cluster/status"]
+ interval: 30s
+ timeout: 10s
+ retries: 5
+ start_period: 30s
+
+ master1:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "19334:9334"
+ volumes:
+ - /tmp/seaweedfs-test/master1:/data
+ command: "master -port=9334 -mdir=/data -peers=master0:9333,master1:9334,master2:9335 -ip=master1 -defaultReplication=001"
+ networks:
+ - seaweedfs-test
+ healthcheck:
+ test: ["CMD", "curl", "-f", "http://localhost:9334/cluster/status"]
+ interval: 30s
+ timeout: 10s
+ retries: 5
+ start_period: 30s
+
+ master2:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "19335:9335"
+ volumes:
+ - /tmp/seaweedfs-test/master2:/data
+ command: "master -port=9335 -mdir=/data -peers=master0:9333,master1:9334,master2:9335 -ip=master2 -defaultReplication=001"
+ networks:
+ - seaweedfs-test
+ healthcheck:
+ test: ["CMD", "curl", "-f", "http://localhost:9335/cluster/status"]
+ interval: 30s
+ timeout: 10s
+ retries: 5
+ start_period: 30s
+
+ # Volume Servers
+ volume1:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "18080:8080"
+ volumes:
+ - /tmp/seaweedfs-test/volume1:/data
+ command: "volume -port=8080 -mserver=master0:9333,master1:9334,master2:9335 -dir=/data"
+ depends_on:
+ - master0
+ - master1
+ - master2
+ networks:
+ - seaweedfs-test
+
+ volume2:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "18081:8081"
+ volumes:
+ - /tmp/seaweedfs-test/volume2:/data
+ command: "volume -port=8081 -mserver=master0:9333,master1:9334,master2:9335 -dir=/data"
+ depends_on:
+ - master0
+ - master1
+ - master2
+ networks:
+ - seaweedfs-test
+
+ volume3:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "18082:8082"
+ volumes:
+ - /tmp/seaweedfs-test/volume3:/data
+ command: "volume -port=8082 -mserver=master0:9333,master1:9334,master2:9335 -dir=/data"
+ depends_on:
+ - master0
+ - master1
+ - master2
+ networks:
+ - seaweedfs-test
+
+ # Filers
+ filer1:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "18888:8888"
+ volumes:
+ - /tmp/seaweedfs-test/filer1:/data
+ command: "filer -port=8888 -master=master0:9333,master1:9334,master2:9335"
+ depends_on:
+ - volume1
+ - volume2
+ - volume3
+ networks:
+ - seaweedfs-test
+
+ filer2:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "18889:8889"
+ volumes:
+ - /tmp/seaweedfs-test/filer2:/data
+ command: "filer -port=8889 -master=master0:9333,master1:9334,master2:9335"
+ depends_on:
+ - volume1
+ - volume2
+ - volume3
+ networks:
+ - seaweedfs-test
+
+ # Message Queue Brokers
+ broker1:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "17777:17777"
+ volumes:
+ - /tmp/seaweedfs-test/broker1:/data
+ command: "mq.broker -port=17777 -master=master0:9333,master1:9334,master2:9335"
+ depends_on:
+ - filer1
+ - filer2
+ networks:
+ - seaweedfs-test
+
+ broker2:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "17778:17778"
+ volumes:
+ - /tmp/seaweedfs-test/broker2:/data
+ command: "mq.broker -port=17778 -master=master0:9333,master1:9334,master2:9335"
+ depends_on:
+ - filer1
+ - filer2
+ networks:
+ - seaweedfs-test
+
+ broker3:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "17779:17779"
+ volumes:
+ - /tmp/seaweedfs-test/broker3:/data
+ command: "mq.broker -port=17779 -master=master0:9333,master1:9334,master2:9335"
+ depends_on:
+ - filer1
+ - filer2
+ networks:
+ - seaweedfs-test
+
+networks:
+ seaweedfs-test:
+ driver: bridge \ No newline at end of file
diff --git a/test/mq/docker-compose.production.yml b/test/mq/docker-compose.production.yml
new file mode 100644
index 000000000..e0e9e6c4d
--- /dev/null
+++ b/test/mq/docker-compose.production.yml
@@ -0,0 +1,262 @@
+version: '3.8'
+
+services:
+ # Masters
+ master0:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "19333:19333"
+ - "9333:9333"
+ volumes:
+ - /tmp/seaweedfs-test/master0:/data
+ command: "master -port=9333 -mdir=/data -peers=master0:9333,master1:9334,master2:9335 -defaultReplication=001"
+ environment:
+ WEED_MASTER_VOLUME_GROWTH_COPY_1: 7
+ WEED_MASTER_VOLUME_GROWTH_COPY_2: 6
+ WEED_MASTER_VOLUME_GROWTH_COPY_OTHER: 3
+ networks:
+ - seaweedfs-test
+ healthcheck:
+ test: ["CMD", "curl", "-f", "http://localhost:9333/cluster/status"]
+ interval: 10s
+ timeout: 5s
+ retries: 3
+
+ master1:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "19334:9334"
+ - "9334:9334"
+ volumes:
+ - /tmp/seaweedfs-test/master1:/data
+ command: "master -port=9334 -mdir=/data -peers=master0:9333,master1:9334,master2:9335 -defaultReplication=001"
+ environment:
+ WEED_MASTER_VOLUME_GROWTH_COPY_1: 7
+ WEED_MASTER_VOLUME_GROWTH_COPY_2: 6
+ WEED_MASTER_VOLUME_GROWTH_COPY_OTHER: 3
+ networks:
+ - seaweedfs-test
+ healthcheck:
+ test: ["CMD", "curl", "-f", "http://localhost:9334/cluster/status"]
+ interval: 10s
+ timeout: 5s
+ retries: 3
+
+ master2:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "19335:9335"
+ - "9335:9335"
+ volumes:
+ - /tmp/seaweedfs-test/master2:/data
+ command: "master -port=9335 -mdir=/data -peers=master0:9333,master1:9334,master2:9335 -defaultReplication=001"
+ environment:
+ WEED_MASTER_VOLUME_GROWTH_COPY_1: 7
+ WEED_MASTER_VOLUME_GROWTH_COPY_2: 6
+ WEED_MASTER_VOLUME_GROWTH_COPY_OTHER: 3
+ networks:
+ - seaweedfs-test
+ healthcheck:
+ test: ["CMD", "curl", "-f", "http://localhost:9335/cluster/status"]
+ interval: 10s
+ timeout: 5s
+ retries: 3
+
+ # Volume Servers
+ volume1:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "18080:8080"
+ - "8080:8080"
+ volumes:
+ - /tmp/seaweedfs-test/volume1:/data
+ command: "volume -port=8080 -mserver=master0:9333,master1:9334,master2:9335 -dir=/data"
+ depends_on:
+ master0:
+ condition: service_healthy
+ master1:
+ condition: service_healthy
+ master2:
+ condition: service_healthy
+ networks:
+ - seaweedfs-test
+ environment:
+ WEED_VOLUME_MAX: 100
+
+ volume2:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "18081:8081"
+ - "8081:8081"
+ volumes:
+ - /tmp/seaweedfs-test/volume2:/data
+ command: "volume -port=8081 -mserver=master0:9333,master1:9334,master2:9335 -dir=/data"
+ depends_on:
+ master0:
+ condition: service_healthy
+ master1:
+ condition: service_healthy
+ master2:
+ condition: service_healthy
+ networks:
+ - seaweedfs-test
+ environment:
+ WEED_VOLUME_MAX: 100
+
+ volume3:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "18082:8082"
+ - "8082:8082"
+ volumes:
+ - /tmp/seaweedfs-test/volume3:/data
+ command: "volume -port=8082 -mserver=master0:9333,master1:9334,master2:9335 -dir=/data"
+ depends_on:
+ master0:
+ condition: service_healthy
+ master1:
+ condition: service_healthy
+ master2:
+ condition: service_healthy
+ networks:
+ - seaweedfs-test
+ environment:
+ WEED_VOLUME_MAX: 100
+
+ # Filers
+ filer1:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "18888:8888"
+ - "8888:8888"
+ volumes:
+ - /tmp/seaweedfs-test/filer1:/data
+ command: "filer -port=8888 -master=master0:9333,master1:9334,master2:9335"
+ depends_on:
+ - volume1
+ - volume2
+ - volume3
+ networks:
+ - seaweedfs-test
+ environment:
+ WEED_LEVELDB2_DIR: "/data/filerldb2"
+
+ filer2:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "18889:8889"
+ - "8889:8889"
+ volumes:
+ - /tmp/seaweedfs-test/filer2:/data
+ command: "filer -port=8889 -master=master0:9333,master1:9334,master2:9335"
+ depends_on:
+ - volume1
+ - volume2
+ - volume3
+ networks:
+ - seaweedfs-test
+ environment:
+ WEED_LEVELDB2_DIR: "/data/filerldb2"
+
+ # Message Queue Brokers
+ broker1:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "17777:17777"
+ volumes:
+ - /tmp/seaweedfs-test/broker1:/data
+ command: "mq.broker -port=17777 -filer=filer1:8888,filer2:8889"
+ depends_on:
+ - filer1
+ - filer2
+ networks:
+ - seaweedfs-test
+ environment:
+ WEED_MQ_BROKER_CPU_PERCENT: 80
+
+ broker2:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "17778:17778"
+ volumes:
+ - /tmp/seaweedfs-test/broker2:/data
+ command: "mq.broker -port=17778 -filer=filer1:8888,filer2:8889"
+ depends_on:
+ - filer1
+ - filer2
+ networks:
+ - seaweedfs-test
+ environment:
+ WEED_MQ_BROKER_CPU_PERCENT: 80
+
+ broker3:
+ image: chrislusf/seaweedfs:latest
+ ports:
+ - "17779:17779"
+ volumes:
+ - /tmp/seaweedfs-test/broker3:/data
+ command: "mq.broker -port=17779 -filer=filer1:8888,filer2:8889"
+ depends_on:
+ - filer1
+ - filer2
+ networks:
+ - seaweedfs-test
+ environment:
+ WEED_MQ_BROKER_CPU_PERCENT: 80
+
+ # Test Runner
+ test-runner:
+ image: seaweedfs-test-runner
+ volumes:
+ - ../..:/workspace
+ - /tmp/test-results:/test-results
+ working_dir: /workspace
+ networks:
+ - seaweedfs-test
+ environment:
+ - SEAWEED_MASTERS=master0:9333,master1:9334,master2:9335
+ - SEAWEED_BROKERS=broker1:17777,broker2:17778,broker3:17779
+ - SEAWEED_FILERS=filer1:8888,filer2:8889
+ - GO111MODULE=on
+ - CGO_ENABLED=0
+ depends_on:
+ - broker1
+ - broker2
+ - broker3
+
+ # Monitoring
+ prometheus:
+ image: prom/prometheus:latest
+ ports:
+ - "19090:9090"
+ volumes:
+ - ./prometheus.yml:/etc/prometheus/prometheus.yml
+ networks:
+ - seaweedfs-test
+ depends_on:
+ - master0
+ - master1
+ - master2
+ - volume1
+ - volume2
+ - volume3
+ - filer1
+ - filer2
+ - broker1
+ - broker2
+ - broker3
+
+ grafana:
+ image: grafana/grafana:latest
+ ports:
+ - "13000:3000"
+ environment:
+ - GF_SECURITY_ADMIN_PASSWORD=admin
+ networks:
+ - seaweedfs-test
+ depends_on:
+ - prometheus
+
+networks:
+ seaweedfs-test:
+ driver: bridge \ No newline at end of file