run_fvt_tests.yaml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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-16:1.13.4-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", "alpine:3.15.1"]
  45. otp:
  46. - 24.2.1-1
  47. elixir:
  48. - 1.13.4
  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[0] }}-${{ 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-16:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os[0] }}
  79. EMQX_RUNNER: ${{ matrix.os[1] }}
  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. - ["debian11", "debian:11-slim"]
  123. otp:
  124. - 24.2.1-1
  125. elixir:
  126. - 1.13.4
  127. arch:
  128. - amd64
  129. # - emqx-enterprise # TODO test enterprise
  130. steps:
  131. - uses: erlef/setup-beam@v1
  132. with:
  133. otp-version: "24.2"
  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 quicer cache
  148. uses: actions/cache@v2
  149. with:
  150. path: source/_build/default/lib/quicer/
  151. key: ${{ matrix.os[0] }}-${{ matrix.otp }}-${{ matrix.arch }}-${{ steps.deps-refs.outputs.DEP_QUICER_REF }}
  152. - name: make docker image
  153. working-directory: source
  154. env:
  155. EMQX_BUILDER: ghcr.io/emqx/emqx-builder/5.0-16:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os[0] }}
  156. EMQX_RUNNER: ${{ matrix.os[1] }}
  157. run: |
  158. make ${{ matrix.profile }}-docker
  159. echo "TARGET=emqx/${{ matrix.profile }}" >> $GITHUB_ENV
  160. echo "EMQX_TAG=$(./pkg-vsn.sh ${{ matrix.profile }})" >> $GITHUB_ENV
  161. - run: minikube start
  162. - name: run emqx on chart
  163. timeout-minutes: 5
  164. working-directory: source
  165. run: |
  166. minikube image load $TARGET:$EMQX_TAG
  167. sed -i -r "s/^appVersion: .*$/appVersion: \"$EMQX_TAG\"/g" deploy/charts/emqx/Chart.yaml
  168. helm install emqx \
  169. --set image.repository=$TARGET \
  170. --set image.pullPolicy=Never \
  171. --set emqxAclConfig="" \
  172. --set image.pullPolicy=Never \
  173. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__RETRY_INTERVAL=2s \
  174. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__MAX_TOPIC_ALIAS=10 \
  175. --set emqxConfig.EMQX_AUTHORIZATION__SOURCES=[] \
  176. --set emqxConfig.EMQX_AUTHORIZATION__NO_MATCH=allow \
  177. deploy/charts/emqx \
  178. --debug
  179. while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.replicas}')" \
  180. != "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
  181. echo "==============================";
  182. kubectl get pods;
  183. echo "==============================";
  184. echo "waiting emqx started";
  185. sleep 10;
  186. done
  187. - name: get emqx-0 pods log
  188. if: failure()
  189. run: |
  190. kubectl describe pods emqx-0
  191. kubectl logs emqx-0
  192. - name: get emqx-1 pods log
  193. if: failure()
  194. run: |
  195. kubectl describe pods emqx-1
  196. kubectl logs emqx-1
  197. - name: get emqx-2 pods log
  198. if: failure()
  199. run: |
  200. kubectl describe pods emqx-2
  201. kubectl logs emqx-2
  202. - uses: actions/checkout@v2
  203. with:
  204. repository: emqx/paho.mqtt.testing
  205. ref: develop-4.0
  206. path: paho.mqtt.testing
  207. - name: install pytest
  208. run: |
  209. pip install pytest
  210. echo "$HOME/.local/bin" >> $GITHUB_PATH
  211. - name: run paho test
  212. run: |
  213. port_connected () {
  214. local server="$1"
  215. local port="$2"
  216. echo > /dev/tcp/${server}/${port} 2>/dev/null
  217. }
  218. kubectl port-forward service/emqx 1883:1883 > /dev/null &
  219. while ! port_connected localhost 1883; do
  220. echo server not listening yet...
  221. sleep 10
  222. done
  223. pytest -v paho.mqtt.testing/interoperability/test_client/V5/test_connect.py -k test_basic --host "127.0.0.1"