run_fvt_tests.yaml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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-17: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-17:${{ 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-17:${{ 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 emqxConfig.EMQX_CLUSTER__DISCOVERY_STRATEGY="k8s" \
  150. --set emqxConfig.EMQX_CLUSTER__K8S__APISERVER="https://kubernetes.default.svc:443" \
  151. --set emqxConfig.EMQX_CLUSTER__K8S__SERVICE_NAME="emqx-headless" \
  152. --set emqxConfig.EMQX_CLUSTER__K8S__NAMESPACE="default" \
  153. --set image.repository=$TARGET \
  154. --set image.pullPolicy=Never \
  155. --set emqxAclConfig="" \
  156. --set image.pullPolicy=Never \
  157. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__RETRY_INTERVAL=2s \
  158. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__MAX_TOPIC_ALIAS=10 \
  159. --set emqxConfig.EMQX_AUTHORIZATION__SOURCES=[] \
  160. --set emqxConfig.EMQX_AUTHORIZATION__NO_MATCH=allow \
  161. deploy/charts/emqx \
  162. --debug
  163. - name: run emqx on chart
  164. working-directory: source
  165. if: matrix.discovery == 'dns'
  166. run: |
  167. helm install emqx \
  168. --set emqxConfig.EMQX_CLUSTER__DISCOVERY_STRATEGY="dns" \
  169. --set emqxConfig.EMQX_CLUSTER__DNS__RECORD_TYPE="srv" \
  170. --set emqxConfig.EMQX_CLUSTER__DNS__NAME="emqx-headless.default.svc.cluster.local" \
  171. --set image.repository=$TARGET \
  172. --set image.pullPolicy=Never \
  173. --set emqxAclConfig="" \
  174. --set image.pullPolicy=Never \
  175. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__RETRY_INTERVAL=2s \
  176. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__MAX_TOPIC_ALIAS=10 \
  177. --set emqxConfig.EMQX_AUTHORIZATION__SOURCES=[] \
  178. --set emqxConfig.EMQX_AUTHORIZATION__NO_MATCH=allow \
  179. deploy/charts/emqx \
  180. --debug
  181. - name: waiting emqx started
  182. timeout-minutes: 10
  183. run: |
  184. while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.replicas}')" \
  185. != "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
  186. echo "==============================";
  187. kubectl get pods;
  188. echo "==============================";
  189. echo "waiting emqx started";
  190. sleep 10;
  191. done
  192. - name: Check cluster
  193. timeout-minutes: 10
  194. run: |
  195. kubectl port-forward svc/emqx 18083:18083 &
  196. while
  197. [ "$(curl --silent --basic -u admin:public -X GET http://127.0.0.1:18083/api/v5/cluster| jq '.nodes|length')" != "3" ];
  198. do
  199. echo "waiting emqx cluster scale"
  200. sleep 1
  201. done
  202. - name: get emqx-0 pods log
  203. if: failure()
  204. run: |
  205. kubectl describe pods emqx-0
  206. kubectl logs emqx-0
  207. - name: get emqx-1 pods log
  208. if: failure()
  209. run: |
  210. kubectl describe pods emqx-1
  211. kubectl logs emqx-1
  212. - name: get emqx-2 pods log
  213. if: failure()
  214. run: |
  215. kubectl describe pods emqx-2
  216. kubectl logs emqx-2
  217. - uses: actions/checkout@v2
  218. with:
  219. repository: emqx/paho.mqtt.testing
  220. ref: develop-4.0
  221. path: paho.mqtt.testing
  222. - name: install pytest
  223. run: |
  224. pip install pytest
  225. echo "$HOME/.local/bin" >> $GITHUB_PATH
  226. - name: run paho test
  227. run: |
  228. port_connected () {
  229. local server="$1"
  230. local port="$2"
  231. echo > /dev/tcp/${server}/${port} 2>/dev/null
  232. }
  233. kubectl port-forward service/emqx 1883:1883 > /dev/null &
  234. while ! port_connected localhost 1883; do
  235. echo server not listening yet...
  236. sleep 10
  237. done
  238. pytest -v paho.mqtt.testing/interoperability/test_client/V5/test_connect.py -k test_basic --host "127.0.0.1"