run_fvt_tests.yaml 11 KB

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