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