s3-iam-tests.yml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. name: "S3 IAM Integration Tests"
  2. on:
  3. pull_request:
  4. paths:
  5. - 'weed/iam/**'
  6. - 'weed/s3api/**'
  7. - 'test/s3/iam/**'
  8. - '.github/workflows/s3-iam-tests.yml'
  9. push:
  10. branches: [ master ]
  11. paths:
  12. - 'weed/iam/**'
  13. - 'weed/s3api/**'
  14. - 'test/s3/iam/**'
  15. - '.github/workflows/s3-iam-tests.yml'
  16. concurrency:
  17. group: ${{ github.head_ref }}/s3-iam-tests
  18. cancel-in-progress: true
  19. permissions:
  20. contents: read
  21. defaults:
  22. run:
  23. working-directory: weed
  24. jobs:
  25. # Unit tests for IAM components
  26. iam-unit-tests:
  27. name: IAM Unit Tests
  28. runs-on: ubuntu-22.04
  29. timeout-minutes: 15
  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: Get dependencies
  39. run: |
  40. go mod download
  41. - name: Run IAM Unit Tests
  42. timeout-minutes: 10
  43. run: |
  44. set -x
  45. echo "=== Running IAM STS Tests ==="
  46. go test -v -timeout 5m ./iam/sts/...
  47. echo "=== Running IAM Policy Tests ==="
  48. go test -v -timeout 5m ./iam/policy/...
  49. echo "=== Running IAM Integration Tests ==="
  50. go test -v -timeout 5m ./iam/integration/...
  51. echo "=== Running S3 API IAM Tests ==="
  52. go test -v -timeout 5m ./s3api/... -run ".*IAM.*|.*JWT.*|.*Auth.*"
  53. - name: Upload test results on failure
  54. if: failure()
  55. uses: actions/upload-artifact@v4
  56. with:
  57. name: iam-unit-test-results
  58. path: |
  59. weed/testdata/
  60. weed/**/testdata/
  61. retention-days: 3
  62. # S3 IAM integration tests with SeaweedFS services
  63. s3-iam-integration-tests:
  64. name: S3 IAM Integration Tests
  65. runs-on: ubuntu-22.04
  66. timeout-minutes: 25
  67. strategy:
  68. matrix:
  69. test-type: ["basic", "advanced", "policy-enforcement"]
  70. steps:
  71. - name: Check out code
  72. uses: actions/checkout@v5
  73. - name: Set up Go
  74. uses: actions/setup-go@v6
  75. with:
  76. go-version-file: 'go.mod'
  77. id: go
  78. - name: Install SeaweedFS
  79. working-directory: weed
  80. run: |
  81. go install -buildvcs=false
  82. - name: Run S3 IAM Integration Tests - ${{ matrix.test-type }}
  83. timeout-minutes: 20
  84. working-directory: test/s3/iam
  85. run: |
  86. set -x
  87. echo "=== System Information ==="
  88. uname -a
  89. free -h
  90. df -h
  91. echo "=== Starting S3 IAM Integration Tests (${{ matrix.test-type }}) ==="
  92. # Set WEED_BINARY to use the installed version
  93. export WEED_BINARY=$(which weed)
  94. export TEST_TIMEOUT=15m
  95. # Run tests based on type
  96. case "${{ matrix.test-type }}" in
  97. "basic")
  98. echo "Running basic IAM functionality tests..."
  99. make clean setup start-services wait-for-services
  100. go test -v -timeout 15m -run "TestS3IAMAuthentication|TestS3IAMBasicWorkflow|TestS3IAMTokenValidation" ./...
  101. ;;
  102. "advanced")
  103. echo "Running advanced IAM feature tests..."
  104. make clean setup start-services wait-for-services
  105. go test -v -timeout 15m -run "TestS3IAMSessionExpiration|TestS3IAMMultipart|TestS3IAMPresigned" ./...
  106. ;;
  107. "policy-enforcement")
  108. echo "Running policy enforcement tests..."
  109. make clean setup start-services wait-for-services
  110. go test -v -timeout 15m -run "TestS3IAMPolicyEnforcement|TestS3IAMBucketPolicy|TestS3IAMContextual" ./...
  111. ;;
  112. *)
  113. echo "Unknown test type: ${{ matrix.test-type }}"
  114. exit 1
  115. ;;
  116. esac
  117. # Always cleanup
  118. make stop-services
  119. - name: Show service logs on failure
  120. if: failure()
  121. working-directory: test/s3/iam
  122. run: |
  123. echo "=== Service Logs ==="
  124. echo "--- Master Log ---"
  125. tail -50 weed-master.log 2>/dev/null || echo "No master log found"
  126. echo ""
  127. echo "--- Filer Log ---"
  128. tail -50 weed-filer.log 2>/dev/null || echo "No filer log found"
  129. echo ""
  130. echo "--- Volume Log ---"
  131. tail -50 weed-volume.log 2>/dev/null || echo "No volume log found"
  132. echo ""
  133. echo "--- S3 API Log ---"
  134. tail -50 weed-s3.log 2>/dev/null || echo "No S3 log found"
  135. echo ""
  136. echo "=== Process Information ==="
  137. ps aux | grep -E "(weed|test)" || true
  138. netstat -tlnp | grep -E "(8333|8888|9333|8080)" || true
  139. - name: Upload test logs on failure
  140. if: failure()
  141. uses: actions/upload-artifact@v4
  142. with:
  143. name: s3-iam-integration-logs-${{ matrix.test-type }}
  144. path: test/s3/iam/weed-*.log
  145. retention-days: 5
  146. # Distributed IAM tests
  147. s3-iam-distributed-tests:
  148. name: S3 IAM Distributed Tests
  149. runs-on: ubuntu-22.04
  150. timeout-minutes: 25
  151. steps:
  152. - name: Check out code
  153. uses: actions/checkout@v5
  154. - name: Set up Go
  155. uses: actions/setup-go@v6
  156. with:
  157. go-version-file: 'go.mod'
  158. id: go
  159. - name: Install SeaweedFS
  160. working-directory: weed
  161. run: |
  162. go install -buildvcs=false
  163. - name: Run Distributed IAM Tests
  164. timeout-minutes: 20
  165. working-directory: test/s3/iam
  166. run: |
  167. set -x
  168. echo "=== System Information ==="
  169. uname -a
  170. free -h
  171. export WEED_BINARY=$(which weed)
  172. export TEST_TIMEOUT=15m
  173. # Test distributed configuration
  174. echo "Testing distributed IAM configuration..."
  175. make clean setup
  176. # Start services with distributed IAM config
  177. echo "Starting services with distributed configuration..."
  178. make start-services
  179. make wait-for-services
  180. # Run distributed-specific tests
  181. export ENABLE_DISTRIBUTED_TESTS=true
  182. go test -v -timeout 15m -run "TestS3IAMDistributedTests" ./... || {
  183. echo "❌ Distributed tests failed, checking logs..."
  184. make logs
  185. exit 1
  186. }
  187. make stop-services
  188. - name: Upload distributed test logs
  189. if: always()
  190. uses: actions/upload-artifact@v4
  191. with:
  192. name: s3-iam-distributed-logs
  193. path: test/s3/iam/weed-*.log
  194. retention-days: 7
  195. # Performance and stress tests
  196. s3-iam-performance-tests:
  197. name: S3 IAM Performance Tests
  198. runs-on: ubuntu-22.04
  199. timeout-minutes: 30
  200. steps:
  201. - name: Check out code
  202. uses: actions/checkout@v5
  203. - name: Set up Go
  204. uses: actions/setup-go@v6
  205. with:
  206. go-version-file: 'go.mod'
  207. id: go
  208. - name: Install SeaweedFS
  209. working-directory: weed
  210. run: |
  211. go install -buildvcs=false
  212. - name: Run IAM Performance Benchmarks
  213. timeout-minutes: 25
  214. working-directory: test/s3/iam
  215. run: |
  216. set -x
  217. echo "=== Running IAM Performance Tests ==="
  218. export WEED_BINARY=$(which weed)
  219. export TEST_TIMEOUT=20m
  220. make clean setup start-services wait-for-services
  221. # Run performance tests (benchmarks disabled for CI)
  222. echo "Running performance tests..."
  223. export ENABLE_PERFORMANCE_TESTS=true
  224. go test -v -timeout 15m -run "TestS3IAMPerformanceTests" ./... || {
  225. echo "❌ Performance tests failed"
  226. make logs
  227. exit 1
  228. }
  229. make stop-services
  230. - name: Upload performance test results
  231. if: always()
  232. uses: actions/upload-artifact@v4
  233. with:
  234. name: s3-iam-performance-results
  235. path: |
  236. test/s3/iam/weed-*.log
  237. test/s3/iam/*.test
  238. retention-days: 7