run_fvt_tests.yaml 11 KB

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