run_all_tests.sh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #!/bin/bash
  2. # Master Test Runner - Enables and runs all previously skipped tests
  3. set -e
  4. # Colors
  5. RED='\033[0;31m'
  6. GREEN='\033[0;32m'
  7. YELLOW='\033[1;33m'
  8. BLUE='\033[0;34m'
  9. NC='\033[0m'
  10. SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  11. echo -e "${BLUE}🎯 SeaweedFS S3 IAM Complete Test Suite${NC}"
  12. echo -e "${BLUE}=====================================${NC}"
  13. # Set environment variables to enable all tests
  14. export ENABLE_DISTRIBUTED_TESTS=true
  15. export ENABLE_PERFORMANCE_TESTS=true
  16. export ENABLE_STRESS_TESTS=true
  17. export KEYCLOAK_URL="http://localhost:8080"
  18. export S3_ENDPOINT="http://localhost:8333"
  19. export TEST_TIMEOUT=60m
  20. export CGO_ENABLED=0
  21. # Function to run test category
  22. run_test_category() {
  23. local category="$1"
  24. local test_pattern="$2"
  25. local description="$3"
  26. echo -e "${YELLOW}🧪 Running $description...${NC}"
  27. if go test -v -timeout=$TEST_TIMEOUT -run "$test_pattern" ./...; then
  28. echo -e "${GREEN}✅ $description completed successfully${NC}"
  29. return 0
  30. else
  31. echo -e "${RED}❌ $description failed${NC}"
  32. return 1
  33. fi
  34. }
  35. # Track results
  36. TOTAL_CATEGORIES=0
  37. PASSED_CATEGORIES=0
  38. # 1. Standard IAM Integration Tests
  39. echo -e "\n${BLUE}1. Standard IAM Integration Tests${NC}"
  40. TOTAL_CATEGORIES=$((TOTAL_CATEGORIES + 1))
  41. if run_test_category "standard" "TestS3IAM(?!.*Distributed|.*Performance)" "Standard IAM Integration Tests"; then
  42. PASSED_CATEGORIES=$((PASSED_CATEGORIES + 1))
  43. fi
  44. # 2. Keycloak Integration Tests (if Keycloak is available)
  45. echo -e "\n${BLUE}2. Keycloak Integration Tests${NC}"
  46. TOTAL_CATEGORIES=$((TOTAL_CATEGORIES + 1))
  47. if curl -s "http://localhost:8080/health/ready" > /dev/null 2>&1; then
  48. if run_test_category "keycloak" "TestKeycloak" "Keycloak Integration Tests"; then
  49. PASSED_CATEGORIES=$((PASSED_CATEGORIES + 1))
  50. fi
  51. else
  52. echo -e "${YELLOW}⚠️ Keycloak not available, skipping Keycloak tests${NC}"
  53. echo -e "${YELLOW}💡 Run './setup_all_tests.sh' to start Keycloak${NC}"
  54. fi
  55. # 3. Distributed Tests
  56. echo -e "\n${BLUE}3. Distributed IAM Tests${NC}"
  57. TOTAL_CATEGORIES=$((TOTAL_CATEGORIES + 1))
  58. if run_test_category "distributed" "TestS3IAMDistributedTests" "Distributed IAM Tests"; then
  59. PASSED_CATEGORIES=$((PASSED_CATEGORIES + 1))
  60. fi
  61. # 4. Performance Tests
  62. echo -e "\n${BLUE}4. Performance Tests${NC}"
  63. TOTAL_CATEGORIES=$((TOTAL_CATEGORIES + 1))
  64. if run_test_category "performance" "TestS3IAMPerformanceTests" "Performance Tests"; then
  65. PASSED_CATEGORIES=$((PASSED_CATEGORIES + 1))
  66. fi
  67. # 5. Benchmarks
  68. echo -e "\n${BLUE}5. Benchmark Tests${NC}"
  69. TOTAL_CATEGORIES=$((TOTAL_CATEGORIES + 1))
  70. if go test -bench=. -benchmem -timeout=$TEST_TIMEOUT ./...; then
  71. echo -e "${GREEN}✅ Benchmark tests completed successfully${NC}"
  72. PASSED_CATEGORIES=$((PASSED_CATEGORIES + 1))
  73. else
  74. echo -e "${RED}❌ Benchmark tests failed${NC}"
  75. fi
  76. # 6. Versioning Stress Tests
  77. echo -e "\n${BLUE}6. S3 Versioning Stress Tests${NC}"
  78. TOTAL_CATEGORIES=$((TOTAL_CATEGORIES + 1))
  79. if [ -f "../versioning/enable_stress_tests.sh" ]; then
  80. if (cd ../versioning && ./enable_stress_tests.sh); then
  81. echo -e "${GREEN}✅ Versioning stress tests completed successfully${NC}"
  82. PASSED_CATEGORIES=$((PASSED_CATEGORIES + 1))
  83. else
  84. echo -e "${RED}❌ Versioning stress tests failed${NC}"
  85. fi
  86. else
  87. echo -e "${YELLOW}⚠️ Versioning stress tests not available${NC}"
  88. fi
  89. # Summary
  90. echo -e "\n${BLUE}📊 Test Summary${NC}"
  91. echo -e "${BLUE}===============${NC}"
  92. echo -e "Total test categories: $TOTAL_CATEGORIES"
  93. echo -e "Passed: ${GREEN}$PASSED_CATEGORIES${NC}"
  94. echo -e "Failed: ${RED}$((TOTAL_CATEGORIES - PASSED_CATEGORIES))${NC}"
  95. if [ $PASSED_CATEGORIES -eq $TOTAL_CATEGORIES ]; then
  96. echo -e "\n${GREEN}🎉 All test categories passed!${NC}"
  97. exit 0
  98. else
  99. echo -e "\n${RED}❌ Some test categories failed${NC}"
  100. exit 1
  101. fi