run_fvt_tests.yaml 9.6 KB

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