run_api_tests.yaml 3.5 KB

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