s3-keycloak-tests.yml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. name: "S3 Keycloak Integration Tests"
  2. on:
  3. pull_request:
  4. paths:
  5. - 'weed/iam/**'
  6. - 'weed/s3api/**'
  7. - 'test/s3/iam/**'
  8. - '.github/workflows/s3-keycloak-tests.yml'
  9. push:
  10. branches: [ master ]
  11. paths:
  12. - 'weed/iam/**'
  13. - 'weed/s3api/**'
  14. - 'test/s3/iam/**'
  15. - '.github/workflows/s3-keycloak-tests.yml'
  16. concurrency:
  17. group: ${{ github.head_ref }}/s3-keycloak-tests
  18. cancel-in-progress: true
  19. permissions:
  20. contents: read
  21. defaults:
  22. run:
  23. working-directory: weed
  24. jobs:
  25. # Dedicated job for Keycloak integration tests
  26. s3-keycloak-integration-tests:
  27. name: S3 Keycloak Integration Tests
  28. runs-on: ubuntu-22.04
  29. timeout-minutes: 30
  30. steps:
  31. - name: Check out code
  32. uses: actions/checkout@v5
  33. - name: Set up Go
  34. uses: actions/setup-go@v6
  35. with:
  36. go-version-file: 'go.mod'
  37. id: go
  38. - name: Install SeaweedFS
  39. working-directory: weed
  40. run: |
  41. go install -buildvcs=false
  42. - name: Run Keycloak Integration Tests
  43. timeout-minutes: 25
  44. working-directory: test/s3/iam
  45. run: |
  46. set -x
  47. echo "=== System Information ==="
  48. uname -a
  49. free -h
  50. df -h
  51. echo "=== Starting S3 Keycloak Integration Tests ==="
  52. # Set WEED_BINARY to use the installed version
  53. export WEED_BINARY=$(which weed)
  54. export TEST_TIMEOUT=20m
  55. echo "Running Keycloak integration tests..."
  56. # Start Keycloak container first
  57. docker run -d \
  58. --name keycloak \
  59. -p 8080:8080 \
  60. -e KC_BOOTSTRAP_ADMIN_USERNAME=admin \
  61. -e KC_BOOTSTRAP_ADMIN_PASSWORD=admin \
  62. -e KC_HTTP_ENABLED=true \
  63. -e KC_HOSTNAME_STRICT=false \
  64. -e KC_HOSTNAME_STRICT_HTTPS=false \
  65. quay.io/keycloak/keycloak:26.0 \
  66. start-dev
  67. # Wait for Keycloak with better health checking
  68. timeout 300 bash -c '
  69. while true; do
  70. if curl -s http://localhost:8080/health/ready > /dev/null 2>&1; then
  71. echo "✅ Keycloak health check passed"
  72. break
  73. fi
  74. echo "... waiting for Keycloak to be ready"
  75. sleep 5
  76. done
  77. '
  78. # Setup Keycloak configuration
  79. ./setup_keycloak.sh
  80. # Start SeaweedFS services
  81. make clean setup start-services wait-for-services
  82. # Verify service accessibility
  83. echo "=== Verifying Service Accessibility ==="
  84. curl -f http://localhost:8080/realms/master
  85. curl -s http://localhost:8333
  86. echo "✅ SeaweedFS S3 API is responding (IAM-protected endpoint)"
  87. # Run Keycloak-specific tests
  88. echo "=== Running Keycloak Tests ==="
  89. export KEYCLOAK_URL=http://localhost:8080
  90. export S3_ENDPOINT=http://localhost:8333
  91. # Wait for realm to be properly configured
  92. timeout 120 bash -c 'until curl -fs http://localhost:8080/realms/seaweedfs-test/.well-known/openid-configuration > /dev/null; do echo "... waiting for realm"; sleep 3; done'
  93. # Run the Keycloak integration tests
  94. go test -v -timeout 20m -run "TestKeycloak" ./...
  95. - name: Show server logs on failure
  96. if: failure()
  97. working-directory: test/s3/iam
  98. run: |
  99. echo "=== Service Logs ==="
  100. echo "--- Keycloak logs ---"
  101. docker logs keycloak --tail=100 || echo "No Keycloak container logs"
  102. echo "--- SeaweedFS Master logs ---"
  103. if [ -f weed-master.log ]; then
  104. tail -100 weed-master.log
  105. fi
  106. echo "--- SeaweedFS S3 logs ---"
  107. if [ -f weed-s3.log ]; then
  108. tail -100 weed-s3.log
  109. fi
  110. echo "--- SeaweedFS Filer logs ---"
  111. if [ -f weed-filer.log ]; then
  112. tail -100 weed-filer.log
  113. fi
  114. echo "=== System Status ==="
  115. ps aux | grep -E "(weed|keycloak)" || true
  116. netstat -tlnp | grep -E "(8333|9333|8080|8888)" || true
  117. docker ps -a || true
  118. - name: Cleanup
  119. if: always()
  120. working-directory: test/s3/iam
  121. run: |
  122. # Stop Keycloak container
  123. docker stop keycloak || true
  124. docker rm keycloak || true
  125. # Stop SeaweedFS services
  126. make clean || true
  127. - name: Upload test logs on failure
  128. if: failure()
  129. uses: actions/upload-artifact@v4
  130. with:
  131. name: s3-keycloak-test-logs
  132. path: |
  133. test/s3/iam/*.log
  134. test/s3/iam/test-volume-data/
  135. retention-days: 3