run_api_tests.yaml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. name: API Test Suite
  2. concurrency:
  3. group: apt-${{ github.event_name }}-${{ github.ref }}
  4. cancel-in-progress: true
  5. on:
  6. push:
  7. branch:
  8. - *
  9. tags:
  10. - e*
  11. - v*
  12. pull_request:
  13. jobs:
  14. build:
  15. strategy:
  16. matrix:
  17. otp:
  18. - 24.1.5-4
  19. elixir:
  20. - 1.13.2
  21. os:
  22. - ubuntu20.04
  23. arch:
  24. - amd64
  25. runs-on: ubuntu-latest
  26. container: ghcr.io/emqx/emqx-builder/5.0-5:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}
  27. steps:
  28. - uses: actions/checkout@v2
  29. - name: Get deps git refs for cache
  30. id: deps-refs
  31. run: |
  32. scripts/get-dep-refs.sh
  33. make clean-all
  34. - name: load rocksdb cache
  35. uses: actions/cache@v2
  36. with:
  37. path: source/_build/default/lib/rocksdb/
  38. key: ${{ matrix.os }}-${{ matrix.otp }}-${{ matrix.arch }}-${{ steps.deps-refs.outputs.DEP_ROCKSDB_REF }}
  39. - name: load quicer cache
  40. uses: actions/cache@v2
  41. with:
  42. path: source/_build/default/lib/quicer/
  43. key: ${{ matrix.os }}-${{ matrix.otp }}-${{ matrix.arch }}-${{ steps.deps-refs.outputs.DEP_QUICER_REF }}
  44. - name: build EMQ X CE and EE tgz package
  45. if: endsWith(github.repository, 'emqx')
  46. run: |
  47. make emqx-tgz
  48. make emqx-enterprise-tgz
  49. - uses: actions/upload-artifact@v2
  50. with:
  51. name: emqx-community
  52. path: _packages/emqx/*.tar.gz
  53. - uses: actions/upload-artifact@v2
  54. with:
  55. name: emqx-enterprise
  56. path: _packages/emqx-enterprise/*.tar.gz
  57. api-test:
  58. needs: build
  59. runs-on: ubuntu-latest
  60. strategy:
  61. fail-fast: false
  62. matrix:
  63. script_name:
  64. - api_metrics
  65. - api_subscriptions
  66. - api_clients
  67. - api_routes
  68. - api_publish
  69. - api_user
  70. - api_login
  71. - api_banned
  72. - api_alarms
  73. - api_nodes
  74. - api_topic_metrics
  75. - api_retainer
  76. - api_auto_subscribe
  77. - api_delayed_publish
  78. - api_topic_rewrite
  79. - api_event_message
  80. - api_stats
  81. edition:
  82. - emqx-community
  83. #TODO: add emqx-enterprise
  84. steps:
  85. - uses: actions/checkout@v2
  86. with:
  87. repository: emqx/emqx-fvt
  88. ref: 1.0.4-dev2
  89. path: .
  90. - uses: actions/setup-java@v1
  91. with:
  92. java-version: '8.0.282' # The JDK version to make available on the path.
  93. java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
  94. architecture: x64 # (x64 or x86) - defaults to x64
  95. - uses: actions/download-artifact@v2
  96. with:
  97. name: ${{ matrix.edition }}
  98. path: .
  99. - name: start EMQ X service
  100. env:
  101. EMQX_LISTENERS__WSS__DEFAULT__BIND: "0.0.0.0:8085"
  102. run: |
  103. tar -zxf ./*.tar.gz
  104. ./emqx/bin/emqx start
  105. - name: install jmeter
  106. timeout-minutes: 10
  107. env:
  108. JMETER_VERSION: 5.3
  109. run: |
  110. wget --no-verbose --no-check-certificate -O /tmp/apache-jmeter.tgz https://downloads.apache.org/jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz
  111. cd /tmp && tar -xvf apache-jmeter.tgz
  112. echo "jmeter.save.saveservice.output_format=xml" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  113. echo "jmeter.save.saveservice.response_data.on_error=true" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  114. wget --no-verbose -O /tmp/apache-jmeter-$JMETER_VERSION/lib/ext/mqtt-xmeter-fuse-2.0.2-jar-with-dependencies.jar https://raw.githubusercontent.com/xmeter-net/mqtt-jmeter/master/Download/v2.0.2/mqtt-xmeter-fuse-2.0.2-jar-with-dependencies.jar
  115. ln -s /tmp/apache-jmeter-$JMETER_VERSION /opt/jmeter
  116. - name: run ${{ matrix.script_name }}
  117. run: |
  118. /opt/jmeter/bin/jmeter.sh \
  119. -Jjmeter.save.saveservice.output_format=xml -n \
  120. -t api-test-suite/${{ matrix.script_name }}.jmx \
  121. -Demqx_ip="127.0.0.1" \
  122. -l jmeter_logs/${{ matrix.script_name }}.jtl \
  123. -j jmeter_logs/logs/${{ matrix.script_name }}.log
  124. - name: check test logs
  125. run: |
  126. if cat jmeter_logs/${{ matrix.script_name }}.jtl | grep -e '<failure>true</failure>' > /dev/null 2>&1; then
  127. grep -A 5 -B 3 '<failure>true</failure>' jmeter_logs/${{ matrix.script_name }}.jtl > jmeter_logs/${{ matrix.script_name }}_err_api.txt
  128. echo "check logs failed"
  129. exit 1
  130. fi
  131. - uses: actions/upload-artifact@v1
  132. if: failure()
  133. with:
  134. name: jmeter_logs
  135. path: ./jmeter_logs
  136. delete-package:
  137. runs-on: ubuntu-20.04
  138. needs: api-test
  139. if: always()
  140. steps:
  141. - uses: geekyeggo/delete-artifact@v1
  142. with:
  143. name: emqx-community
  144. - uses: geekyeggo/delete-artifact@v1
  145. with:
  146. name: emqx-enterprise