run_fvt_tests.yaml 9.8 KB

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