run_fvt_tests.yaml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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_plan:
  172. runs-on: ubuntu-20.04
  173. container: emqx/build-env:erl23.2.7.2-emqx-3-ubuntu20.04
  174. outputs:
  175. profile: ${{ steps.profile-and-versions.outputs.profile }}
  176. vsn: ${{ steps.profile-and-versions.outputs.vsn }}
  177. old_vsns: ${{ steps.profile-and-versions.outputs.old_vsns }}
  178. broker: ${{ steps.profile-and-versions.outputs.broker }}
  179. matrix: ${{ steps.generate-matrix.outputs.matrix }}
  180. defaults:
  181. run:
  182. shell: bash
  183. steps:
  184. - uses: actions/checkout@v2
  185. name: Checkout
  186. with:
  187. path: emqx
  188. fetch-depth: 0
  189. - name: Get profile and version list
  190. id: profile-and-versions
  191. run: |
  192. cd emqx
  193. vsn="$(./pkg-vsn.sh)"
  194. pre_vsn="$(echo $vsn | grep -oE '^[0-9]+.[0-9]')"
  195. if make emqx-ee --dry-run > /dev/null 2>&1; then
  196. profile="emqx-ee"
  197. old_vsns="$(git tag -l "e$pre_vsn.[0-9]" | xargs echo -n | sed "s/e$vsn//")"
  198. broker="emqx-ee"
  199. else
  200. profile="emqx"
  201. old_vsns="$(git tag -l "v$pre_vsn.[0-9]" | xargs echo -n | sed "s/v$vsn//")"
  202. broker="emqx-ce"
  203. fi
  204. echo "OLD_VSNS=$old_vsns" >> $GITHUB_ENV
  205. echo "::set-output name=vsn::$vsn"
  206. echo "::set-output name=profile::$profile"
  207. echo "::set-output name=broker::$broker"
  208. echo "::set-output name=old_vsns::$old_vsns"
  209. - name: Generate matrix
  210. id: generate-matrix
  211. run: |
  212. matrix=$(echo -n "$OLD_VSNS" | sed 's/ $//g' | jq -R -s -c 'split(" ")')
  213. echo "::set-output name=matrix::$matrix"
  214. relup_test_build:
  215. needs: relup_test_plan
  216. runs-on: ubuntu-20.04
  217. container: emqx/build-env:erl23.2.7.2-emqx-3-ubuntu20.04
  218. defaults:
  219. run:
  220. shell: bash
  221. env:
  222. OLD_VSNS: "${{ needs.relup_test_plan.outputs.old_vsns }}"
  223. PROFILE: "${{ needs.relup_test_plan.outputs.profile }}"
  224. BROKER: "${{ needs.relup_test_plan.outputs.broker }}"
  225. steps:
  226. - uses: actions/checkout@v2
  227. name: Checkout
  228. with:
  229. path: emqx
  230. - name: Prepare credentials
  231. run: |
  232. if [ "$PROFILE" = "emqx-ee" ]; then
  233. echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@github.com" > $HOME/.git-credentials
  234. git config --global credential.helper store
  235. echo "${{ secrets.CI_GIT_TOKEN }}" >> emqx/scripts/git-token
  236. fi
  237. - name: Download bases
  238. run: |
  239. set -e -x -u
  240. mkdir -p emqx/_upgrade_base
  241. cd emqx/_upgrade_base
  242. old_vsns=($(echo $OLD_VSNS | tr ' ' ' '))
  243. for old_vsn in ${old_vsns[@]}; do
  244. wget --no-verbose https://s3-us-west-2.amazonaws.com/packages.emqx/$BROKER/$old_vsn/$PROFILE-ubuntu20.04-${old_vsn#[e|v]}-amd64.zip
  245. done
  246. - name: Build emqx
  247. run: make -C emqx ${PROFILE}-zip
  248. - uses: actions/upload-artifact@v2
  249. name: Upload built emqx and test scenario
  250. with:
  251. name: emqx_built
  252. path: |
  253. emqx/_packages/*/*.zip
  254. emqx/.ci/fvt_tests
  255. relup_test_run:
  256. needs:
  257. - relup_test_plan
  258. - relup_test_build
  259. runs-on: ubuntu-20.04
  260. container: emqx/relup-test-env:erl23.2.7.2-emqx-3-ubuntu20.04
  261. strategy:
  262. fail-fast: false
  263. matrix:
  264. old_vsn: ${{ fromJson(needs.relup_test_plan.outputs.matrix) }}
  265. env:
  266. OLD_VSN: "${{ matrix.old_vsn }}"
  267. PROFILE: "${{ needs.relup_test_plan.outputs.profile }}"
  268. VSN: "${{ needs.relup_test_plan.outputs.vsn }}"
  269. BROKER: "${{ needs.relup_test_plan.outputs.broker }}"
  270. defaults:
  271. run:
  272. shell: bash
  273. steps:
  274. - uses: actions/download-artifact@v2
  275. name: Dowload built emqx and test scenario
  276. with:
  277. name: emqx_built
  278. path: emqx_built
  279. - uses: actions/checkout@v2
  280. name: Checkout one_more_emqx
  281. with:
  282. repository: terry-xiaoyu/one_more_emqx
  283. ref: master
  284. path: one_more_emqx
  285. - name: Prepare packages
  286. run: |
  287. set -e -x -u
  288. mkdir -p packages
  289. cp emqx_built/_packages/*/*.zip packages
  290. cd packages
  291. wget --no-verbose https://s3-us-west-2.amazonaws.com/packages.emqx/$BROKER/$OLD_VSN/$PROFILE-ubuntu20.04-${OLD_VSN#[e|v]}-amd64.zip
  292. - name: Run relup test scenario
  293. timeout-minutes: 5
  294. run: |
  295. lux \
  296. --progress verbose \
  297. --case_timeout infinity \
  298. --var PROFILE=$PROFILE \
  299. --var PACKAGE_PATH=$(pwd)/packages \
  300. --var ONE_MORE_EMQX_PATH=$(pwd)/one_more_emqx \
  301. --var VSN="$VSN" \
  302. --var OLD_VSN="$OLD_VSN" \
  303. emqx_built/.ci/fvt_tests/relup.lux
  304. - uses: actions/upload-artifact@v2
  305. name: Save debug data
  306. if: failure()
  307. with:
  308. name: debug_data
  309. path: |
  310. packages/emqx/log/emqx.log.1
  311. packages/emqx2/log/emqx.log.1
  312. packages/*.zip
  313. lux_logs