run_fvt_tests.yaml 10 KB

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