run_api_tests.yaml 3.8 KB

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