run_fvt_tests.yaml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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: make docker
  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. make emqx-ee-docker
  27. else
  28. echo "TARGET=emqx/emqx" >> $GITHUB_ENV
  29. echo "EMQX_TAG=$(./pkg-vsn.sh)" >> $GITHUB_ENV
  30. make emqx-docker
  31. fi
  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. make emqx-ee-docker
  78. else
  79. echo "TARGET=emqx/emqx" >> $GITHUB_ENV
  80. make emqx-docker
  81. fi
  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. if make emqx-ee --dry-run > /dev/null 2>&1; then
  195. profile="emqx-ee"
  196. old_vsns="$(./scripts/relup-base-vsns.sh enterprise | xargs)"
  197. broker="emqx-ee"
  198. else
  199. profile="emqx"
  200. old_vsns="$(./scripts/relup-base-vsns.sh community | xargs)"
  201. broker="emqx-ce"
  202. fi
  203. echo "OLD_VSNS=$old_vsns" >> $GITHUB_ENV
  204. echo "::set-output name=vsn::$vsn"
  205. echo "::set-output name=profile::$profile"
  206. echo "::set-output name=broker::$broker"
  207. echo "::set-output name=old_vsns::$old_vsns"
  208. - name: Generate matrix
  209. id: generate-matrix
  210. run: |
  211. matrix=$(echo -n "$OLD_VSNS" | sed 's/ $//g' | jq -R -s -c 'split(" ")')
  212. echo "::set-output name=matrix::$matrix"
  213. relup_test_build:
  214. needs: relup_test_plan
  215. runs-on: ubuntu-20.04
  216. container: emqx/build-env:erl23.2.7.2-emqx-3-ubuntu20.04
  217. defaults:
  218. run:
  219. shell: bash
  220. env:
  221. OLD_VSNS: "${{ needs.relup_test_plan.outputs.old_vsns }}"
  222. PROFILE: "${{ needs.relup_test_plan.outputs.profile }}"
  223. BROKER: "${{ needs.relup_test_plan.outputs.broker }}"
  224. steps:
  225. - uses: actions/checkout@v2
  226. name: Checkout
  227. with:
  228. path: emqx
  229. fetch-depth: 0
  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: Build emqx
  238. run: make -C emqx ${PROFILE}-zip
  239. - uses: actions/upload-artifact@v2
  240. name: Upload built emqx and test scenario
  241. with:
  242. name: emqx_built
  243. path: |
  244. emqx/_packages/*/*.zip
  245. emqx/.ci/fvt_tests
  246. relup_test_run:
  247. needs:
  248. - relup_test_plan
  249. - relup_test_build
  250. runs-on: ubuntu-20.04
  251. container: emqx/relup-test-env:erl23.2.7.2-emqx-3-ubuntu20.04
  252. strategy:
  253. fail-fast: false
  254. matrix:
  255. old_vsn: ${{ fromJson(needs.relup_test_plan.outputs.matrix) }}
  256. env:
  257. OLD_VSN: "${{ matrix.old_vsn }}"
  258. PROFILE: "${{ needs.relup_test_plan.outputs.profile }}"
  259. VSN: "${{ needs.relup_test_plan.outputs.vsn }}"
  260. BROKER: "${{ needs.relup_test_plan.outputs.broker }}"
  261. defaults:
  262. run:
  263. shell: bash
  264. steps:
  265. - uses: actions/download-artifact@v2
  266. name: Download built emqx and test scenario
  267. with:
  268. name: emqx_built
  269. path: emqx_built
  270. - uses: actions/checkout@v2
  271. name: Checkout one_more_emqx
  272. with:
  273. repository: terry-xiaoyu/one_more_emqx
  274. ref: master
  275. path: one_more_emqx
  276. - name: Prepare packages
  277. run: |
  278. set -e -x -u
  279. mkdir -p packages
  280. cp emqx_built/_packages/*/*.zip packages
  281. cd packages
  282. wget --no-verbose https://s3-us-west-2.amazonaws.com/packages.emqx/$BROKER/$OLD_VSN/$PROFILE-ubuntu20.04-${OLD_VSN#[e|v]}-amd64.zip
  283. - name: Run relup test scenario
  284. timeout-minutes: 5
  285. run: |
  286. lux \
  287. --progress verbose \
  288. --case_timeout infinity \
  289. --var PROFILE=$PROFILE \
  290. --var PACKAGE_PATH=$(pwd)/packages \
  291. --var ONE_MORE_EMQX_PATH=$(pwd)/one_more_emqx \
  292. --var VSN="$VSN" \
  293. --var OLD_VSN="$OLD_VSN" \
  294. emqx_built/.ci/fvt_tests/relup.lux
  295. - uses: actions/upload-artifact@v2
  296. name: Save debug data
  297. if: failure()
  298. with:
  299. name: debug_data
  300. path: |
  301. packages/emqx/log/emqx.log.1
  302. packages/emqx2/log/emqx.log.1
  303. packages/*.zip
  304. lux_logs