run_fvt_tests.yaml 11 KB

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