run_api_tests.yaml 4.7 KB

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