run_fvt_tests.yaml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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 rocksdb cache
  70. uses: actions/cache@v2
  71. with:
  72. path: |
  73. source/_build/default/lib/rocksdb/
  74. source/deps/rocksdb/
  75. key: ${{ matrix.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.arch }}-${{ steps.deps-refs.outputs.DEP_ROCKSDB_REF }}
  76. - name: load quicer cache
  77. uses: actions/cache@v2
  78. with:
  79. path: |
  80. source/_build/default/lib/quicer/
  81. source/deps/quicer/
  82. key: ${{ matrix.os }}-${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.arch }}-${{ steps.deps-refs.outputs.DEP_QUICER_REF }}
  83. - name: make docker image
  84. working-directory: source
  85. env:
  86. EMQX_BUILDER: ghcr.io/emqx/emqx-builder/5.0-8:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}
  87. run: |
  88. make ${{ matrix.profile }}-docker
  89. - name: run emqx
  90. timeout-minutes: 5
  91. working-directory: source
  92. run: |
  93. set -x
  94. if [[ "${{ matrix.profile }}" = *-elixir ]]
  95. then
  96. export IS_ELIXIR=yes
  97. PROFILE=$(echo ${{ matrix.profile }} | sed -e "s/-elixir//g")
  98. IMAGE=emqx/$PROFILE:$(./pkg-vsn.sh ${{ matrix.profile }})-elixir
  99. else
  100. IMAGE=emqx/${{ matrix.profile }}:$(./pkg-vsn.sh ${{ matrix.profile }})
  101. fi
  102. ./.ci/docker-compose-file/scripts/run-emqx.sh $IMAGE ${{ matrix.cluster_db_backend }}
  103. - name: make paho tests
  104. run: |
  105. if ! docker exec -i python /scripts/pytest.sh "${{ matrix.cluster_db_backend }}"; then
  106. echo "DUMP_CONTAINER_LOGS_BGN"
  107. echo "============== haproxy =============="
  108. docker logs haproxy
  109. echo "============== node1 =============="
  110. docker logs node1.emqx.io
  111. echo "============== node2 =============="
  112. docker logs node2.emqx.io
  113. echo "DUMP_CONTAINER_LOGS_END"
  114. exit 1
  115. fi
  116. helm_test:
  117. runs-on: ubuntu-20.04
  118. needs: prepare
  119. strategy:
  120. fail-fast: false
  121. matrix:
  122. profile:
  123. - emqx
  124. os:
  125. - alpine3.14
  126. otp:
  127. - 24.2.1-1
  128. elixir:
  129. - 1.13.3
  130. arch:
  131. - amd64
  132. # - emqx-enterprise # TODO test enterprise
  133. steps:
  134. - uses: actions/download-artifact@v2
  135. with:
  136. name: source
  137. path: .
  138. - name: unzip source code
  139. run: unzip -q source.zip
  140. - name: Get deps git refs for cache
  141. id: deps-refs
  142. run: |
  143. cd source
  144. make ensure-rebar3
  145. sudo cp rebar3 /usr/local/bin/rebar3
  146. scripts/get-dep-refs.sh
  147. - name: load rocksdb cache
  148. uses: actions/cache@v2
  149. with:
  150. path: source/_build/default/lib/rocksdb/
  151. key: ${{ matrix.os }}-${{ matrix.otp }}-${{ matrix.arch }}-${{ steps.deps-refs.outputs.DEP_ROCKSDB_REF }}
  152. - name: load quicer cache
  153. uses: actions/cache@v2
  154. with:
  155. path: source/_build/default/lib/quicer/
  156. key: ${{ matrix.os }}-${{ matrix.otp }}-${{ matrix.arch }}-${{ steps.deps-refs.outputs.DEP_QUICER_REF }}
  157. - name: make docker image
  158. working-directory: source
  159. env:
  160. EMQX_BUILDER: ghcr.io/emqx/emqx-builder/5.0-8:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os }}
  161. run: |
  162. make ${{ matrix.profile }}-docker
  163. echo "TARGET=emqx/${{ matrix.profile }}" >> $GITHUB_ENV
  164. echo "EMQX_TAG=$(./pkg-vsn.sh ${{ matrix.profile }})" >> $GITHUB_ENV
  165. - run: minikube start
  166. - name: run emqx on chart
  167. timeout-minutes: 5
  168. working-directory: source
  169. run: |
  170. minikube image load $TARGET:$EMQX_TAG
  171. sed -i -r "s/^appVersion: .*$/appVersion: \"$EMQX_TAG\"/g" deploy/charts/emqx/Chart.yaml
  172. helm install emqx \
  173. --set image.repository=$TARGET \
  174. --set image.pullPolicy=Never \
  175. --set emqxAclConfig="" \
  176. --set image.pullPolicy=Never \
  177. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__RETRY_INTERVAL=2s \
  178. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__MAX_TOPIC_ALIAS=10 \
  179. deploy/charts/emqx \
  180. --debug
  181. while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.replicas}')" \
  182. != "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
  183. echo "==============================";
  184. kubectl get pods;
  185. echo "==============================";
  186. echo "waiting emqx started";
  187. sleep 10;
  188. done
  189. - name: get emqx-0 pods log
  190. if: failure()
  191. run: |
  192. kubectl describe pods emqx-0
  193. kubectl logs emqx-0
  194. - name: get emqx-1 pods log
  195. if: failure()
  196. run: |
  197. kubectl describe pods emqx-1
  198. kubectl logs emqx-1
  199. - name: get emqx-2 pods log
  200. if: failure()
  201. run: |
  202. kubectl describe pods emqx-2
  203. kubectl logs emqx-2
  204. - uses: actions/checkout@v2
  205. with:
  206. repository: emqx/paho.mqtt.testing
  207. ref: develop-4.0
  208. path: paho.mqtt.testing
  209. - name: install pytest
  210. run: |
  211. pip install pytest
  212. echo "$HOME/.local/bin" >> $GITHUB_PATH
  213. - name: run paho test
  214. run: |
  215. port_connected () {
  216. local server="$1"
  217. local port="$2"
  218. echo > /dev/tcp/${server}/${port} 2>/dev/null
  219. }
  220. kubectl port-forward service/emqx 1883:1883 > /dev/null &
  221. while ! port_connected localhost 1883; do
  222. echo server not listening yet...
  223. sleep 10
  224. done
  225. pytest -v paho.mqtt.testing/interoperability/test_client/V5/test_connect.py -k test_basic --host "127.0.0.1"