run_fvt_tests.yaml 11 KB

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