performance_test.yaml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. name: Performance Test Suite
  2. on:
  3. push:
  4. branches:
  5. - 'perf/**'
  6. schedule:
  7. - cron: '0 1 * * *'
  8. workflow_dispatch:
  9. inputs:
  10. ref:
  11. required: false
  12. jobs:
  13. prepare:
  14. runs-on: ubuntu-latest
  15. if: github.repository_owner == 'emqx'
  16. container: ghcr.io/emqx/emqx-builder/5.1-0:1.14.5-25.3.2-1-ubuntu20.04
  17. outputs:
  18. BENCH_ID: ${{ steps.prepare.outputs.BENCH_ID }}
  19. PACKAGE_FILE: ${{ steps.package_file.outputs.PACKAGE_FILE }}
  20. steps:
  21. - uses: actions/checkout@v3
  22. with:
  23. fetch-depth: 0
  24. ref: ${{ github.event.inputs.ref }}
  25. - name: Work around https://github.com/actions/checkout/issues/766
  26. run: |
  27. git config --global --add safe.directory "$GITHUB_WORKSPACE"
  28. - id: prepare
  29. run: |
  30. echo "EMQX_NAME=emqx" >> $GITHUB_ENV
  31. echo "CODE_PATH=$GITHUB_WORKSPACE" >> $GITHUB_ENV
  32. echo "BENCH_ID=$(date --utc +%F)/emqx-$(./pkg-vsn.sh emqx)" >> $GITHUB_OUTPUT
  33. - name: Build deb package
  34. run: |
  35. make ${EMQX_NAME}-pkg
  36. ./scripts/pkg-tests.sh ${EMQX_NAME}-pkg
  37. - name: Get package file name
  38. id: package_file
  39. run: |
  40. echo "PACKAGE_FILE=$(find _packages/emqx -name 'emqx-*.deb' | head -n 1 | xargs basename)" >> $GITHUB_OUTPUT
  41. - uses: actions/upload-artifact@v3
  42. with:
  43. name: emqx-ubuntu20.04
  44. path: _packages/emqx/${{ steps.package_file.outputs.PACKAGE_FILE }}
  45. scenario_1on1:
  46. runs-on: ubuntu-latest
  47. needs:
  48. - prepare
  49. env:
  50. TF_VAR_package_file: ${{ needs.prepare.outputs.PACKAGE_FILE }}
  51. TF_AWS_REGION: eu-west-1
  52. TF_VAR_test_duration: 1800
  53. TF_VAR_prometheus_remote_write_url: ${{ secrets.TF_EMQX_PERF_TEST_PROMETHEUS_REMOTE_WRITE_URL }}
  54. TF_VAR_prometheus_remote_write_region: eu-west-1
  55. steps:
  56. - name: Configure AWS Credentials
  57. uses: aws-actions/configure-aws-credentials@v2
  58. with:
  59. aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_PERF_TEST }}
  60. aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_PERF_TEST }}
  61. aws-region: eu-west-1
  62. - name: Checkout tf-emqx-performance-test
  63. uses: actions/checkout@v3
  64. with:
  65. repository: emqx/tf-emqx-performance-test
  66. path: tf-emqx-performance-test
  67. ref: v0.2.2
  68. - uses: actions/download-artifact@v3
  69. with:
  70. name: emqx-ubuntu20.04
  71. path: tf-emqx-performance-test/
  72. - name: Setup Terraform
  73. uses: hashicorp/setup-terraform@v2
  74. with:
  75. terraform_wrapper: false
  76. - name: 1on1 scenario
  77. id: scenario_1on1
  78. working-directory: ./tf-emqx-performance-test
  79. timeout-minutes: 60
  80. env:
  81. TF_VAR_bench_id: "${{ needs.prepare.outputs.BENCH_ID }}/1on1"
  82. TF_VAR_use_emqttb: 1
  83. TF_VAR_use_emqtt_bench: 0
  84. TF_VAR_emqttb_instance_count: 1
  85. TF_VAR_emqttb_instance_type: "c5.2xlarge"
  86. TF_VAR_emqttb_scenario: "@pubsub_fwd -n 50_000 --pub-qos 1 --sub-qos 1"
  87. TF_VAR_emqx_instance_type: "c5.xlarge"
  88. TF_VAR_emqx_instance_count: 3
  89. run: |
  90. terraform init
  91. terraform apply -auto-approve
  92. ./wait-emqttb.sh
  93. ./fetch-metrics.sh
  94. MESSAGES_RECEIVED=$(cat metrics.json | jq '[.[]."messages.received"] | add')
  95. MESSAGES_SENT=$(cat metrics.json | jq '[.[]."messages.sent"] | add')
  96. echo MESSAGES_DROPPED=$(cat metrics.json | jq '[.[]."messages.dropped"] | add') >> $GITHUB_OUTPUT
  97. echo PUB_MSG_RATE=$(($MESSAGES_RECEIVED / $TF_VAR_test_duration)) >> $GITHUB_OUTPUT
  98. echo SUB_MSG_RATE=$(($MESSAGES_SENT / $TF_VAR_test_duration)) >> $GITHUB_OUTPUT
  99. terraform destroy -auto-approve
  100. - name: Send notification to Slack
  101. uses: slackapi/slack-github-action@v1.23.0
  102. env:
  103. SLACK_WEBHOOK_URL: ${{ secrets.TF_EMQX_PERF_TEST_SLACK_URL }}
  104. with:
  105. payload: |
  106. {"text": "Performance test result for 1on1 scenario (50k pub, 50k sub): ${{ job.status }}\nhttps://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\n*Pub message rate*: `${{ steps.scenario_1on1.outputs.PUB_MSG_RATE }}`\n*Sub message rate*: `${{ steps.scenario_1on1.outputs.SUB_MSG_RATE }}`\nDropped messages: `${{ steps.scenario_1on1.outputs.MESSAGES_DROPPED }}`"}
  107. - name: terraform destroy
  108. if: always()
  109. working-directory: ./tf-emqx-performance-test
  110. run: |
  111. terraform destroy -auto-approve
  112. - uses: actions/upload-artifact@v3
  113. if: success()
  114. with:
  115. name: metrics
  116. path: "./tf-emqx-performance-test/*.json"
  117. - uses: actions/upload-artifact@v3
  118. if: failure()
  119. with:
  120. name: terraform
  121. path: |
  122. ./tf-emqx-performance-test/.terraform
  123. ./tf-emqx-performance-test/*.tfstate
  124. scenario_1m_conns:
  125. runs-on: ubuntu-latest
  126. needs:
  127. - prepare
  128. - scenario_1on1
  129. env:
  130. TF_VAR_package_file: ${{ needs.prepare.outputs.PACKAGE_FILE }}
  131. TF_AWS_REGION: eu-west-1
  132. TF_VAR_test_duration: 1800
  133. TF_VAR_prometheus_remote_write_url: ${{ secrets.TF_EMQX_PERF_TEST_PROMETHEUS_REMOTE_WRITE_URL }}
  134. TF_VAR_prometheus_remote_write_region: eu-west-1
  135. steps:
  136. - name: Configure AWS Credentials
  137. uses: aws-actions/configure-aws-credentials@v2
  138. with:
  139. aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_PERF_TEST }}
  140. aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_PERF_TEST }}
  141. aws-region: eu-west-1
  142. - name: Checkout tf-emqx-performance-test
  143. uses: actions/checkout@v3
  144. with:
  145. repository: emqx/tf-emqx-performance-test
  146. path: tf-emqx-performance-test
  147. ref: v0.2.2
  148. - uses: actions/download-artifact@v3
  149. with:
  150. name: emqx-ubuntu20.04
  151. path: tf-emqx-performance-test/
  152. - name: Setup Terraform
  153. uses: hashicorp/setup-terraform@v2
  154. with:
  155. terraform_wrapper: false
  156. - name: 1m conns scenario
  157. id: scenario_1m_conns
  158. working-directory: ./tf-emqx-performance-test
  159. timeout-minutes: 60
  160. env:
  161. TF_VAR_bench_id: "${{ needs.prepare.outputs.BENCH_ID }}/scenario_1m_conns"
  162. TF_VAR_use_emqttb: 1
  163. TF_VAR_use_emqtt_bench: 0
  164. TF_VAR_emqttb_instance_count: 5
  165. TF_VAR_emqttb_instance_type: "c5.xlarge"
  166. TF_VAR_emqttb_scenario: "@conn -N 200_000 --conninterval 1ms"
  167. TF_VAR_emqx_instance_type: "c5.xlarge"
  168. TF_VAR_emqx_instance_count: 5
  169. run: |
  170. terraform init
  171. terraform apply -auto-approve
  172. ./wait-emqttb.sh
  173. ./fetch-metrics.sh
  174. echo CLIENT_CONNECT=$(cat metrics.json | jq '[.[]."client.connect"] | add') >> $GITHUB_OUTPUT
  175. terraform destroy -auto-approve
  176. - name: Send notification to Slack
  177. uses: slackapi/slack-github-action@v1.23.0
  178. env:
  179. SLACK_WEBHOOK_URL: ${{ secrets.TF_EMQX_PERF_TEST_SLACK_URL }}
  180. with:
  181. payload: |
  182. {"text": "Performance test result for 1m conns: ${{ job.status }}\nhttps://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\n*client.connect*: `${{ steps.scenario_1m_conns.outputs.CLIENT_CONNECT }}`"}
  183. - name: terraform destroy
  184. if: always()
  185. working-directory: ./tf-emqx-performance-test
  186. run: |
  187. terraform destroy -auto-approve
  188. - uses: actions/upload-artifact@v3
  189. if: success()
  190. with:
  191. name: metrics
  192. path: "./tf-emqx-performance-test/*.json"
  193. - uses: actions/upload-artifact@v3
  194. if: failure()
  195. with:
  196. name: terraform
  197. path: |
  198. ./tf-emqx-performance-test/.terraform
  199. ./tf-emqx-performance-test/*.tfstate