run_api_tests.yaml 3.7 KB

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