run_api_tests.yaml 4.6 KB

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