run_fvt_tests.yaml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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. - master
  9. - 'ci/**'
  10. tags:
  11. - v*
  12. pull_request:
  13. jobs:
  14. prepare:
  15. runs-on: ubuntu-22.04
  16. # prepare source with any OTP version, no need for a matrix
  17. container: ghcr.io/emqx/emqx-builder/5.1-0:1.14.5-25.3.2-1-debian11
  18. steps:
  19. - uses: actions/checkout@v3
  20. with:
  21. path: source
  22. fetch-depth: 0
  23. - name: get deps
  24. run: |
  25. make -C source deps-all
  26. zip -ryq source.zip source/* source/.[^.]*
  27. - uses: actions/upload-artifact@v3
  28. with:
  29. name: source
  30. path: source.zip
  31. docker_test:
  32. runs-on: ubuntu-22.04
  33. needs: prepare
  34. strategy:
  35. fail-fast: false
  36. matrix:
  37. profile:
  38. - emqx
  39. - emqx-enterprise
  40. - emqx-elixir
  41. cluster_db_backend:
  42. - mnesia
  43. - rlog
  44. os:
  45. - ["debian11", "debian:11-slim"]
  46. builder:
  47. - 5.1-0
  48. otp:
  49. - 25.3.2-1
  50. elixir:
  51. - 1.14.5
  52. arch:
  53. - amd64
  54. steps:
  55. - uses: erlef/setup-beam@v1.15.4
  56. with:
  57. otp-version: 25.3.2
  58. - uses: actions/download-artifact@v3
  59. with:
  60. name: source
  61. path: .
  62. - name: unzip source code
  63. run: unzip -q source.zip
  64. - name: make docker image
  65. working-directory: source
  66. env:
  67. EMQX_BUILDER: ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os[0] }}
  68. EMQX_RUNNER: ${{ matrix.os[1] }}
  69. run: |
  70. make ${{ matrix.profile }}-docker
  71. - name: run emqx
  72. timeout-minutes: 5
  73. working-directory: source
  74. run: |
  75. set -x
  76. if [[ "${{ matrix.profile }}" = *-elixir ]]
  77. then
  78. export IS_ELIXIR=yes
  79. PROFILE=$(echo ${{ matrix.profile }} | sed -e "s/-elixir//g")
  80. IMAGE=emqx/$PROFILE:$(./pkg-vsn.sh ${{ matrix.profile }})-elixir
  81. else
  82. IMAGE=emqx/${{ matrix.profile }}:$(./pkg-vsn.sh ${{ matrix.profile }})
  83. fi
  84. ./.ci/docker-compose-file/scripts/run-emqx.sh $IMAGE ${{ matrix.cluster_db_backend }}
  85. - name: make paho tests
  86. run: |
  87. if ! docker exec -i python /scripts/pytest.sh "${{ matrix.cluster_db_backend }}"; then
  88. echo "DUMP_CONTAINER_LOGS_BGN"
  89. echo "============== haproxy =============="
  90. docker logs haproxy
  91. echo "============== node1 =============="
  92. docker logs node1.emqx.io
  93. echo "============== node2 =============="
  94. docker logs node2.emqx.io
  95. echo "DUMP_CONTAINER_LOGS_END"
  96. exit 1
  97. fi
  98. # simple smoke test for node_dump
  99. - name: test node_dump
  100. run: |
  101. docker exec node1.emqx.io node_dump
  102. helm_test:
  103. runs-on: ubuntu-22.04
  104. needs: prepare
  105. strategy:
  106. fail-fast: false
  107. matrix:
  108. discovery:
  109. - k8s
  110. - dns
  111. profile:
  112. - emqx
  113. - emqx-enterprise
  114. os:
  115. - ["debian11", "debian:11-slim"]
  116. builder:
  117. - 5.1-0
  118. otp:
  119. - 25.3.2-1
  120. elixir:
  121. - 1.14.5
  122. arch:
  123. - amd64
  124. # - emqx-enterprise # TODO test enterprise
  125. steps:
  126. - uses: erlef/setup-beam@v1.15.4
  127. with:
  128. otp-version: 25.3.2
  129. - uses: actions/download-artifact@v3
  130. with:
  131. name: source
  132. path: .
  133. - name: unzip source code
  134. run: unzip -q source.zip
  135. - name: make docker image
  136. working-directory: source
  137. env:
  138. EMQX_BUILDER: ghcr.io/emqx/emqx-builder/${{ matrix.builder }}:${{ matrix.elixir }}-${{ matrix.otp }}-${{ matrix.os[0] }}
  139. EMQX_RUNNER: ${{ matrix.os[1] }}
  140. run: |
  141. make ${{ matrix.profile }}-docker
  142. echo "TARGET=emqx/${{ matrix.profile }}" >> $GITHUB_ENV
  143. echo "EMQX_TAG=$(./pkg-vsn.sh ${{ matrix.profile }})" >> $GITHUB_ENV
  144. - run: minikube start
  145. - run: minikube image load $TARGET:$EMQX_TAG
  146. - name: run emqx on chart
  147. working-directory: source
  148. if: matrix.discovery == 'k8s'
  149. run: |
  150. helm install ${{ matrix.profile }} \
  151. --set emqxConfig.EMQX_CLUSTER__DISCOVERY_STRATEGY="k8s" \
  152. --set emqxConfig.EMQX_CLUSTER__K8S__APISERVER="https://kubernetes.default.svc:443" \
  153. --set emqxConfig.EMQX_CLUSTER__K8S__SERVICE_NAME="${{ matrix.profile }}-headless" \
  154. --set emqxConfig.EMQX_CLUSTER__K8S__NAMESPACE="default" \
  155. --set image.repository=$TARGET \
  156. --set image.pullPolicy=Never \
  157. --set image.tag=$EMQX_TAG \
  158. --set emqxAclConfig="" \
  159. --set emqxConfig.EMQX_MQTT__RETRY_INTERVAL=2s \
  160. --set emqxConfig.EMQX_MQTT__MAX_TOPIC_ALIAS=10 \
  161. --set emqxConfig.EMQX_AUTHORIZATION__SOURCES=[] \
  162. --set emqxConfig.EMQX_AUTHORIZATION__NO_MATCH=allow \
  163. deploy/charts/${{ matrix.profile }} \
  164. --debug
  165. - name: run emqx on chart
  166. working-directory: source
  167. if: matrix.discovery == 'dns'
  168. run: |
  169. helm install ${{ matrix.profile }} \
  170. --set emqxConfig.EMQX_CLUSTER__DISCOVERY_STRATEGY="dns" \
  171. --set emqxConfig.EMQX_CLUSTER__DNS__RECORD_TYPE="srv" \
  172. --set emqxConfig.EMQX_CLUSTER__DNS__NAME="${{ matrix.profile }}-headless.default.svc.cluster.local" \
  173. --set image.repository=$TARGET \
  174. --set image.pullPolicy=Never \
  175. --set image.tag=$EMQX_TAG \
  176. --set emqxAclConfig="" \
  177. --set emqxConfig.EMQX_MQTT__RETRY_INTERVAL=2s \
  178. --set emqxConfig.EMQX_MQTT__MAX_TOPIC_ALIAS=10 \
  179. --set emqxConfig.EMQX_AUTHORIZATION__SOURCES=[] \
  180. --set emqxConfig.EMQX_AUTHORIZATION__NO_MATCH=allow \
  181. deploy/charts/${{ matrix.profile }} \
  182. --debug
  183. - name: waiting emqx started
  184. timeout-minutes: 10
  185. run: |
  186. while [ "$(kubectl get StatefulSet -l app.kubernetes.io/instance=${{ matrix.profile }} -o jsonpath='{.items[0].status.replicas}')" \
  187. != "$(kubectl get StatefulSet -l app.kubernetes.io/instance=${{ matrix.profile }} -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
  188. echo "==============================";
  189. kubectl get pods;
  190. echo "==============================";
  191. echo "waiting emqx started";
  192. sleep 10;
  193. done
  194. - name: Get Token
  195. timeout-minutes: 1
  196. run: |
  197. kubectl port-forward service/${{ matrix.profile }} 18083:18083 > /dev/null &
  198. while
  199. [ "$(curl --silent -X 'GET' 'http://127.0.0.1:18083/api/v5/status' | tail -n1)" != "emqx is running" ]
  200. do
  201. echo "waiting emqx"
  202. sleep 1
  203. done
  204. echo "TOKEN=$(curl --silent -X 'POST' 'http://127.0.0.1:18083/api/v5/login' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{"username": "admin","password": "public"}' | jq -r ".token")" >> $GITHUB_ENV
  205. - name: Check cluster
  206. timeout-minutes: 10
  207. run: |
  208. while
  209. [ "$(curl --silent -H "Authorization: Bearer $TOKEN" -X GET http://127.0.0.1:18083/api/v5/cluster| jq '.nodes|length')" != "3" ];
  210. do
  211. echo "waiting ${{ matrix.profile }} cluster scale"
  212. sleep 1
  213. done
  214. - uses: actions/checkout@v3
  215. with:
  216. repository: emqx/paho.mqtt.testing
  217. ref: develop-5.0
  218. path: paho.mqtt.testing
  219. - name: install pytest
  220. run: |
  221. pip install pytest==7.1.2 pytest-retry
  222. echo "$HOME/.local/bin" >> $GITHUB_PATH
  223. - name: run paho test
  224. timeout-minutes: 10
  225. run: |
  226. port_connected () {
  227. local server="$1"
  228. local port="$2"
  229. echo > /dev/tcp/${server}/${port} 2>/dev/null
  230. }
  231. kubectl port-forward service/${{ matrix.profile }} 1883:1883 > /dev/null &
  232. while ! port_connected localhost 1883; do
  233. echo server not listening yet...
  234. sleep 10
  235. done
  236. pytest --retries 3 -v paho.mqtt.testing/interoperability/test_client/V5/test_connect.py -k test_basic --host "127.0.0.1"
  237. - if: failure()
  238. run: kubectl logs -l "app.kubernetes.io/instance=${{ matrix.profile }}" -c emqx --tail=1000