run_jmeter_tests.yaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. name: JMeter integration tests
  2. on:
  3. workflow_call:
  4. inputs:
  5. version-emqx:
  6. required: true
  7. type: string
  8. jobs:
  9. jmeter_artifact:
  10. runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
  11. steps:
  12. - name: Cache Jmeter
  13. id: cache-jmeter
  14. uses: actions/cache@v3
  15. with:
  16. path: /tmp/apache-jmeter.tgz
  17. key: apache-jmeter-5.4.3.tgz
  18. - name: download jmeter
  19. if: steps.cache-jmeter.outputs.cache-hit != 'true'
  20. timeout-minutes: 15
  21. env:
  22. JMETER_VERSION: 5.4.3
  23. run: |
  24. # versions below 5.5 had been moved to the archive area
  25. # latest version is 5.6, the script below should handle both scenarios
  26. URL=https://downloads.apache.org/jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz
  27. ARCHIVE_URL=https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz
  28. if wget -q --method HEAD $URL; then
  29. wget --no-verbose --no-check-certificate -O /tmp/apache-jmeter.tgz $URL
  30. else
  31. wget --no-verbose --no-check-certificate -O /tmp/apache-jmeter.tgz $ARCHIVE_URL
  32. fi
  33. - uses: actions/upload-artifact@v3
  34. with:
  35. name: apache-jmeter.tgz
  36. path: /tmp/apache-jmeter.tgz
  37. retention-days: 3
  38. advanced_feat:
  39. runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
  40. strategy:
  41. fail-fast: false
  42. matrix:
  43. scripts_type:
  44. - mqtt_subscription_topic_metrics
  45. - mqtt_delayed_publish
  46. - mqtt_topic_rewrite
  47. # - mqtt_retainer
  48. needs: jmeter_artifact
  49. steps:
  50. - uses: actions/checkout@v3
  51. - uses: ./.github/actions/prepare-jmeter
  52. with:
  53. version-emqx: ${{ inputs.version-emqx }}
  54. - name: docker compose up
  55. timeout-minutes: 5
  56. run: |
  57. docker compose \
  58. -f .ci/docker-compose-file/docker-compose-emqx-cluster.yaml \
  59. up --wait --build
  60. echo HAPROXY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' haproxy) >> $GITHUB_ENV
  61. - name: show logs
  62. if: failure()
  63. run: |
  64. docker compose \
  65. -f .ci/docker-compose-file/docker-compose-emqx-cluster.yaml \
  66. logs
  67. - name: run jmeter
  68. run: |
  69. jmeter/bin/jmeter.sh \
  70. -Jjmeter.save.saveservice.output_format=xml -n \
  71. -t scripts/broker-autotest-suite/${{ matrix.scripts_type }}.jmx \
  72. -Demqx_ip=$HAPROXY_IP \
  73. -l jmeter_logs/${{ matrix.scripts_type }}.jtl \
  74. -j jmeter_logs/logs/${{ matrix.scripts_type }}.log
  75. - name: check logs
  76. run: |
  77. if cat jmeter_logs/${{ matrix.scripts_type }}.jtl | grep -e '<failure>true</failure>' > /dev/null 2>&1; then
  78. echo "check logs failed"
  79. exit 1
  80. fi
  81. - uses: actions/upload-artifact@v3
  82. if: always()
  83. with:
  84. name: jmeter_logs
  85. path: ./jmeter_logs
  86. retention-days: 3
  87. pgsql_authn_authz:
  88. runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
  89. strategy:
  90. fail-fast: false
  91. matrix:
  92. pgsql_tag:
  93. - 9
  94. - 10
  95. - 11
  96. - 12
  97. - 13
  98. scripts_type:
  99. - pgsql_authn
  100. - pgsql_authz
  101. needs: jmeter_artifact
  102. steps:
  103. - uses: actions/checkout@v3
  104. - uses: ./.github/actions/prepare-jmeter
  105. with:
  106. version-emqx: ${{ inputs.version-emqx }}
  107. - name: docker compose up
  108. timeout-minutes: 5
  109. env:
  110. PGSQL_TAG: ${{ matrix.pgsql_tag }}
  111. run: |
  112. docker compose \
  113. -f .ci/docker-compose-file/docker-compose-emqx-cluster.yaml \
  114. -f .ci/docker-compose-file/docker-compose-pgsql-tls.yaml \
  115. up --wait --build
  116. echo HAPROXY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' haproxy) >> $GITHUB_ENV
  117. echo PGSQL_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pgsql-tls) >> $GITHUB_ENV
  118. - name: run jmeter
  119. run: |
  120. jmeter/bin/jmeter.sh \
  121. -Jjmeter.save.saveservice.output_format=xml -n \
  122. -t scripts/broker-autotest-suite/${{ matrix.scripts_type }}.jmx \
  123. -Demqx_ip=$HAPROXY_IP \
  124. -Ddb_ip=$PGSQL_IP \
  125. -Dport="5432" \
  126. -Dpgsql_user="root" \
  127. -Dpgsql_pwd="public" \
  128. -Ddbname="mqtt" \
  129. -Droute="apps/emqx_auth/test/data/certs" \
  130. -Dca_name="ca.crt" \
  131. -Dkey_name="client.key" \
  132. -Dcert_name="client.crt" \
  133. -l jmeter_logs/${{ matrix.scripts_type }}_${{ matrix.pgsql_tag }}.jtl \
  134. -j jmeter_logs/logs/${{ matrix.scripts_type }}_${{ matrix.pgsql_tag }}.log
  135. - name: check logs
  136. run: |
  137. if cat jmeter_logs/${{ matrix.scripts_type }}_${{ matrix.pgsql_tag }}.jtl | grep -e '<failure>true</failure>' > /dev/null 2>&1; then
  138. echo "check logs failed"
  139. exit 1
  140. fi
  141. - name: dump docker compose logs
  142. if: failure()
  143. run: |
  144. docker compose -f .ci/docker-compose-file/docker-compose-emqx-cluster.yaml logs --no-color > ./jmeter_logs/emqx.log
  145. - uses: actions/upload-artifact@v3
  146. if: always()
  147. with:
  148. name: jmeter_logs
  149. path: ./jmeter_logs
  150. retention-days: 3
  151. mysql_authn_authz:
  152. runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
  153. strategy:
  154. fail-fast: false
  155. matrix:
  156. mysql_tag:
  157. - 5.7
  158. - 8
  159. scripts_type:
  160. - mysql_authn
  161. - mysql_authz
  162. needs: jmeter_artifact
  163. steps:
  164. - uses: actions/checkout@v3
  165. - uses: ./.github/actions/prepare-jmeter
  166. with:
  167. version-emqx: ${{ inputs.version-emqx }}
  168. - name: docker compose up
  169. timeout-minutes: 5
  170. env:
  171. PGSQL_TAG: ${{ matrix.mysql_tag }}
  172. run: |
  173. docker compose \
  174. -f .ci/docker-compose-file/docker-compose-emqx-cluster.yaml \
  175. -f .ci/docker-compose-file/docker-compose-mysql-tls.yaml \
  176. up --wait --build
  177. echo HAPROXY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' haproxy) >> $GITHUB_ENV
  178. echo MYSQL_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mysql-tls) >> $GITHUB_ENV
  179. - name: run jmeter
  180. run: |
  181. jmeter/bin/jmeter.sh \
  182. -Jjmeter.save.saveservice.output_format=xml -n \
  183. -t scripts/broker-autotest-suite/${{ matrix.scripts_type }}.jmx \
  184. -Demqx_ip=$HAPROXY_IP \
  185. -Dmysql_ip=$MYSQL_IP \
  186. -Dport="3306" \
  187. -Dmysql_user="root" \
  188. -Dmysql_pwd="public" \
  189. -Ddbname="mqtt" \
  190. -Droute="apps/emqx_auth/test/data/certs" \
  191. -Dca_name="ca.crt" \
  192. -Dkey_name="client.key" \
  193. -Dcert_name="client.crt" \
  194. -l jmeter_logs/${{ matrix.scripts_type }}_${{ matrix.mysql_tag }}.jtl \
  195. -j jmeter_logs/logs/${{ matrix.scripts_type }}_${{ matrix.mysql_tag }}.log
  196. - name: check logs
  197. run: |
  198. if cat jmeter_logs/${{ matrix.scripts_type }}_${{ matrix.mysql_tag }}.jtl | grep -e '<failure>true</failure>' > /dev/null 2>&1; then
  199. echo "check logs failed"
  200. exit 1
  201. fi
  202. - uses: actions/upload-artifact@v3
  203. if: always()
  204. with:
  205. name: jmeter_logs
  206. path: ./jmeter_logs
  207. retention-days: 3
  208. JWT_authn:
  209. runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
  210. strategy:
  211. fail-fast: false
  212. matrix:
  213. scripts_type:
  214. - jwt_authn
  215. needs: jmeter_artifact
  216. steps:
  217. - uses: actions/checkout@v3
  218. - uses: ./.github/actions/prepare-jmeter
  219. with:
  220. version-emqx: ${{ inputs.version-emqx }}
  221. - name: docker compose up
  222. timeout-minutes: 5
  223. run: |
  224. docker compose \
  225. -f .ci/docker-compose-file/docker-compose-emqx-cluster.yaml \
  226. up --wait --build
  227. echo HAPROXY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' haproxy) >> $GITHUB_ENV
  228. - name: run jwks_server
  229. timeout-minutes: 10
  230. run: |
  231. cd scripts/jwks-server
  232. mvn package
  233. cd target
  234. docker run --name jwks_server --network emqx_bridge --ip 172.100.239.88 -d -v $(pwd)/jwkserver-0.0.1.jar:/jwks_server/jwkserver-0.0.1.jar --workdir /jwks_server public.ecr.aws/amazoncorretto/amazoncorretto:8 bash \
  235. -c "java -jar jwkserver-0.0.1.jar"
  236. - name: run jmeter
  237. run: |
  238. jmeter/bin/jmeter.sh \
  239. -Jjmeter.save.saveservice.output_format=xml -n \
  240. -t scripts/broker-autotest-suite/${{ matrix.scripts_type }}.jmx \
  241. -Demqx_ip=$HAPROXY_IP \
  242. -Djwks_ip="172.100.239.88" \
  243. -l jmeter_logs/${{ matrix.scripts_type }}.jtl \
  244. -j jmeter_logs/logs/${{ matrix.scripts_type }}.log
  245. - name: check logs
  246. run: |
  247. if cat jmeter_logs/${{ matrix.scripts_type }}.jtl | grep -e '<failure>true</failure>' > /dev/null 2>&1; then
  248. echo "check logs failed"
  249. exit 1
  250. fi
  251. - uses: actions/upload-artifact@v3
  252. if: always()
  253. with:
  254. name: jmeter_logs
  255. path: ./jmeter_logs
  256. retention-days: 3
  257. built_in_database_authn_authz:
  258. runs-on: ${{ github.repository_owner == 'emqx' && fromJSON('["self-hosted","ephemeral","linux","x64"]') || 'ubuntu-22.04' }}
  259. strategy:
  260. fail-fast: false
  261. matrix:
  262. scripts_type:
  263. - built_in_database_authn
  264. - built_in_database_authz
  265. needs: jmeter_artifact
  266. steps:
  267. - uses: actions/checkout@v3
  268. - uses: ./.github/actions/prepare-jmeter
  269. with:
  270. version-emqx: ${{ inputs.version-emqx }}
  271. - name: docker compose up
  272. timeout-minutes: 5
  273. run: |
  274. docker compose \
  275. -f .ci/docker-compose-file/docker-compose-emqx-cluster.yaml \
  276. up --wait --build
  277. echo HAPROXY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' haproxy) >> $GITHUB_ENV
  278. - name: run jmeter
  279. run: |
  280. jmeter/bin/jmeter.sh \
  281. -Jjmeter.save.saveservice.output_format=xml -n \
  282. -t scripts/broker-autotest-suite/${{ matrix.scripts_type }}.jmx \
  283. -Demqx_ip=$HAPROXY_IP \
  284. -l jmeter_logs/${{ matrix.scripts_type }}.jtl \
  285. -j jmeter_logs/logs/${{ matrix.scripts_type }}.log
  286. - name: check logs
  287. run: |
  288. if cat jmeter_logs/${{ matrix.scripts_type }}.jtl | grep -e '<failure>true</failure>' > /dev/null 2>&1; then
  289. echo "check logs failed"
  290. exit 1
  291. fi
  292. - uses: actions/upload-artifact@v3
  293. if: always()
  294. with:
  295. name: jmeter_logs
  296. path: ./jmeter_logs
  297. retention-days: 3