run_fvt_tests.yaml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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-10: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-edge
  39. - emqx-enterprise
  40. - emqx-elixir
  41. cluster_db_backend:
  42. - mnesia
  43. - rlog
  44. os:
  45. - alpine3.15.1
  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-10:${{ 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. # simple smoke test for node_dump
  110. - name: test node_dump
  111. run: |
  112. docker exec node1.emqx.io node_dump
  113. helm_test:
  114. runs-on: ubuntu-20.04
  115. needs: prepare
  116. strategy:
  117. fail-fast: false
  118. matrix:
  119. profile:
  120. - emqx
  121. os:
  122. - alpine3.15.1
  123. otp:
  124. - 24.2.1-1
  125. elixir:
  126. - 1.13.3
  127. arch:
  128. - amd64
  129. # - emqx-enterprise # TODO test enterprise
  130. steps:
  131. - uses: actions/download-artifact@v2
  132. with:
  133. name: source
  134. path: .
  135. - name: unzip source code
  136. run: unzip -q source.zip
  137. - name: Get deps git refs for cache
  138. id: deps-refs
  139. run: |
  140. cd source
  141. make ensure-rebar3
  142. sudo cp rebar3 /usr/local/bin/rebar3
  143. scripts/get-dep-refs.sh
  144. - name: load quicer cache
  145. uses: actions/cache@v2
  146. with:
  147. path: source/_build/default/lib/quicer/
  148. key: ${{ matrix.os }}-${{ matrix.otp }}-${{ matrix.arch }}-${{ steps.deps-refs.outputs.DEP_QUICER_REF }}
  149. - name: make docker image
  150. working-directory: source
  151. env:
  152. EMQX_BUILDER: ghcr.io/emqx/emqx-builder/5.0-10:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}
  153. run: |
  154. make ${{ matrix.profile }}-docker
  155. echo "TARGET=emqx/${{ matrix.profile }}" >> $GITHUB_ENV
  156. echo "EMQX_TAG=$(./pkg-vsn.sh ${{ matrix.profile }})" >> $GITHUB_ENV
  157. - run: minikube start
  158. - name: run emqx on chart
  159. timeout-minutes: 5
  160. working-directory: source
  161. run: |
  162. minikube image load $TARGET:$EMQX_TAG
  163. sed -i -r "s/^appVersion: .*$/appVersion: \"$EMQX_TAG\"/g" deploy/charts/emqx/Chart.yaml
  164. helm install emqx \
  165. --set image.repository=$TARGET \
  166. --set image.pullPolicy=Never \
  167. --set emqxAclConfig="" \
  168. --set image.pullPolicy=Never \
  169. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__RETRY_INTERVAL=2s \
  170. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__MAX_TOPIC_ALIAS=10 \
  171. deploy/charts/emqx \
  172. --debug
  173. while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.replicas}')" \
  174. != "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
  175. echo "==============================";
  176. kubectl get pods;
  177. echo "==============================";
  178. echo "waiting emqx started";
  179. sleep 10;
  180. done
  181. - name: get emqx-0 pods log
  182. if: failure()
  183. run: |
  184. kubectl describe pods emqx-0
  185. kubectl logs emqx-0
  186. - name: get emqx-1 pods log
  187. if: failure()
  188. run: |
  189. kubectl describe pods emqx-1
  190. kubectl logs emqx-1
  191. - name: get emqx-2 pods log
  192. if: failure()
  193. run: |
  194. kubectl describe pods emqx-2
  195. kubectl logs emqx-2
  196. - uses: actions/checkout@v2
  197. with:
  198. repository: emqx/paho.mqtt.testing
  199. ref: develop-4.0
  200. path: paho.mqtt.testing
  201. - name: install pytest
  202. run: |
  203. pip install pytest
  204. echo "$HOME/.local/bin" >> $GITHUB_PATH
  205. - name: run paho test
  206. run: |
  207. port_connected () {
  208. local server="$1"
  209. local port="$2"
  210. echo > /dev/tcp/${server}/${port} 2>/dev/null
  211. }
  212. kubectl port-forward service/emqx 1883:1883 > /dev/null &
  213. while ! port_connected localhost 1883; do
  214. echo server not listening yet...
  215. sleep 10
  216. done
  217. pytest -v paho.mqtt.testing/interoperability/test_client/V5/test_connect.py -k test_basic --host "127.0.0.1"