run_fvt_tests.yaml 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. name: Functional Verification Tests
  2. on:
  3. push:
  4. tags:
  5. - v*
  6. - e*
  7. release:
  8. types:
  9. - published
  10. pull_request:
  11. jobs:
  12. docker_test:
  13. runs-on: ubuntu-20.04
  14. steps:
  15. - uses: actions/checkout@v1
  16. - name: prepare
  17. run: |
  18. if make emqx-ee --dry-run > /dev/null 2>&1; then
  19. echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@github.com" > $HOME/.git-credentials
  20. git config --global credential.helper store
  21. echo "${{ secrets.CI_GIT_TOKEN }}" >> scripts/git-token
  22. make deps-emqx-ee
  23. echo "TARGET=emqx/emqx-ee" >> $GITHUB_ENV
  24. else
  25. echo "TARGET=emqx/emqx" >> $GITHUB_ENV
  26. fi
  27. - name: make emqx image
  28. run: make docker
  29. - name: run emqx
  30. timeout-minutes: 5
  31. run: |
  32. set -e -u -x
  33. docker-compose -f .ci/fvt_tests/docker-compose.yaml up -d
  34. while [ "$(docker inspect -f '{{ .State.Health.Status}}' node1.emqx.io)" != "healthy" ] || [ "$(docker inspect -f '{{ .State.Health.Status}}' node2.emqx.io)" != "healthy" ]; do
  35. if [ $(docker ps -a -f name=fvt_tests_emqx -f status=exited -q | wc -l) -ne 0 ]; then
  36. echo "['$(date -u +"%Y-%m-%dT%H:%M:%SZ")']:emqx stop";
  37. exit;
  38. else
  39. echo "['$(date -u +"%Y-%m-%dT%H:%M:%SZ")']:waiting emqx";
  40. sleep 5;
  41. fi;
  42. done
  43. - name: make paho tests
  44. run: |
  45. if ! docker exec -i paho_client /scripts/pytest.sh; then
  46. docker logs node1.emqx.io
  47. docker logs node2.emqx.io
  48. exit 1
  49. fi
  50. helm_test:
  51. runs-on: ubuntu-20.04
  52. steps:
  53. - uses: actions/checkout@v1
  54. - name: prepare
  55. run: |
  56. if make emqx-ee --dry-run > /dev/null 2>&1; then
  57. echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@github.com" > $HOME/.git-credentials
  58. git config --global credential.helper store
  59. echo "${{ secrets.CI_GIT_TOKEN }}" >> scripts/git-token
  60. make deps-emqx-ee
  61. echo "TARGET=emqx/emqx-ee" >> $GITHUB_ENV
  62. else
  63. echo "TARGET=emqx/emqx" >> $GITHUB_ENV
  64. fi
  65. - name: make emqx image
  66. run: make docker
  67. - name: install k3s
  68. env:
  69. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  70. run: |
  71. sudo sh -c "echo \"127.0.0.1 $(hostname)\" >> /etc/hosts"
  72. curl -sfL https://get.k3s.io | sh -
  73. sudo chmod 644 /etc/rancher/k3s/k3s.yaml
  74. kubectl cluster-info
  75. - name: install helm
  76. env:
  77. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  78. run: |
  79. curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
  80. sudo chmod 700 get_helm.sh
  81. sudo ./get_helm.sh
  82. helm version
  83. - name: run emqx on chart
  84. env:
  85. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  86. timeout-minutes: 5
  87. run: |
  88. version=$(./pkg-vsn.sh)
  89. sudo docker save ${TARGET}:$version -o emqx.tar.gz
  90. sudo k3s ctr image import emqx.tar.gz
  91. sed -i -r "s/^appVersion: .*$/appVersion: \"${version}\"/g" deploy/charts/emqx/Chart.yaml
  92. sed -i '/emqx_telemetry/d' deploy/charts/emqx/values.yaml
  93. helm install emqx \
  94. --set image.repository=${TARGET} \
  95. --set image.pullPolicy=Never \
  96. --set emqxAclConfig="" \
  97. --set image.pullPolicy=Never \
  98. --set emqxConfig.EMQX_ZONE__EXTERNAL__RETRY_INTERVAL=2s \
  99. --set emqxConfig.EMQX_MQTT__MAX_TOPIC_ALIAS=10 \
  100. deploy/charts/emqx \
  101. --debug
  102. while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.replicas}')" \
  103. != "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
  104. echo "==============================";
  105. kubectl get pods;
  106. echo "==============================";
  107. echo "waiting emqx started";
  108. sleep 10;
  109. done
  110. - name: get pods log
  111. if: failure()
  112. env:
  113. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  114. run: kubectl describe pods emqx-0
  115. - uses: actions/checkout@v2
  116. with:
  117. repository: emqx/paho.mqtt.testing
  118. ref: develop-4.0
  119. path: paho.mqtt.testing
  120. - name: install pytest
  121. run: |
  122. pip install pytest
  123. echo "$HOME/.local/bin" >> $GITHUB_PATH
  124. - name: run paho test
  125. env:
  126. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  127. run: |
  128. emqx_svc=$(kubectl get svc --namespace default emqx -o jsonpath="{.spec.clusterIP}")
  129. emqx1=$(kubectl get pods emqx-1 -o jsonpath='{.status.podIP}')
  130. emqx2=$(kubectl get pods emqx-2 -o jsonpath='{.status.podIP}')
  131. pytest -v paho.mqtt.testing/interoperability/test_client/V5/test_connect.py -k test_basic --host $emqx_svc
  132. RESULT=$?
  133. pytest -v paho.mqtt.testing/interoperability/test_cluster --host1 $emqx1 --host2 $emqx2
  134. RESULT=$((RESULT + $?))
  135. if [ 0 -ne $RESULT ]; then
  136. kubectl logs emqx-1
  137. kubectl logs emqx-2
  138. fi
  139. exit $RESULT
  140. relup_test:
  141. runs-on: ubuntu-20.04
  142. container: emqx/build-env:erl23.2.7-ubuntu20.04
  143. defaults:
  144. run:
  145. shell: bash
  146. steps:
  147. - uses: actions/setup-python@v2
  148. with:
  149. python-version: '3.8'
  150. architecture: 'x64'
  151. - uses: actions/checkout@v2
  152. with:
  153. repository: emqx/paho.mqtt.testing
  154. ref: develop-4.0
  155. path: paho.mqtt.testing
  156. - uses: actions/checkout@v2
  157. with:
  158. repository: terry-xiaoyu/one_more_emqx
  159. ref: master
  160. path: one_more_emqx
  161. - uses: actions/checkout@v2
  162. with:
  163. repository: emqx/emqtt-bench
  164. ref: master
  165. path: emqtt-bench
  166. - uses: actions/checkout@v2
  167. with:
  168. repository: hawk/lux
  169. ref: lux-2.4
  170. path: lux
  171. - uses: actions/checkout@v2
  172. with:
  173. repository: ${{ github.repository }}
  174. path: emqx
  175. fetch-depth: 0
  176. - name: prepare
  177. run: |
  178. if make -C emqx emqx-ee --dry-run > /dev/null 2>&1; then
  179. echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@github.com" > $HOME/.git-credentials
  180. git config --global credential.helper store
  181. echo "${{ secrets.CI_GIT_TOKEN }}" >> emqx/scripts/git-token
  182. echo "PROFILE=emqx-ee" >> $GITHUB_ENV
  183. else
  184. echo "PROFILE=emqx" >> $GITHUB_ENV
  185. fi
  186. - name: get version
  187. run: |
  188. set -e -x -u
  189. cd emqx
  190. if [ $PROFILE = "emqx" ];then
  191. broker="emqx-ce"
  192. edition='opensource'
  193. else
  194. broker="emqx-ee"
  195. edition='enterprise'
  196. fi
  197. vsn="$(grep -E "define.+EMQX_RELEASE.+${edition}" include/emqx_release.hrl | cut -d '"' -f2)"
  198. echo "VSN=$vsn" >> $GITHUB_ENV
  199. pre_vsn="$(echo $vsn | grep -oE '^[0-9]+.[0-9]')"
  200. if [ $PROFILE = "emqx" ]; then
  201. old_vsns="$(git tag -l "v$pre_vsn.[0-9]" | tr "\n" " " | sed "s/v$vsn//")"
  202. else
  203. old_vsns="$(git tag -l "e$pre_vsn.[0-9]" | tr "\n" " " | sed "s/v$vsn//")"
  204. fi
  205. echo "OLD_VSNS=$old_vsns" >> $GITHUB_ENV
  206. - name: download emqx
  207. run: |
  208. set -e -x -u
  209. cd emqx
  210. old_vsns=($(echo $OLD_VSNS | tr ' ' ' '))
  211. for old_vsn in ${old_vsns[@]}; do
  212. wget https://s3-${{ secrets.AWS_DEFAULT_REGION }}.amazonaws.com/${{ secrets.AWS_S3_BUCKET }}/$broker/$old_vsn/$PROFILE-ubuntu20.04-${old_vsn#[e|v]}-x86_64.zip
  213. done
  214. - name: build emqx
  215. run: make -C emqx ${PROFILE}-zip
  216. - name: build emqtt-bench
  217. run: make -C emqtt-bench
  218. - name: build lux
  219. run: |
  220. set -e -u -x
  221. cd lux
  222. autoconf
  223. ./configure
  224. make
  225. make install
  226. - name: run relup test
  227. run: |
  228. set -e -x -u
  229. if [ -n "$OLD_VSNS" ]; then
  230. mkdir -p packages
  231. cp emqx/_packages/emqx/*.zip packages
  232. cp emqx/*.zip packages
  233. lux -v \
  234. --timeout 600000 \
  235. --var PACKAGE_PATH=$(pwd)/packages \
  236. --var BENCH_PATH=$(pwd)/emqtt-bench \
  237. --var ONE_MORE_EMQX_PATH=$(pwd)/one_more_emqx \
  238. --var VSN="$VSN" \
  239. --var OLD_VSNS="$OLD_VSNS" \
  240. emqx/.ci/fvt_tests/relup.lux
  241. fi
  242. - uses: actions/upload-artifact@v1
  243. if: failure()
  244. with:
  245. name: lux_logs
  246. path: lux_logs