run_fvt_tests.yaml 6.8 KB

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