run_broker_tests.yaml 4.2 KB

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