performance_test.yaml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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.0-35:1.13.4-25.1.2-3-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. tf_emqx_perf_test:
  46. runs-on: ubuntu-latest
  47. needs:
  48. - prepare
  49. env:
  50. TF_VAR_package_file: ${{ needs.prepare.outputs.PACKAGE_FILE }}
  51. TF_VAR_grafana_api_key: ${{ secrets.TF_EMQX_PERF_TEST_GRAFANA_API_KEY }}
  52. TF_AWS_REGION: eu-north-1
  53. TF_VAR_test_duration: 1800
  54. steps:
  55. - name: Configure AWS Credentials
  56. uses: aws-actions/configure-aws-credentials@v2
  57. with:
  58. aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_PERF_TEST }}
  59. aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_PERF_TEST }}
  60. aws-region: eu-north-1
  61. - name: Checkout tf-emqx-performance-test
  62. uses: actions/checkout@v3
  63. with:
  64. repository: emqx/tf-emqx-performance-test
  65. path: tf-emqx-performance-test
  66. - uses: actions/download-artifact@v3
  67. with:
  68. name: emqx-ubuntu20.04
  69. path: tf-emqx-performance-test/
  70. - name: Setup Terraform
  71. uses: hashicorp/setup-terraform@v2
  72. with:
  73. terraform_wrapper: false
  74. - name: 1on1 scenario
  75. id: scenario_1on1
  76. working-directory: ./tf-emqx-performance-test
  77. timeout-minutes: 60
  78. env:
  79. TF_VAR_bench_id: "${{ needs.prepare.outputs.BENCH_ID }}/1on1"
  80. TF_VAR_use_emqttb: 1
  81. TF_VAR_use_emqtt_bench: 0
  82. TF_VAR_emqttb_instance_count: 2
  83. TF_VAR_emqttb_instance_type: "c5.large"
  84. TF_VAR_emqttb_scenario: "@pub --topic 't/%n' --pubinterval 10ms --qos 1 --publatency 50ms --size 16 --num-clients 25000 @sub --topic 't/%n' --num-clients 25000"
  85. TF_VAR_emqx_instance_type: "c5.xlarge"
  86. TF_VAR_emqx_instance_count: 3
  87. run: |
  88. terraform init
  89. terraform apply -auto-approve
  90. ./wait-emqttb.sh
  91. ./fetch-metrics.sh
  92. MESSAGES_RECEIVED=$(cat metrics.json | jq '[.[]."messages.received"] | add')
  93. MESSAGES_SENT=$(cat metrics.json | jq '[.[]."messages.sent"] | add')
  94. echo MESSAGES_DROPPED=$(cat metrics.json | jq '[.[]."messages.dropped"] | add') >> $GITHUB_OUTPUT
  95. echo PUB_MSG_RATE=$(($MESSAGES_RECEIVED / $TF_VAR_test_duration)) >> $GITHUB_OUTPUT
  96. echo SUB_MSG_RATE=$(($MESSAGES_SENT / $TF_VAR_test_duration)) >> $GITHUB_OUTPUT
  97. terraform destroy -auto-approve
  98. - name: Send notification to Slack
  99. uses: slackapi/slack-github-action@v1.23.0
  100. env:
  101. SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
  102. with:
  103. payload: |
  104. {"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 }}"}
  105. - name: terraform destroy
  106. if: always()
  107. working-directory: ./tf-emqx-performance-test
  108. run: |
  109. terraform destroy -auto-approve
  110. - uses: actions/upload-artifact@v3
  111. if: success()
  112. with:
  113. name: metrics
  114. path: "./tf-emqx-performance-test/metrics.json"
  115. - uses: actions/upload-artifact@v3
  116. if: failure()
  117. with:
  118. name: terraform
  119. path: |
  120. ./tf-emqx-performance-test/.terraform
  121. ./tf-emqx-performance-test/*.tfstate