run-integration-tests.sh 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. #!/bin/bash
  2. # SeaweedFS RDMA Integration Test Suite
  3. # Comprehensive testing of the complete integration in Docker environment
  4. set -e
  5. # Colors for output
  6. RED='\033[0;31m'
  7. GREEN='\033[0;32m'
  8. YELLOW='\033[1;33m'
  9. BLUE='\033[0;34m'
  10. PURPLE='\033[0;35m'
  11. CYAN='\033[0;36m'
  12. NC='\033[0m' # No Color
  13. print_header() {
  14. echo -e "\n${PURPLE}===============================================${NC}"
  15. echo -e "${PURPLE}$1${NC}"
  16. echo -e "${PURPLE}===============================================${NC}\n"
  17. }
  18. print_step() {
  19. echo -e "${CYAN}🔵 $1${NC}"
  20. }
  21. print_success() {
  22. echo -e "${GREEN}✅ $1${NC}"
  23. }
  24. print_warning() {
  25. echo -e "${YELLOW}⚠️ $1${NC}"
  26. }
  27. print_error() {
  28. echo -e "${RED}❌ $1${NC}"
  29. }
  30. wait_for_service() {
  31. local url=$1
  32. local service_name=$2
  33. local max_attempts=30
  34. local attempt=1
  35. print_step "Waiting for $service_name to be ready..."
  36. while [ $attempt -le $max_attempts ]; do
  37. if curl -s "$url" > /dev/null 2>&1; then
  38. print_success "$service_name is ready"
  39. return 0
  40. fi
  41. echo -n "."
  42. sleep 2
  43. attempt=$((attempt + 1))
  44. done
  45. print_error "$service_name failed to become ready after $max_attempts attempts"
  46. return 1
  47. }
  48. test_seaweedfs_master() {
  49. print_header "TESTING SEAWEEDFS MASTER"
  50. wait_for_service "$SEAWEEDFS_MASTER/cluster/status" "SeaweedFS Master"
  51. print_step "Checking master status..."
  52. response=$(curl -s "$SEAWEEDFS_MASTER/cluster/status")
  53. if echo "$response" | jq -e '.IsLeader == true' > /dev/null; then
  54. print_success "SeaweedFS Master is leader and ready"
  55. else
  56. print_error "SeaweedFS Master is not ready"
  57. echo "$response"
  58. return 1
  59. fi
  60. }
  61. test_seaweedfs_volume() {
  62. print_header "TESTING SEAWEEDFS VOLUME SERVER"
  63. wait_for_service "$SEAWEEDFS_VOLUME/status" "SeaweedFS Volume Server"
  64. print_step "Checking volume server status..."
  65. response=$(curl -s "$SEAWEEDFS_VOLUME/status")
  66. if echo "$response" | jq -e '.Version' > /dev/null; then
  67. print_success "SeaweedFS Volume Server is ready"
  68. echo "Volume Server Version: $(echo "$response" | jq -r '.Version')"
  69. else
  70. print_error "SeaweedFS Volume Server is not ready"
  71. echo "$response"
  72. return 1
  73. fi
  74. }
  75. test_rdma_engine() {
  76. print_header "TESTING RDMA ENGINE"
  77. print_step "Checking RDMA engine socket..."
  78. if [ -S "$RDMA_SOCKET_PATH" ]; then
  79. print_success "RDMA engine socket exists"
  80. else
  81. print_error "RDMA engine socket not found at $RDMA_SOCKET_PATH"
  82. return 1
  83. fi
  84. print_step "Testing RDMA engine ping..."
  85. if ./test-rdma ping --socket "$RDMA_SOCKET_PATH" 2>/dev/null; then
  86. print_success "RDMA engine ping successful"
  87. else
  88. print_error "RDMA engine ping failed"
  89. return 1
  90. fi
  91. print_step "Testing RDMA engine capabilities..."
  92. if ./test-rdma capabilities --socket "$RDMA_SOCKET_PATH" 2>/dev/null | grep -q "Version:"; then
  93. print_success "RDMA engine capabilities retrieved"
  94. ./test-rdma capabilities --socket "$RDMA_SOCKET_PATH" 2>/dev/null | head -5
  95. else
  96. print_error "RDMA engine capabilities failed"
  97. return 1
  98. fi
  99. }
  100. test_rdma_sidecar() {
  101. print_header "TESTING RDMA SIDECAR"
  102. wait_for_service "$SIDECAR_URL/health" "RDMA Sidecar"
  103. print_step "Testing sidecar health..."
  104. response=$(curl -s "$SIDECAR_URL/health")
  105. if echo "$response" | jq -e '.status == "healthy"' > /dev/null; then
  106. print_success "RDMA Sidecar is healthy"
  107. echo "RDMA Status: $(echo "$response" | jq -r '.rdma.enabled')"
  108. else
  109. print_error "RDMA Sidecar health check failed"
  110. echo "$response"
  111. return 1
  112. fi
  113. print_step "Testing sidecar stats..."
  114. stats=$(curl -s "$SIDECAR_URL/stats")
  115. if echo "$stats" | jq -e '.enabled' > /dev/null; then
  116. print_success "RDMA Sidecar stats retrieved"
  117. echo "RDMA Enabled: $(echo "$stats" | jq -r '.enabled')"
  118. echo "RDMA Connected: $(echo "$stats" | jq -r '.connected')"
  119. if echo "$stats" | jq -e '.capabilities' > /dev/null; then
  120. version=$(echo "$stats" | jq -r '.capabilities.version')
  121. sessions=$(echo "$stats" | jq -r '.capabilities.max_sessions')
  122. print_success "RDMA Engine Info: Version=$version, Max Sessions=$sessions"
  123. fi
  124. else
  125. print_error "RDMA Sidecar stats failed"
  126. echo "$stats"
  127. return 1
  128. fi
  129. }
  130. test_direct_rdma_operations() {
  131. print_header "TESTING DIRECT RDMA OPERATIONS"
  132. print_step "Testing direct RDMA read operation..."
  133. if ./test-rdma read --socket "$RDMA_SOCKET_PATH" --volume 1 --needle 12345 --size 1024 2>/dev/null | grep -q "RDMA read completed"; then
  134. print_success "Direct RDMA read operation successful"
  135. else
  136. print_warning "Direct RDMA read operation failed (expected in mock mode)"
  137. fi
  138. print_step "Running RDMA performance benchmark..."
  139. benchmark_result=$(./test-rdma bench --socket "$RDMA_SOCKET_PATH" --iterations 5 --read-size 2048 2>/dev/null | tail -10)
  140. if echo "$benchmark_result" | grep -q "Operations/sec:"; then
  141. print_success "RDMA benchmark completed"
  142. echo "$benchmark_result" | grep -E "Operations|Latency|Throughput"
  143. else
  144. print_warning "RDMA benchmark had issues (expected in mock mode)"
  145. fi
  146. }
  147. test_sidecar_needle_operations() {
  148. print_header "TESTING SIDECAR NEEDLE OPERATIONS"
  149. print_step "Testing needle read via sidecar..."
  150. response=$(curl -s "$SIDECAR_URL/read?volume=1&needle=12345&cookie=305419896&size=1024")
  151. if echo "$response" | jq -e '.success == true' > /dev/null; then
  152. print_success "Sidecar needle read successful"
  153. is_rdma=$(echo "$response" | jq -r '.is_rdma')
  154. source=$(echo "$response" | jq -r '.source')
  155. duration=$(echo "$response" | jq -r '.duration')
  156. if [ "$is_rdma" = "true" ]; then
  157. print_success "RDMA fast path used! Duration: $duration"
  158. else
  159. print_warning "HTTP fallback used. Duration: $duration"
  160. fi
  161. echo "Response details:"
  162. echo "$response" | jq '{success, is_rdma, source, duration, data_size}'
  163. else
  164. print_error "Sidecar needle read failed"
  165. echo "$response"
  166. return 1
  167. fi
  168. }
  169. test_sidecar_benchmark() {
  170. print_header "TESTING SIDECAR BENCHMARK"
  171. print_step "Running sidecar performance benchmark..."
  172. response=$(curl -s "$SIDECAR_URL/benchmark?iterations=5&size=2048")
  173. if echo "$response" | jq -e '.benchmark_results' > /dev/null; then
  174. print_success "Sidecar benchmark completed"
  175. rdma_ops=$(echo "$response" | jq -r '.benchmark_results.rdma_ops')
  176. http_ops=$(echo "$response" | jq -r '.benchmark_results.http_ops')
  177. avg_latency=$(echo "$response" | jq -r '.benchmark_results.avg_latency')
  178. ops_per_sec=$(echo "$response" | jq -r '.benchmark_results.ops_per_sec')
  179. echo "Benchmark Results:"
  180. echo " RDMA Operations: $rdma_ops"
  181. echo " HTTP Operations: $http_ops"
  182. echo " Average Latency: $avg_latency"
  183. echo " Operations/sec: $ops_per_sec"
  184. else
  185. print_error "Sidecar benchmark failed"
  186. echo "$response"
  187. return 1
  188. fi
  189. }
  190. test_error_handling() {
  191. print_header "TESTING ERROR HANDLING AND FALLBACK"
  192. print_step "Testing invalid needle read..."
  193. response=$(curl -s "$SIDECAR_URL/read?volume=999&needle=999999&size=1024")
  194. # Should succeed with mock data or fail gracefully
  195. if echo "$response" | jq -e '.success' > /dev/null; then
  196. result=$(echo "$response" | jq -r '.success')
  197. if [ "$result" = "true" ]; then
  198. print_success "Error handling working - mock data returned"
  199. else
  200. print_success "Error handling working - graceful failure"
  201. fi
  202. else
  203. print_success "Error handling working - proper error response"
  204. fi
  205. }
  206. main() {
  207. print_header "🚀 SEAWEEDFS RDMA INTEGRATION TEST SUITE"
  208. echo -e "${GREEN}Starting comprehensive integration tests...${NC}"
  209. echo -e "${BLUE}Environment:${NC}"
  210. echo -e " RDMA Socket: $RDMA_SOCKET_PATH"
  211. echo -e " Sidecar URL: $SIDECAR_URL"
  212. echo -e " SeaweedFS Master: $SEAWEEDFS_MASTER"
  213. echo -e " SeaweedFS Volume: $SEAWEEDFS_VOLUME"
  214. # Run tests in sequence
  215. test_seaweedfs_master
  216. test_seaweedfs_volume
  217. test_rdma_engine
  218. test_rdma_sidecar
  219. test_direct_rdma_operations
  220. test_sidecar_needle_operations
  221. test_sidecar_benchmark
  222. test_error_handling
  223. print_header "🎉 ALL INTEGRATION TESTS COMPLETED!"
  224. echo -e "${GREEN}✅ Test Summary:${NC}"
  225. echo -e " ✅ SeaweedFS Master: Working"
  226. echo -e " ✅ SeaweedFS Volume Server: Working"
  227. echo -e " ✅ Rust RDMA Engine: Working (Mock Mode)"
  228. echo -e " ✅ Go RDMA Sidecar: Working"
  229. echo -e " ✅ IPC Communication: Working"
  230. echo -e " ✅ Needle Operations: Working"
  231. echo -e " ✅ Performance Benchmarking: Working"
  232. echo -e " ✅ Error Handling: Working"
  233. print_success "SeaweedFS RDMA integration is fully functional!"
  234. return 0
  235. }
  236. # Check required environment variables
  237. if [ -z "$RDMA_SOCKET_PATH" ] || [ -z "$SIDECAR_URL" ] || [ -z "$SEAWEEDFS_MASTER" ] || [ -z "$SEAWEEDFS_VOLUME" ]; then
  238. print_error "Required environment variables not set"
  239. echo "Required: RDMA_SOCKET_PATH, SIDECAR_URL, SEAWEEDFS_MASTER, SEAWEEDFS_VOLUME"
  240. exit 1
  241. fi
  242. # Run main test suite
  243. main "$@"