run_fvt_tests.yaml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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: make docker image
  62. working-directory: source
  63. env:
  64. EMQX_BUILDER: ghcr.io/emqx/emqx-builder/5.0-16:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os[0] }}
  65. EMQX_RUNNER: ${{ matrix.os[1] }}
  66. run: |
  67. make ${{ matrix.profile }}-docker
  68. - name: run emqx
  69. timeout-minutes: 5
  70. working-directory: source
  71. run: |
  72. set -x
  73. if [[ "${{ matrix.profile }}" = *-elixir ]]
  74. then
  75. export IS_ELIXIR=yes
  76. PROFILE=$(echo ${{ matrix.profile }} | sed -e "s/-elixir//g")
  77. IMAGE=emqx/$PROFILE:$(./pkg-vsn.sh ${{ matrix.profile }})-elixir
  78. else
  79. IMAGE=emqx/${{ matrix.profile }}:$(./pkg-vsn.sh ${{ matrix.profile }})
  80. fi
  81. ./.ci/docker-compose-file/scripts/run-emqx.sh $IMAGE ${{ matrix.cluster_db_backend }}
  82. - name: make paho tests
  83. run: |
  84. if ! docker exec -i python /scripts/pytest.sh "${{ matrix.cluster_db_backend }}"; then
  85. echo "DUMP_CONTAINER_LOGS_BGN"
  86. echo "============== haproxy =============="
  87. docker logs haproxy
  88. echo "============== node1 =============="
  89. docker logs node1.emqx.io
  90. echo "============== node2 =============="
  91. docker logs node2.emqx.io
  92. echo "DUMP_CONTAINER_LOGS_END"
  93. exit 1
  94. fi
  95. # simple smoke test for node_dump
  96. - name: test node_dump
  97. run: |
  98. docker exec node1.emqx.io node_dump
  99. helm_test:
  100. runs-on: ubuntu-20.04
  101. needs: prepare
  102. strategy:
  103. fail-fast: false
  104. matrix:
  105. discovery:
  106. - k8s
  107. - dns
  108. profile:
  109. - emqx
  110. os:
  111. - ["debian11", "debian:11-slim"]
  112. otp:
  113. - 24.2.1-1
  114. elixir:
  115. - 1.13.4
  116. arch:
  117. - amd64
  118. # - emqx-enterprise # TODO test enterprise
  119. steps:
  120. - uses: erlef/setup-beam@v1
  121. with:
  122. otp-version: "24.2"
  123. - uses: actions/download-artifact@v2
  124. with:
  125. name: source
  126. path: .
  127. - name: unzip source code
  128. run: unzip -q source.zip
  129. - name: make docker image
  130. working-directory: source
  131. env:
  132. EMQX_BUILDER: ghcr.io/emqx/emqx-builder/5.0-16:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os[0] }}
  133. EMQX_RUNNER: ${{ matrix.os[1] }}
  134. run: |
  135. make ${{ matrix.profile }}-docker
  136. echo "TARGET=emqx/${{ matrix.profile }}" >> $GITHUB_ENV
  137. echo "EMQX_TAG=$(./pkg-vsn.sh ${{ matrix.profile }})" >> $GITHUB_ENV
  138. - run: minikube start
  139. - name: setup helm chart
  140. working-directory: source
  141. run: |
  142. minikube image load $TARGET:$EMQX_TAG
  143. sed -i -r "s/^appVersion: .*$/appVersion: \"$EMQX_TAG\"/g" deploy/charts/emqx/Chart.yaml
  144. - name: run emqx on chart
  145. working-directory: source
  146. if: matrix.discovery == 'k8s'
  147. run: |
  148. helm install emqx \
  149. --set image.repository=$TARGET \
  150. --set image.pullPolicy=Never \
  151. --set emqxAclConfig="" \
  152. --set image.pullPolicy=Never \
  153. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__RETRY_INTERVAL=2s \
  154. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__MAX_TOPIC_ALIAS=10 \
  155. --set emqxConfig.EMQX_AUTHORIZATION__SOURCES=[] \
  156. --set emqxConfig.EMQX_AUTHORIZATION__NO_MATCH=allow \
  157. deploy/charts/emqx \
  158. --debug
  159. - name: run emqx on chart
  160. working-directory: source
  161. if: matrix.discovery == 'dns'
  162. run: |
  163. helm install emqx \
  164. --set emqxConfig.EMQX_CLUSTER__DISCOVERY_STRATEGY="dns" \
  165. --set emqxConfig.EMQX_CLUSTER__DNS__NAME="emqx-headless.default.svc.cluster.local" \
  166. --set emqxConfig.EMQX_CLUSTER__DNS__RECORD_TYPE="srv" \
  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. --set emqxConfig.EMQX_AUTHORIZATION__SOURCES=[] \
  174. --set emqxConfig.EMQX_AUTHORIZATION__NO_MATCH=allow \
  175. deploy/charts/emqx \
  176. --debug
  177. - name: waiting emqx started
  178. timeout-minutes: 10
  179. run: |
  180. while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.replicas}')" \
  181. != "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
  182. echo "==============================";
  183. kubectl get pods;
  184. echo "==============================";
  185. echo "waiting emqx started";
  186. sleep 10;
  187. done
  188. - name: Check cluster
  189. timeout-minutes: 10
  190. run: |
  191. kubectl port-forward svc/emqx 18083:18083 &
  192. while
  193. [ "$(curl --silent --basic -u admin:public -X GET http://127.0.0.1:18083/api/v5/cluster| jq '.nodes|length')" != "3" ];
  194. do
  195. echo "waiting emqx cluster scale"
  196. sleep 1
  197. done
  198. - name: get emqx-0 pods log
  199. if: failure()
  200. run: |
  201. kubectl describe pods emqx-0
  202. kubectl logs emqx-0
  203. - name: get emqx-1 pods log
  204. if: failure()
  205. run: |
  206. kubectl describe pods emqx-1
  207. kubectl logs emqx-1
  208. - name: get emqx-2 pods log
  209. if: failure()
  210. run: |
  211. kubectl describe pods emqx-2
  212. kubectl logs emqx-2
  213. - uses: actions/checkout@v2
  214. with:
  215. repository: emqx/paho.mqtt.testing
  216. ref: develop-4.0
  217. path: paho.mqtt.testing
  218. - name: install pytest
  219. run: |
  220. pip install pytest
  221. echo "$HOME/.local/bin" >> $GITHUB_PATH
  222. - name: run paho test
  223. run: |
  224. port_connected () {
  225. local server="$1"
  226. local port="$2"
  227. echo > /dev/tcp/${server}/${port} 2>/dev/null
  228. }
  229. kubectl port-forward service/emqx 1883:1883 > /dev/null &
  230. while ! port_connected localhost 1883; do
  231. echo server not listening yet...
  232. sleep 10
  233. done
  234. pytest -v paho.mqtt.testing/interoperability/test_client/V5/test_connect.py -k test_basic --host "127.0.0.1"