run_fvt_tests.yaml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. name: Functional Verification Tests
  2. concurrency:
  3. group: fvt-${{ github.event_name }}-${{ github.ref }}
  4. cancel-in-progress: true
  5. on:
  6. push:
  7. branches:
  8. - '**'
  9. tags:
  10. - v*
  11. pull_request:
  12. jobs:
  13. prepare:
  14. runs-on: ubuntu-20.04
  15. # prepare source with any OTP version, no need for a matrix
  16. container: ghcr.io/emqx/emqx-builder/5.0-8:1.13.3-24.2.1-1-alpine3.14
  17. steps:
  18. - uses: actions/checkout@v2
  19. with:
  20. path: source
  21. fetch-depth: 0
  22. - name: get deps
  23. run: |
  24. make -C source deps-all
  25. zip -ryq source.zip source/* source/.[^.]*
  26. - uses: actions/upload-artifact@v2
  27. with:
  28. name: source
  29. path: source.zip
  30. docker_test:
  31. runs-on: ubuntu-20.04
  32. needs: prepare
  33. strategy:
  34. fail-fast: false
  35. matrix:
  36. profile:
  37. - emqx
  38. - emqx-edge
  39. - emqx-enterprise
  40. - emqx-elixir
  41. cluster_db_backend:
  42. - mnesia
  43. - rlog
  44. os:
  45. - alpine3.14
  46. otp:
  47. - 24.2.1-1
  48. elixir:
  49. - 1.13.3
  50. arch:
  51. - amd64
  52. exclude:
  53. - profile: emqx-edge
  54. cluster_db_backend: rlog
  55. steps:
  56. - uses: actions/download-artifact@v2
  57. with:
  58. name: source
  59. path: .
  60. - name: unzip source code
  61. run: unzip -q source.zip
  62. - name: Get deps git refs for cache
  63. id: deps-refs
  64. run: |
  65. cd source
  66. make ensure-rebar3
  67. sudo cp rebar3 /usr/local/bin/rebar3
  68. scripts/get-dep-refs.sh
  69. - name: load quicer cache
  70. uses: actions/cache@v2
  71. with:
  72. path: |
  73. source/_build/default/lib/quicer/
  74. source/deps/quicer/
  75. key: ${{ matrix.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.arch }}-${{ steps.deps-refs.outputs.DEP_QUICER_REF }}
  76. - name: make docker image
  77. working-directory: source
  78. env:
  79. EMQX_BUILDER: ghcr.io/emqx/emqx-builder/5.0-8:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}
  80. run: |
  81. make ${{ matrix.profile }}-docker
  82. - name: run emqx
  83. timeout-minutes: 5
  84. working-directory: source
  85. run: |
  86. set -x
  87. if [[ "${{ matrix.profile }}" = *-elixir ]]
  88. then
  89. export IS_ELIXIR=yes
  90. PROFILE=$(echo ${{ matrix.profile }} | sed -e "s/-elixir//g")
  91. IMAGE=emqx/$PROFILE:$(./pkg-vsn.sh ${{ matrix.profile }})-elixir
  92. else
  93. IMAGE=emqx/${{ matrix.profile }}:$(./pkg-vsn.sh ${{ matrix.profile }})
  94. fi
  95. ./.ci/docker-compose-file/scripts/run-emqx.sh $IMAGE ${{ matrix.cluster_db_backend }}
  96. - name: make paho tests
  97. run: |
  98. if ! docker exec -i python /scripts/pytest.sh "${{ matrix.cluster_db_backend }}"; then
  99. echo "DUMP_CONTAINER_LOGS_BGN"
  100. echo "============== haproxy =============="
  101. docker logs haproxy
  102. echo "============== node1 =============="
  103. docker logs node1.emqx.io
  104. echo "============== node2 =============="
  105. docker logs node2.emqx.io
  106. echo "DUMP_CONTAINER_LOGS_END"
  107. exit 1
  108. fi
  109. helm_test:
  110. runs-on: ubuntu-20.04
  111. needs: prepare
  112. strategy:
  113. fail-fast: false
  114. matrix:
  115. profile:
  116. - emqx
  117. os:
  118. - alpine3.14
  119. otp:
  120. - 24.2.1-1
  121. elixir:
  122. - 1.13.3
  123. arch:
  124. - amd64
  125. # - emqx-enterprise # TODO test enterprise
  126. steps:
  127. - uses: actions/download-artifact@v2
  128. with:
  129. name: source
  130. path: .
  131. - name: unzip source code
  132. run: unzip -q source.zip
  133. - name: Get deps git refs for cache
  134. id: deps-refs
  135. run: |
  136. cd source
  137. make ensure-rebar3
  138. sudo cp rebar3 /usr/local/bin/rebar3
  139. scripts/get-dep-refs.sh
  140. - name: load quicer cache
  141. uses: actions/cache@v2
  142. with:
  143. path: source/_build/default/lib/quicer/
  144. key: ${{ matrix.os }}-${{ matrix.otp }}-${{ matrix.arch }}-${{ steps.deps-refs.outputs.DEP_QUICER_REF }}
  145. - name: make docker image
  146. working-directory: source
  147. env:
  148. EMQX_BUILDER: ghcr.io/emqx/emqx-builder/5.0-8:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}
  149. run: |
  150. make ${{ matrix.profile }}-docker
  151. echo "TARGET=emqx/${{ matrix.profile }}" >> $GITHUB_ENV
  152. echo "EMQX_TAG=$(./pkg-vsn.sh ${{ matrix.profile }})" >> $GITHUB_ENV
  153. - run: minikube start
  154. - name: run emqx on chart
  155. timeout-minutes: 5
  156. working-directory: source
  157. run: |
  158. minikube image load $TARGET:$EMQX_TAG
  159. sed -i -r "s/^appVersion: .*$/appVersion: \"$EMQX_TAG\"/g" deploy/charts/emqx/Chart.yaml
  160. helm install emqx \
  161. --set image.repository=$TARGET \
  162. --set image.pullPolicy=Never \
  163. --set emqxAclConfig="" \
  164. --set image.pullPolicy=Never \
  165. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__RETRY_INTERVAL=2s \
  166. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__MAX_TOPIC_ALIAS=10 \
  167. deploy/charts/emqx \
  168. --debug
  169. while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.replicas}')" \
  170. != "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
  171. echo "==============================";
  172. kubectl get pods;
  173. echo "==============================";
  174. echo "waiting emqx started";
  175. sleep 10;
  176. done
  177. - name: get emqx-0 pods log
  178. if: failure()
  179. run: |
  180. kubectl describe pods emqx-0
  181. kubectl logs emqx-0
  182. - name: get emqx-1 pods log
  183. if: failure()
  184. run: |
  185. kubectl describe pods emqx-1
  186. kubectl logs emqx-1
  187. - name: get emqx-2 pods log
  188. if: failure()
  189. run: |
  190. kubectl describe pods emqx-2
  191. kubectl logs emqx-2
  192. - uses: actions/checkout@v2
  193. with:
  194. repository: emqx/paho.mqtt.testing
  195. ref: develop-4.0
  196. path: paho.mqtt.testing
  197. - name: install pytest
  198. run: |
  199. pip install pytest
  200. echo "$HOME/.local/bin" >> $GITHUB_PATH
  201. - name: run paho test
  202. run: |
  203. port_connected () {
  204. local server="$1"
  205. local port="$2"
  206. echo > /dev/tcp/${server}/${port} 2>/dev/null
  207. }
  208. kubectl port-forward service/emqx 1883:1883 > /dev/null &
  209. while ! port_connected localhost 1883; do
  210. echo server not listening yet...
  211. sleep 10
  212. done
  213. pytest -v paho.mqtt.testing/interoperability/test_client/V5/test_connect.py -k test_basic --host "127.0.0.1"