run_fvt_tests.yaml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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-18: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. otp:
  46. - 24.3.4.2-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@v3
  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-18:${{ 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. - emqx-enterprise
  111. os:
  112. - ["debian11", "debian:11-slim"]
  113. otp:
  114. - 24.3.4.2-1
  115. elixir:
  116. - 1.13.4
  117. arch:
  118. - amd64
  119. # - emqx-enterprise # TODO test enterprise
  120. steps:
  121. - uses: erlef/setup-beam@v1
  122. with:
  123. otp-version: "24.2"
  124. - uses: actions/download-artifact@v3
  125. with:
  126. name: source
  127. path: .
  128. - name: unzip source code
  129. run: unzip -q source.zip
  130. - name: make docker image
  131. working-directory: source
  132. env:
  133. EMQX_BUILDER: ghcr.io/emqx/emqx-builder/5.0-18:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os[0] }}
  134. EMQX_RUNNER: ${{ matrix.os[1] }}
  135. run: |
  136. make ${{ matrix.profile }}-docker
  137. echo "TARGET=emqx/${{ matrix.profile }}" >> $GITHUB_ENV
  138. echo "EMQX_TAG=$(./pkg-vsn.sh ${{ matrix.profile }})" >> $GITHUB_ENV
  139. - run: minikube start
  140. - run: minikube image load $TARGET:$EMQX_TAG
  141. - name: run emqx on chart
  142. working-directory: source
  143. if: matrix.discovery == 'k8s'
  144. run: |
  145. helm install ${{ matrix.profile }} \
  146. --set emqxConfig.EMQX_CLUSTER__DISCOVERY_STRATEGY="k8s" \
  147. --set emqxConfig.EMQX_CLUSTER__K8S__APISERVER="https://kubernetes.default.svc:443" \
  148. --set emqxConfig.EMQX_CLUSTER__K8S__SERVICE_NAME="${{ matrix.profile }}-headless" \
  149. --set emqxConfig.EMQX_CLUSTER__K8S__NAMESPACE="default" \
  150. --set image.repository=$TARGET \
  151. --set image.pullPolicy=Never \
  152. --set image.tag=$EMQX_TAG \
  153. --set emqxAclConfig="" \
  154. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__RETRY_INTERVAL=2s \
  155. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__MAX_TOPIC_ALIAS=10 \
  156. --set emqxConfig.EMQX_AUTHORIZATION__SOURCES=[] \
  157. --set emqxConfig.EMQX_AUTHORIZATION__NO_MATCH=allow \
  158. deploy/charts/${{ matrix.profile }} \
  159. --debug
  160. - name: run emqx on chart
  161. working-directory: source
  162. if: matrix.discovery == 'dns'
  163. run: |
  164. helm install ${{ matrix.profile }} \
  165. --set emqxConfig.EMQX_CLUSTER__DISCOVERY_STRATEGY="dns" \
  166. --set emqxConfig.EMQX_CLUSTER__DNS__RECORD_TYPE="srv" \
  167. --set emqxConfig.EMQX_CLUSTER__DNS__NAME="${{ matrix.profile }}-headless.default.svc.cluster.local" \
  168. --set image.repository=$TARGET \
  169. --set image.pullPolicy=Never \
  170. --set image.tag=$EMQX_TAG \
  171. --set emqxAclConfig="" \
  172. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__RETRY_INTERVAL=2s \
  173. --set emqxConfig.EMQX_ZONES__DEFAULT__MQTT__MAX_TOPIC_ALIAS=10 \
  174. --set emqxConfig.EMQX_AUTHORIZATION__SOURCES=[] \
  175. --set emqxConfig.EMQX_AUTHORIZATION__NO_MATCH=allow \
  176. deploy/charts/${{ matrix.profile }} \
  177. --debug
  178. - name: waiting emqx started
  179. timeout-minutes: 10
  180. run: |
  181. while [ "$(kubectl get StatefulSet -l app.kubernetes.io/instance=${{ matrix.profile }} -o jsonpath='{.items[0].status.replicas}')" \
  182. != "$(kubectl get StatefulSet -l app.kubernetes.io/instance=${{ matrix.profile }} -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
  183. echo "==============================";
  184. kubectl get pods;
  185. echo "==============================";
  186. echo "waiting emqx started";
  187. sleep 10;
  188. done
  189. - name: Check cluster
  190. timeout-minutes: 10
  191. run: |
  192. kubectl port-forward service/${{ matrix.profile }} 18083:18083 > /dev/null &
  193. while
  194. [ "$(curl --silent --basic -u admin:public -X GET http://127.0.0.1:18083/api/v5/cluster| jq '.nodes|length')" != "3" ];
  195. do
  196. echo "waiting ${{ matrix.profile }} cluster scale"
  197. sleep 1
  198. done
  199. - uses: actions/checkout@v3
  200. with:
  201. repository: emqx/paho.mqtt.testing
  202. ref: develop-4.0
  203. path: paho.mqtt.testing
  204. - name: install pytest
  205. run: |
  206. pip install pytest
  207. echo "$HOME/.local/bin" >> $GITHUB_PATH
  208. - name: run paho test
  209. timeout-minutes: 10
  210. run: |
  211. port_connected () {
  212. local server="$1"
  213. local port="$2"
  214. echo > /dev/tcp/${server}/${port} 2>/dev/null
  215. }
  216. kubectl port-forward service/${{ matrix.profile }} 1883:1883 > /dev/null &
  217. while ! port_connected localhost 1883; do
  218. echo server not listening yet...
  219. sleep 10
  220. done
  221. pytest -v paho.mqtt.testing/interoperability/test_client/V5/test_connect.py -k test_basic --host "127.0.0.1"
  222. - if: failure()
  223. run: kubectl logs -l "app.kubernetes.io/instance=${{ matrix.profile }}" -c emqx --tail=1000