run_fvt_tests.yaml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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. discovery:
  120. - k8s
  121. - dns
  122. profile:
  123. - emqx
  124. os:
  125. - ["debian11", "debian:11-slim"]
  126. otp:
  127. - 24.2.1-1
  128. elixir:
  129. - 1.13.4
  130. arch:
  131. - amd64
  132. # - emqx-enterprise # TODO test enterprise
  133. steps:
  134. - uses: erlef/setup-beam@v1
  135. with:
  136. otp-version: "24.2"
  137. - uses: actions/download-artifact@v2
  138. with:
  139. name: source
  140. path: .
  141. - name: unzip source code
  142. run: unzip -q source.zip
  143. - name: Get deps git refs for cache
  144. id: deps-refs
  145. run: |
  146. cd source
  147. make ensure-rebar3
  148. sudo cp rebar3 /usr/local/bin/rebar3
  149. scripts/get-dep-refs.sh
  150. - name: load quicer cache
  151. uses: actions/cache@v2
  152. with:
  153. path: source/_build/default/lib/quicer/
  154. key: ${{ matrix.os[0] }}-${{ matrix.otp }}-${{ matrix.arch }}-${{ steps.deps-refs.outputs.DEP_QUICER_REF }}
  155. - name: make docker image
  156. working-directory: source
  157. env:
  158. EMQX_BUILDER: ghcr.io/emqx/emqx-builder/5.0-16:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os[0] }}
  159. EMQX_RUNNER: ${{ matrix.os[1] }}
  160. run: |
  161. make ${{ matrix.profile }}-docker
  162. echo "TARGET=emqx/${{ matrix.profile }}" >> $GITHUB_ENV
  163. echo "EMQX_TAG=$(./pkg-vsn.sh ${{ matrix.profile }})" >> $GITHUB_ENV
  164. - run: minikube start
  165. - name: setup helm chart
  166. working-directory: source
  167. run: |
  168. minikube image load $TARGET:$EMQX_TAG
  169. sed -i -r "s/^appVersion: .*$/appVersion: \"$EMQX_TAG\"/g" deploy/charts/emqx/Chart.yaml
  170. - name: run emqx on chart
  171. working-directory: source
  172. if: matrix.discovery == 'k8s'
  173. run: |
  174. helm install emqx \
  175. --set image.repository=$TARGET \
  176. --set image.pullPolicy=Never \
  177. --set emqxAclConfig="" \
  178. --set image.pullPolicy=Never \
  179. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__RETRY_INTERVAL=2s \
  180. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__MAX_TOPIC_ALIAS=10 \
  181. --set emqxConfig.EMQX_AUTHORIZATION__SOURCES=[] \
  182. --set emqxConfig.EMQX_AUTHORIZATION__NO_MATCH=allow \
  183. deploy/charts/emqx \
  184. --debug
  185. - name: run emqx on chart
  186. working-directory: source
  187. if: matrix.discovery == 'dns'
  188. run: |
  189. helm install emqx \
  190. --set emqxConfig.EMQX_CLUSTER__DISCOVERY_STRATEGY="dns" \
  191. --set emqxConfig.EMQX_CLUSTER__DNS__NAME="emqx-headless.default.svc.cluster.local" \
  192. --set emqxConfig.EMQX_CLUSTER__DNS__RECORD_TYPE="srv" \
  193. --set image.repository=$TARGET \
  194. --set image.pullPolicy=Never \
  195. --set emqxAclConfig="" \
  196. --set image.pullPolicy=Never \
  197. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__RETRY_INTERVAL=2s \
  198. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__MAX_TOPIC_ALIAS=10 \
  199. --set emqxConfig.EMQX_AUTHORIZATION__SOURCES=[] \
  200. --set emqxConfig.EMQX_AUTHORIZATION__NO_MATCH=allow \
  201. deploy/charts/emqx \
  202. --debug
  203. - name: waiting emqx started
  204. timeout-minutes: 10
  205. run: |
  206. while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.replicas}')" \
  207. != "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
  208. echo "==============================";
  209. kubectl get pods;
  210. echo "==============================";
  211. echo "waiting emqx started";
  212. sleep 10;
  213. done
  214. - name: Check cluster
  215. timeout-minutes: 10
  216. run: |
  217. kubectl port-forward svc/emqx 18083:18083 &
  218. while
  219. [ "$(curl --silent --basic -u admin:public -X GET http://127.0.0.1:18083/api/v5/cluster| jq '.nodes|length')" != "3" ];
  220. do
  221. echo "waiting emqx cluster scale"
  222. sleep 1
  223. done
  224. - name: get emqx-0 pods log
  225. if: failure()
  226. run: |
  227. kubectl describe pods emqx-0
  228. kubectl logs emqx-0
  229. - name: get emqx-1 pods log
  230. if: failure()
  231. run: |
  232. kubectl describe pods emqx-1
  233. kubectl logs emqx-1
  234. - name: get emqx-2 pods log
  235. if: failure()
  236. run: |
  237. kubectl describe pods emqx-2
  238. kubectl logs emqx-2
  239. - uses: actions/checkout@v2
  240. with:
  241. repository: emqx/paho.mqtt.testing
  242. ref: develop-4.0
  243. path: paho.mqtt.testing
  244. - name: install pytest
  245. run: |
  246. pip install pytest
  247. echo "$HOME/.local/bin" >> $GITHUB_PATH
  248. - name: run paho test
  249. run: |
  250. port_connected () {
  251. local server="$1"
  252. local port="$2"
  253. echo > /dev/tcp/${server}/${port} 2>/dev/null
  254. }
  255. kubectl port-forward service/emqx 1883:1883 > /dev/null &
  256. while ! port_connected localhost 1883; do
  257. echo server not listening yet...
  258. sleep 10
  259. done
  260. pytest -v paho.mqtt.testing/interoperability/test_client/V5/test_connect.py -k test_basic --host "127.0.0.1"