run_api_tests.yaml 3.8 KB

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