run_fvt_tests.yaml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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 pods log
  126. if: failure()
  127. env:
  128. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  129. run: kubectl describe pods emqx-0
  130. - uses: actions/checkout@v2
  131. with:
  132. repository: emqx/paho.mqtt.testing
  133. ref: develop-4.0
  134. path: paho.mqtt.testing
  135. - name: install pytest
  136. run: |
  137. pip install pytest
  138. echo "$HOME/.local/bin" >> $GITHUB_PATH
  139. - name: run paho test
  140. env:
  141. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  142. run: |
  143. emqx_svc=$(kubectl get svc --namespace default emqx -o jsonpath="{.spec.clusterIP}")
  144. emqx1=$(kubectl get pods emqx-1 -o jsonpath='{.status.podIP}')
  145. emqx2=$(kubectl get pods emqx-2 -o jsonpath='{.status.podIP}')
  146. pytest -v paho.mqtt.testing/interoperability/test_client/V5/test_connect.py -k test_basic --host $emqx_svc
  147. RESULT=$?
  148. pytest -v paho.mqtt.testing/interoperability/test_cluster --host1 $emqx1 --host2 $emqx2
  149. RESULT=$((RESULT + $?))
  150. if [ 0 -ne $RESULT ]; then
  151. kubectl logs emqx-1
  152. kubectl logs emqx-2
  153. fi
  154. exit $RESULT
  155. relup_test:
  156. runs-on: ubuntu-20.04
  157. container: emqx/build-env:erl23.2.7.2-emqx-2-ubuntu20.04
  158. defaults:
  159. run:
  160. shell: bash
  161. steps:
  162. - uses: actions/setup-python@v2
  163. with:
  164. python-version: '3.8'
  165. architecture: 'x64'
  166. - uses: actions/checkout@v2
  167. with:
  168. repository: emqx/paho.mqtt.testing
  169. ref: develop-4.0
  170. path: paho.mqtt.testing
  171. - uses: actions/checkout@v2
  172. with:
  173. repository: terry-xiaoyu/one_more_emqx
  174. ref: master
  175. path: one_more_emqx
  176. - uses: actions/checkout@v2
  177. with:
  178. repository: emqx/emqtt-bench
  179. ref: master
  180. path: emqtt-bench
  181. - uses: actions/checkout@v2
  182. with:
  183. repository: hawk/lux
  184. ref: lux-2.6
  185. path: lux
  186. - uses: actions/checkout@v2
  187. with:
  188. repository: ${{ github.repository }}
  189. path: emqx
  190. fetch-depth: 0
  191. - name: prepare
  192. run: |
  193. if make -C emqx emqx-ee --dry-run > /dev/null 2>&1; then
  194. echo "https://ci%40emqx.io:${{ secrets.CI_GIT_TOKEN }}@github.com" > $HOME/.git-credentials
  195. git config --global credential.helper store
  196. echo "${{ secrets.CI_GIT_TOKEN }}" >> emqx/scripts/git-token
  197. echo "PROFILE=emqx-ee" >> $GITHUB_ENV
  198. else
  199. echo "PROFILE=emqx" >> $GITHUB_ENV
  200. fi
  201. - name: get version
  202. run: |
  203. set -e -x -u
  204. cd emqx
  205. if [ $PROFILE = "emqx" ];then
  206. broker="emqx-ce"
  207. edition='opensource'
  208. else
  209. broker="emqx-ee"
  210. edition='enterprise'
  211. fi
  212. echo "BROKER=$broker" >> $GITHUB_ENV
  213. vsn="$(./pkg-vsn.sh)"
  214. echo "VSN=$vsn" >> $GITHUB_ENV
  215. pre_vsn="$(echo $vsn | grep -oE '^[0-9]+.[0-9]')"
  216. if [ $PROFILE = "emqx" ]; then
  217. old_vsns="$(git tag -l "v$pre_vsn.[0-9]" | xargs echo -n | sed "s/v$vsn//")"
  218. else
  219. old_vsns="$(git tag -l "e$pre_vsn.[0-9]" | xargs echo -n | sed "s/e$vsn//")"
  220. fi
  221. echo "OLD_VSNS=$old_vsns" >> $GITHUB_ENV
  222. - name: download emqx
  223. run: |
  224. set -e -x -u
  225. mkdir -p emqx/_upgrade_base
  226. cd emqx/_upgrade_base
  227. old_vsns=($(echo $OLD_VSNS | tr ' ' ' '))
  228. for old_vsn in ${old_vsns[@]}; do
  229. wget --no-verbose https://s3-us-west-2.amazonaws.com/packages.emqx/$BROKER/$old_vsn/$PROFILE-ubuntu20.04-${old_vsn#[e|v]}-amd64.zip
  230. done
  231. - name: build emqx
  232. run: make -C emqx ${PROFILE}-zip
  233. - name: build emqtt-bench
  234. run: make -C emqtt-bench
  235. - name: build lux
  236. run: |
  237. set -e -u -x
  238. cd lux
  239. autoconf
  240. ./configure
  241. make
  242. make install
  243. - name: run relup test
  244. timeout-minutes: 20
  245. run: |
  246. set -e -x -u
  247. if [ -n "$OLD_VSNS" ]; then
  248. mkdir -p packages
  249. cp emqx/_packages/${PROFILE}/*.zip packages
  250. cp emqx/_upgrade_base/*.zip packages
  251. lux \
  252. --case_timeout infinity \
  253. --var PROFILE=$PROFILE \
  254. --var PACKAGE_PATH=$(pwd)/packages \
  255. --var BENCH_PATH=$(pwd)/emqtt-bench \
  256. --var ONE_MORE_EMQX_PATH=$(pwd)/one_more_emqx \
  257. --var VSN="$VSN" \
  258. --var OLD_VSNS="$OLD_VSNS" \
  259. emqx/.ci/fvt_tests/relup.lux
  260. fi
  261. - uses: actions/upload-artifact@v1
  262. if: failure()
  263. with:
  264. name: lux_logs
  265. path: lux_logs