run_broker_tests.yaml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. name: Broker tests
  2. on:
  3. push:
  4. branches:
  5. - '**'
  6. tags:
  7. - v*
  8. pull_request:
  9. jobs:
  10. build:
  11. runs-on: ubuntu-latest
  12. outputs:
  13. version: ${{ steps.build_docker.outputs.version}}
  14. steps:
  15. - name: download jmeter
  16. timeout-minutes: 3
  17. env:
  18. JMETER_VERSION: 5.3
  19. run: |
  20. wget --no-verbose --no-check-certificate -O /tmp/apache-jmeter.tgz https://downloads.apache.org/jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz
  21. - uses: actions/upload-artifact@v2
  22. with:
  23. name: apache-jmeter.tgz
  24. path: /tmp/apache-jmeter.tgz
  25. - uses: actions/checkout@v2
  26. - name: zip emqx docker image
  27. id: build_docker
  28. if: endsWith(github.repository, 'emqx')
  29. run: |
  30. ## TODO: make profile a matrix dimension
  31. PROFILE='emqx'
  32. make "${PROFILE}-docker"
  33. VSN="$(./pkg-vsn.sh $PROFILE)"
  34. echo "::set-output name=version::${VSN}"
  35. docker save -o emqx.tar emqx/emqx:${VSN}
  36. - uses: actions/upload-artifact@v2
  37. with:
  38. name: emqx.tar
  39. path: ./emqx.tar
  40. mqtt_subscription:
  41. runs-on: ubuntu-latest
  42. strategy:
  43. fail-fast: false
  44. matrix:
  45. subscription_type:
  46. - mqtt_subscription_topic_metrics
  47. needs: build
  48. steps:
  49. - uses: actions/checkout@v2
  50. - uses: actions/download-artifact@v2
  51. with:
  52. name: emqx.tar
  53. path: /tmp
  54. - name: load docker image
  55. run: |
  56. docker load < /tmp/emqx.tar
  57. - name: docker compose up
  58. timeout-minutes: 5
  59. env:
  60. _EMQX_DOCKER_IMAGE_TAG: emqx/emqx:${{ needs.build.outputs.version }}
  61. run: |
  62. docker-compose \
  63. -f .ci/docker-compose-file/docker-compose-emqx-cluster.yaml \
  64. up -d --build
  65. - name: wait docker compose up
  66. timeout-minutes: 5
  67. run: |
  68. while [ "$(docker inspect -f '{{ .State.Health.Status}}' node1.emqx.io)" != "healthy" ] || [ "$(docker inspect -f '{{ .State.Health.Status}}' node2.emqx.io)" != "healthy" ]; do
  69. echo "['$(date -u +"%y-%m-%dt%h:%m:%sz")']:waiting emqx";
  70. sleep 5;
  71. done
  72. while [ $(docker ps -a --filter name=client --filter exited=0 | wc -l) \
  73. != $(docker ps -a --filter name=client | wc -l) ]; do
  74. sleep 1
  75. done
  76. docker ps -a
  77. echo HAPROXY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' haproxy) >> $GITHUB_ENV
  78. - uses: actions/checkout@v2
  79. with:
  80. repository: emqx/emqx-fvt
  81. ref: broker-autotest
  82. path: scripts
  83. - uses: actions/setup-java@v1
  84. with:
  85. java-version: '8.0.282' # The JDK version to make available on the path.
  86. java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
  87. architecture: x64 # (x64 or x86) - defaults to x64
  88. - uses: actions/download-artifact@v2
  89. with:
  90. name: apache-jmeter.tgz
  91. path: /tmp
  92. - name: install jmeter
  93. timeout-minutes: 10
  94. env:
  95. JMETER_VERSION: 5.3
  96. run: |
  97. cd /tmp && tar -xvf apache-jmeter.tgz
  98. echo "jmeter.save.saveservice.output_format=xml" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  99. echo "jmeter.save.saveservice.response_data.on_error=true" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  100. 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
  101. ln -s /tmp/apache-jmeter-$JMETER_VERSION /opt/jmeter
  102. - name: run jmeter
  103. run: |
  104. /opt/jmeter/bin/jmeter.sh \
  105. -Jjmeter.save.saveservice.output_format=xml -n \
  106. -t scripts/broker-autotest-suite/${{ matrix.subscription_type }}.jmx \
  107. -Demqx_ip=$HAPROXY_IP \
  108. -l jmeter_logs/${{ matrix.subscription_type }}.jtl \
  109. -j jmeter_logs/logs/${{ matrix.subscription_type }}.log
  110. - name: check logs
  111. run: |
  112. if cat jmeter_logs/${{ matrix.subscription_type }}}.jtl | grep -e '<failure>true</failure>' > /dev/null 2>&1; then
  113. echo "check logs filed"
  114. exit 1
  115. fi
  116. - uses: actions/upload-artifact@v1
  117. if: always()
  118. with:
  119. name: jmeter_logs
  120. path: ./jmeter_logs