run_fvt_tests.yaml 9.9 KB

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