run_fvt_tests.yaml 10 KB

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