diff options
Diffstat (limited to 'seaweedfs-rdma-sidecar/tests')
| -rwxr-xr-x | seaweedfs-rdma-sidecar/tests/docker-smoke-test.sh | 39 | ||||
| -rwxr-xr-x | seaweedfs-rdma-sidecar/tests/docker-test-helper.sh | 154 | ||||
| -rwxr-xr-x | seaweedfs-rdma-sidecar/tests/run-integration-tests.sh | 302 |
3 files changed, 495 insertions, 0 deletions
diff --git a/seaweedfs-rdma-sidecar/tests/docker-smoke-test.sh b/seaweedfs-rdma-sidecar/tests/docker-smoke-test.sh new file mode 100755 index 000000000..b7ad813c1 --- /dev/null +++ b/seaweedfs-rdma-sidecar/tests/docker-smoke-test.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# Simple smoke test for Docker setup +set -e + +echo "๐งช Docker Smoke Test" +echo "====================" +echo "" + +echo "๐ 1. Testing Docker Compose configuration..." +docker-compose config --quiet +echo "โ
Docker Compose configuration is valid" +echo "" + +echo "๐ 2. Testing container builds..." +echo "Building RDMA engine container..." +docker build -f Dockerfile.rdma-engine -t test-rdma-engine . > /dev/null +echo "โ
RDMA engine container builds successfully" +echo "" + +echo "๐ 3. Testing basic container startup..." +echo "Starting RDMA engine container..." +container_id=$(docker run --rm -d --name test-rdma-engine test-rdma-engine) +sleep 5 + +if docker ps | grep test-rdma-engine > /dev/null; then + echo "โ
RDMA engine container starts successfully" + docker stop test-rdma-engine > /dev/null +else + echo "โ RDMA engine container failed to start" + echo "Checking container logs:" + docker logs test-rdma-engine 2>&1 || true + docker stop test-rdma-engine > /dev/null 2>&1 || true + exit 1 +fi +echo "" + +echo "๐ All smoke tests passed!" +echo "Docker setup is working correctly." diff --git a/seaweedfs-rdma-sidecar/tests/docker-test-helper.sh b/seaweedfs-rdma-sidecar/tests/docker-test-helper.sh new file mode 100755 index 000000000..edb95541e --- /dev/null +++ b/seaweedfs-rdma-sidecar/tests/docker-test-helper.sh @@ -0,0 +1,154 @@ +#!/bin/bash + +# Docker Test Helper - Simplified commands for running integration tests + +set -e + +# Colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' + +print_usage() { + echo -e "${BLUE}SeaweedFS RDMA Docker Integration Test Helper${NC}" + echo "" + echo "Usage: $0 [command]" + echo "" + echo "Commands:" + echo " start - Start all services" + echo " test - Run integration tests" + echo " stop - Stop all services" + echo " clean - Stop services and clean up volumes" + echo " logs - Show logs from all services" + echo " status - Show status of all services" + echo " shell - Open shell in test client container" + echo "" + echo "Examples:" + echo " $0 start # Start all services" + echo " $0 test # Run full integration test suite" + echo " $0 logs rdma-engine # Show logs from RDMA engine" + echo " $0 shell # Interactive testing shell" +} + +start_services() { + echo -e "${GREEN}๐ Starting SeaweedFS RDMA integration services...${NC}" + docker-compose up -d seaweedfs-master seaweedfs-volume rdma-engine rdma-sidecar + + echo -e "${YELLOW}โณ Waiting for services to be ready...${NC}" + sleep 10 + + echo -e "${GREEN}โ
Services started. Checking health...${NC}" + docker-compose ps +} + +run_tests() { + echo -e "${GREEN}๐งช Running integration tests...${NC}" + + # Make sure services are running + docker-compose up -d seaweedfs-master seaweedfs-volume rdma-engine rdma-sidecar + + # Wait for services to be ready + echo -e "${YELLOW}โณ Waiting for services to be ready...${NC}" + sleep 15 + + # Run the integration tests + docker-compose run --rm integration-tests +} + +stop_services() { + echo -e "${YELLOW}๐ Stopping services...${NC}" + docker-compose down + echo -e "${GREEN}โ
Services stopped${NC}" +} + +clean_all() { + echo -e "${YELLOW}๐งน Cleaning up services and volumes...${NC}" + docker-compose down -v --remove-orphans + echo -e "${GREEN}โ
Cleanup complete${NC}" +} + +show_logs() { + local service=${1:-} + if [ -n "$service" ]; then + echo -e "${BLUE}๐ Showing logs for $service...${NC}" + docker-compose logs -f "$service" + else + echo -e "${BLUE}๐ Showing logs for all services...${NC}" + docker-compose logs -f + fi +} + +show_status() { + echo -e "${BLUE}๐ Service Status:${NC}" + docker-compose ps + + echo -e "\n${BLUE}๐ก Health Checks:${NC}" + + # Check SeaweedFS Master + if curl -s http://localhost:9333/cluster/status >/dev/null 2>&1; then + echo -e " ${GREEN}โ
SeaweedFS Master: Healthy${NC}" + else + echo -e " ${RED}โ SeaweedFS Master: Unhealthy${NC}" + fi + + # Check SeaweedFS Volume + if curl -s http://localhost:8080/status >/dev/null 2>&1; then + echo -e " ${GREEN}โ
SeaweedFS Volume: Healthy${NC}" + else + echo -e " ${RED}โ SeaweedFS Volume: Unhealthy${NC}" + fi + + # Check RDMA Sidecar + if curl -s http://localhost:8081/health >/dev/null 2>&1; then + echo -e " ${GREEN}โ
RDMA Sidecar: Healthy${NC}" + else + echo -e " ${RED}โ RDMA Sidecar: Unhealthy${NC}" + fi +} + +open_shell() { + echo -e "${GREEN}๐ Opening interactive shell in test client...${NC}" + echo -e "${YELLOW}Use './test-rdma --help' for RDMA testing commands${NC}" + echo -e "${YELLOW}Use 'curl http://rdma-sidecar:8081/health' to test sidecar${NC}" + + docker-compose run --rm test-client /bin/bash +} + +# Main command handling +case "${1:-}" in + start) + start_services + ;; + test) + run_tests + ;; + stop) + stop_services + ;; + clean) + clean_all + ;; + logs) + show_logs "${2:-}" + ;; + status) + show_status + ;; + shell) + open_shell + ;; + -h|--help|help) + print_usage + ;; + "") + print_usage + exit 1 + ;; + *) + echo -e "${RED}โ Unknown command: $1${NC}" + print_usage + exit 1 + ;; +esac diff --git a/seaweedfs-rdma-sidecar/tests/run-integration-tests.sh b/seaweedfs-rdma-sidecar/tests/run-integration-tests.sh new file mode 100755 index 000000000..8f23c7e5f --- /dev/null +++ b/seaweedfs-rdma-sidecar/tests/run-integration-tests.sh @@ -0,0 +1,302 @@ +#!/bin/bash + +# SeaweedFS RDMA Integration Test Suite +# Comprehensive testing of the complete integration in Docker environment + +set -e + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +PURPLE='\033[0;35m' +CYAN='\033[0;36m' +NC='\033[0m' # No Color + +print_header() { + echo -e "\n${PURPLE}===============================================${NC}" + echo -e "${PURPLE}$1${NC}" + echo -e "${PURPLE}===============================================${NC}\n" +} + +print_step() { + echo -e "${CYAN}๐ต $1${NC}" +} + +print_success() { + echo -e "${GREEN}โ
$1${NC}" +} + +print_warning() { + echo -e "${YELLOW}โ ๏ธ $1${NC}" +} + +print_error() { + echo -e "${RED}โ $1${NC}" +} + +wait_for_service() { + local url=$1 + local service_name=$2 + local max_attempts=30 + local attempt=1 + + print_step "Waiting for $service_name to be ready..." + + while [ $attempt -le $max_attempts ]; do + if curl -s "$url" > /dev/null 2>&1; then + print_success "$service_name is ready" + return 0 + fi + + echo -n "." + sleep 2 + attempt=$((attempt + 1)) + done + + print_error "$service_name failed to become ready after $max_attempts attempts" + return 1 +} + +test_seaweedfs_master() { + print_header "TESTING SEAWEEDFS MASTER" + + wait_for_service "$SEAWEEDFS_MASTER/cluster/status" "SeaweedFS Master" + + print_step "Checking master status..." + response=$(curl -s "$SEAWEEDFS_MASTER/cluster/status") + + if echo "$response" | jq -e '.IsLeader == true' > /dev/null; then + print_success "SeaweedFS Master is leader and ready" + else + print_error "SeaweedFS Master is not ready" + echo "$response" + return 1 + fi +} + +test_seaweedfs_volume() { + print_header "TESTING SEAWEEDFS VOLUME SERVER" + + wait_for_service "$SEAWEEDFS_VOLUME/status" "SeaweedFS Volume Server" + + print_step "Checking volume server status..." + response=$(curl -s "$SEAWEEDFS_VOLUME/status") + + if echo "$response" | jq -e '.Version' > /dev/null; then + print_success "SeaweedFS Volume Server is ready" + echo "Volume Server Version: $(echo "$response" | jq -r '.Version')" + else + print_error "SeaweedFS Volume Server is not ready" + echo "$response" + return 1 + fi +} + +test_rdma_engine() { + print_header "TESTING RDMA ENGINE" + + print_step "Checking RDMA engine socket..." + if [ -S "$RDMA_SOCKET_PATH" ]; then + print_success "RDMA engine socket exists" + else + print_error "RDMA engine socket not found at $RDMA_SOCKET_PATH" + return 1 + fi + + print_step "Testing RDMA engine ping..." + if ./test-rdma ping --socket "$RDMA_SOCKET_PATH" 2>/dev/null; then + print_success "RDMA engine ping successful" + else + print_error "RDMA engine ping failed" + return 1 + fi + + print_step "Testing RDMA engine capabilities..." + if ./test-rdma capabilities --socket "$RDMA_SOCKET_PATH" 2>/dev/null | grep -q "Version:"; then + print_success "RDMA engine capabilities retrieved" + ./test-rdma capabilities --socket "$RDMA_SOCKET_PATH" 2>/dev/null | head -5 + else + print_error "RDMA engine capabilities failed" + return 1 + fi +} + +test_rdma_sidecar() { + print_header "TESTING RDMA SIDECAR" + + wait_for_service "$SIDECAR_URL/health" "RDMA Sidecar" + + print_step "Testing sidecar health..." + response=$(curl -s "$SIDECAR_URL/health") + + if echo "$response" | jq -e '.status == "healthy"' > /dev/null; then + print_success "RDMA Sidecar is healthy" + echo "RDMA Status: $(echo "$response" | jq -r '.rdma.enabled')" + else + print_error "RDMA Sidecar health check failed" + echo "$response" + return 1 + fi + + print_step "Testing sidecar stats..." + stats=$(curl -s "$SIDECAR_URL/stats") + + if echo "$stats" | jq -e '.enabled' > /dev/null; then + print_success "RDMA Sidecar stats retrieved" + echo "RDMA Enabled: $(echo "$stats" | jq -r '.enabled')" + echo "RDMA Connected: $(echo "$stats" | jq -r '.connected')" + + if echo "$stats" | jq -e '.capabilities' > /dev/null; then + version=$(echo "$stats" | jq -r '.capabilities.version') + sessions=$(echo "$stats" | jq -r '.capabilities.max_sessions') + print_success "RDMA Engine Info: Version=$version, Max Sessions=$sessions" + fi + else + print_error "RDMA Sidecar stats failed" + echo "$stats" + return 1 + fi +} + +test_direct_rdma_operations() { + print_header "TESTING DIRECT RDMA OPERATIONS" + + print_step "Testing direct RDMA read operation..." + if ./test-rdma read --socket "$RDMA_SOCKET_PATH" --volume 1 --needle 12345 --size 1024 2>/dev/null | grep -q "RDMA read completed"; then + print_success "Direct RDMA read operation successful" + else + print_warning "Direct RDMA read operation failed (expected in mock mode)" + fi + + print_step "Running RDMA performance benchmark..." + benchmark_result=$(./test-rdma bench --socket "$RDMA_SOCKET_PATH" --iterations 5 --read-size 2048 2>/dev/null | tail -10) + + if echo "$benchmark_result" | grep -q "Operations/sec:"; then + print_success "RDMA benchmark completed" + echo "$benchmark_result" | grep -E "Operations|Latency|Throughput" + else + print_warning "RDMA benchmark had issues (expected in mock mode)" + fi +} + +test_sidecar_needle_operations() { + print_header "TESTING SIDECAR NEEDLE OPERATIONS" + + print_step "Testing needle read via sidecar..." + response=$(curl -s "$SIDECAR_URL/read?volume=1&needle=12345&cookie=305419896&size=1024") + + if echo "$response" | jq -e '.success == true' > /dev/null; then + print_success "Sidecar needle read successful" + + is_rdma=$(echo "$response" | jq -r '.is_rdma') + source=$(echo "$response" | jq -r '.source') + duration=$(echo "$response" | jq -r '.duration') + + if [ "$is_rdma" = "true" ]; then + print_success "RDMA fast path used! Duration: $duration" + else + print_warning "HTTP fallback used. Duration: $duration" + fi + + echo "Response details:" + echo "$response" | jq '{success, is_rdma, source, duration, data_size}' + else + print_error "Sidecar needle read failed" + echo "$response" + return 1 + fi +} + +test_sidecar_benchmark() { + print_header "TESTING SIDECAR BENCHMARK" + + print_step "Running sidecar performance benchmark..." + response=$(curl -s "$SIDECAR_URL/benchmark?iterations=5&size=2048") + + if echo "$response" | jq -e '.benchmark_results' > /dev/null; then + print_success "Sidecar benchmark completed" + + rdma_ops=$(echo "$response" | jq -r '.benchmark_results.rdma_ops') + http_ops=$(echo "$response" | jq -r '.benchmark_results.http_ops') + avg_latency=$(echo "$response" | jq -r '.benchmark_results.avg_latency') + ops_per_sec=$(echo "$response" | jq -r '.benchmark_results.ops_per_sec') + + echo "Benchmark Results:" + echo " RDMA Operations: $rdma_ops" + echo " HTTP Operations: $http_ops" + echo " Average Latency: $avg_latency" + echo " Operations/sec: $ops_per_sec" + else + print_error "Sidecar benchmark failed" + echo "$response" + return 1 + fi +} + +test_error_handling() { + print_header "TESTING ERROR HANDLING AND FALLBACK" + + print_step "Testing invalid needle read..." + response=$(curl -s "$SIDECAR_URL/read?volume=999&needle=999999&size=1024") + + # Should succeed with mock data or fail gracefully + if echo "$response" | jq -e '.success' > /dev/null; then + result=$(echo "$response" | jq -r '.success') + if [ "$result" = "true" ]; then + print_success "Error handling working - mock data returned" + else + print_success "Error handling working - graceful failure" + fi + else + print_success "Error handling working - proper error response" + fi +} + +main() { + print_header "๐ SEAWEEDFS RDMA INTEGRATION TEST SUITE" + + echo -e "${GREEN}Starting comprehensive integration tests...${NC}" + echo -e "${BLUE}Environment:${NC}" + echo -e " RDMA Socket: $RDMA_SOCKET_PATH" + echo -e " Sidecar URL: $SIDECAR_URL" + echo -e " SeaweedFS Master: $SEAWEEDFS_MASTER" + echo -e " SeaweedFS Volume: $SEAWEEDFS_VOLUME" + + # Run tests in sequence + test_seaweedfs_master + test_seaweedfs_volume + test_rdma_engine + test_rdma_sidecar + test_direct_rdma_operations + test_sidecar_needle_operations + test_sidecar_benchmark + test_error_handling + + print_header "๐ ALL INTEGRATION TESTS COMPLETED!" + + echo -e "${GREEN}โ
Test Summary:${NC}" + echo -e " โ
SeaweedFS Master: Working" + echo -e " โ
SeaweedFS Volume Server: Working" + echo -e " โ
Rust RDMA Engine: Working (Mock Mode)" + echo -e " โ
Go RDMA Sidecar: Working" + echo -e " โ
IPC Communication: Working" + echo -e " โ
Needle Operations: Working" + echo -e " โ
Performance Benchmarking: Working" + echo -e " โ
Error Handling: Working" + + print_success "SeaweedFS RDMA integration is fully functional!" + + return 0 +} + +# Check required environment variables +if [ -z "$RDMA_SOCKET_PATH" ] || [ -z "$SIDECAR_URL" ] || [ -z "$SEAWEEDFS_MASTER" ] || [ -z "$SEAWEEDFS_VOLUME" ]; then + print_error "Required environment variables not set" + echo "Required: RDMA_SOCKET_PATH, SIDECAR_URL, SEAWEEDFS_MASTER, SEAWEEDFS_VOLUME" + exit 1 +fi + +# Run main test suite +main "$@" |
