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-15:1.13.3-24.2.1-1-alpine3.15.1
  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-enterprise
  39. - emqx-elixir
  40. cluster_db_backend:
  41. - mnesia
  42. - rlog
  43. os:
  44. - alpine3.15.1
  45. otp:
  46. - 24.2.1-1
  47. elixir:
  48. - 1.13.3
  49. arch:
  50. - amd64
  51. steps:
  52. - uses: actions/download-artifact@v2
  53. with:
  54. name: source
  55. path: .
  56. - name: unzip source code
  57. run: unzip -q source.zip
  58. - name: Get deps git refs for cache
  59. id: deps-refs
  60. run: |
  61. cd source
  62. make ensure-rebar3
  63. sudo cp rebar3 /usr/local/bin/rebar3
  64. scripts/get-dep-refs.sh
  65. - name: load quicer cache
  66. uses: actions/cache@v2
  67. with:
  68. path: |
  69. source/_build/default/lib/quicer/
  70. source/deps/quicer/
  71. key: ${{ matrix.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.arch }}-${{ steps.deps-refs.outputs.DEP_QUICER_REF }}
  72. - name: make docker image
  73. working-directory: source
  74. env:
  75. EMQX_BUILDER: ghcr.io/emqx/emqx-builder/5.0-15:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}
  76. run: |
  77. make ${{ matrix.profile }}-docker
  78. - name: run emqx
  79. timeout-minutes: 5
  80. working-directory: source
  81. run: |
  82. set -x
  83. if [[ "${{ matrix.profile }}" = *-elixir ]]
  84. then
  85. export IS_ELIXIR=yes
  86. PROFILE=$(echo ${{ matrix.profile }} | sed -e "s/-elixir//g")
  87. IMAGE=emqx/$PROFILE:$(./pkg-vsn.sh ${{ matrix.profile }})-elixir
  88. else
  89. IMAGE=emqx/${{ matrix.profile }}:$(./pkg-vsn.sh ${{ matrix.profile }})
  90. fi
  91. ./.ci/docker-compose-file/scripts/run-emqx.sh $IMAGE ${{ matrix.cluster_db_backend }}
  92. - name: make paho tests
  93. run: |
  94. if ! docker exec -i python /scripts/pytest.sh "${{ matrix.cluster_db_backend }}"; then
  95. echo "DUMP_CONTAINER_LOGS_BGN"
  96. echo "============== haproxy =============="
  97. docker logs haproxy
  98. echo "============== node1 =============="
  99. docker logs node1.emqx.io
  100. echo "============== node2 =============="
  101. docker logs node2.emqx.io
  102. echo "DUMP_CONTAINER_LOGS_END"
  103. exit 1
  104. fi
  105. # simple smoke test for node_dump
  106. - name: test node_dump
  107. run: |
  108. docker exec node1.emqx.io node_dump
  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.15.1
  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-15:${{ 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"