run_fvt_tests.yaml 9.5 KB

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