run_fvt_tests.yaml 9.2 KB

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