run_fvt_tests.yaml 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. name: Functional Verification Tests
  2. on:
  3. push:
  4. tags:
  5. - v*
  6. release:
  7. types:
  8. - published
  9. pull_request:
  10. workflow_dispatch:
  11. repository_dispatch:
  12. types: [run_actions]
  13. jobs:
  14. docker_test:
  15. runs-on: ubuntu-20.04
  16. steps:
  17. - uses: actions/checkout@v1
  18. - name: make emqx image
  19. run: TARGET=emqx/emqx make docker
  20. - name: run emqx
  21. timeout-minutes: 5
  22. run: |
  23. set -e -u -x
  24. docker-compose -f .ci/fvt_tests/docker-compose.yaml up -d
  25. while [ "$(docker inspect -f '{{ .State.Health.Status}}' node1.emqx.io)" != "healthy" ] || [ "$(docker inspect -f '{{ .State.Health.Status}}' node2.emqx.io)" != "healthy" ]; do
  26. if [ $(docker ps -a -f name=fvt_tests_emqx -f status=exited -q | wc -l) -ne 0 ]; then
  27. echo "['$(date -u +"%Y-%m-%dT%H:%M:%SZ")']:emqx stop";
  28. exit;
  29. else
  30. echo "['$(date -u +"%Y-%m-%dT%H:%M:%SZ")']:waiting emqx";
  31. sleep 5;
  32. fi;
  33. done
  34. - name: make paho tests
  35. run: |
  36. docker exec -i paho_client sh -c "apk update && apk add git curl \
  37. && git clone -b develop-4.0 https://github.com/emqx/paho.mqtt.testing.git /paho.mqtt.testing \
  38. && pip install pytest \
  39. && pytest -v /paho.mqtt.testing/interoperability/test_client/V5/test_connect.py -k test_basic --host node1.emqx.io \
  40. && pytest -v /paho.mqtt.testing/interoperability/test_cluster --host1 node1.emqx.io --host2 node2.emqx.io \
  41. && pytest -v /paho.mqtt.testing/interoperability/test_client --host node1.emqx.io"
  42. helm_test:
  43. runs-on: ubuntu-20.04
  44. steps:
  45. - uses: actions/checkout@v1
  46. - name: make emqx image
  47. run: TARGET=emqx/emqx make docker
  48. - name: install k3s
  49. env:
  50. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  51. run: |
  52. sudo sh -c "echo \"127.0.0.1 $(hostname)\" >> /etc/hosts"
  53. curl -sfL https://get.k3s.io | sh -
  54. sudo chmod 644 /etc/rancher/k3s/k3s.yaml
  55. kubectl cluster-info
  56. - name: install helm
  57. env:
  58. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  59. run: |
  60. curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
  61. sudo chmod 700 get_helm.sh
  62. sudo ./get_helm.sh
  63. helm version
  64. - name: run emqx on chart
  65. env:
  66. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  67. timeout-minutes: 5
  68. run: |
  69. version=$(./pkg-vsn.sh)
  70. sudo docker save emqx/emqx:$version -o emqx.tar.gz
  71. sudo k3s ctr image import emqx.tar.gz
  72. sed -i -r "s/^appVersion: .*$/appVersion: \"${version}\"/g" deploy/charts/emqx/Chart.yaml
  73. sed -i -r 's/ pullPolicy: .*$/ pullPolicy: Never/g' deploy/charts/emqx/values.yaml
  74. sed -i '/emqx_telemetry/d' deploy/charts/emqx/values.yaml
  75. helm install emqx --set emqxAclConfig="" --set emqxConfig.EMQX_ZONE__EXTERNAL__RETRY_INTERVAL=2s --set emqxConfig.EMQX_MQTT__MAX_TOPIC_ALIAS=10 deploy/charts/emqx --debug --dry-run
  76. helm install emqx --set emqxAclConfig="" --set emqxConfig.EMQX_ZONE__EXTERNAL__RETRY_INTERVAL=2s --set emqxConfig.EMQX_MQTT__MAX_TOPIC_ALIAS=10 deploy/charts/emqx
  77. while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.replicas}')" \
  78. != "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
  79. echo "==============================";
  80. kubectl get pods;
  81. echo "==============================";
  82. echo "waiting emqx started";
  83. sleep 10;
  84. done
  85. - name: get pods log
  86. if: failure()
  87. env:
  88. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  89. run: kubectl describe pods emqx-0
  90. - uses: actions/checkout@v2
  91. with:
  92. repository: emqx/paho.mqtt.testing
  93. ref: develop-4.0
  94. path: paho.mqtt.testing
  95. - name: install pytest
  96. run: |
  97. pip install pytest
  98. echo "$HOME/.local/bin" >> $GITHUB_PATH
  99. - name: run paho test
  100. env:
  101. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  102. run: |
  103. emqx_svc=$(kubectl get svc --namespace default emqx -o jsonpath="{.spec.clusterIP}")
  104. emqx1=$(kubectl get pods emqx-1 -o jsonpath='{.status.podIP}')
  105. emqx2=$(kubectl get pods emqx-2 -o jsonpath='{.status.podIP}')
  106. pytest -v paho.mqtt.testing/interoperability/test_client/V5/test_connect.py -k test_basic --host $emqx_svc
  107. pytest -v paho.mqtt.testing/interoperability/test_cluster --host1 $emqx1 --host2 $emqx2
  108. relup_test:
  109. runs-on: ubuntu-20.04
  110. container: emqx/build-env:erl23.2.2-ubuntu20.04
  111. defaults:
  112. run:
  113. shell: bash
  114. steps:
  115. - uses: actions/setup-python@v2
  116. with:
  117. python-version: '3.8'
  118. architecture: 'x64'
  119. - uses: actions/checkout@v2
  120. with:
  121. repository: emqx/paho.mqtt.testing
  122. ref: develop-4.0
  123. path: paho.mqtt.testing
  124. - uses: actions/checkout@v2
  125. with:
  126. repository: terry-xiaoyu/one_more_emqx
  127. ref: master
  128. path: one_more_emqx
  129. - uses: actions/checkout@v2
  130. with:
  131. repository: emqx/emqtt-bench
  132. ref: master
  133. path: emqtt-bench
  134. - uses: actions/checkout@v2
  135. with:
  136. repository: hawk/lux
  137. ref: lux-2.4
  138. path: lux
  139. - uses: actions/checkout@v2
  140. with:
  141. repository: ${{ github.repository }}
  142. path: emqx
  143. fetch-depth: 0
  144. - name: get version
  145. run: |
  146. set -e -x -u
  147. cd emqx
  148. vsn="$(erl -eval '{ok, [{application,emqx, L} | _]} = file:consult("src/emqx.app.src"), {vsn, VSN} = lists:keyfind(vsn,1,L), io:fwrite(VSN), halt().' -noshell)"
  149. echo "VSN=$vsn" >> $GITHUB_ENV
  150. pre_tag="$(echo $vsn | grep -oE '^[0-9]+.[0-9]')"
  151. old_vsns="$(git tag -l "$pre_tag.[0-9]" | tr "\n" " " | sed "s/$vsn//")"
  152. echo "OLD_VSNS=$old_vsns" >> $GITHUB_ENV
  153. - name: download emqx
  154. run: |
  155. set -e -x -u
  156. cd emqx
  157. old_vsns=($(echo $OLD_VSNS | tr ' ' ' '))
  158. for old_vsn in ${old_vsns[@]}; do
  159. wget https://s3-us-west-2.amazonaws.com/packages.emqx/emqx-ce/v$old_vsn/emqx-ubuntu20.04-${old_vsn}-x86_64.zip
  160. done
  161. - name: build emqx
  162. run: make -C emqx emqx-zip
  163. - name: build emqtt-bench
  164. run: make -C emqtt-bench
  165. - name: build lux
  166. run: |
  167. set -e -u -x
  168. cd lux
  169. autoconf
  170. ./configure
  171. make
  172. make install
  173. - name: run relup test
  174. run: |
  175. set -e -x -u
  176. if [ -n "$OLD_VSNS" ]; then
  177. mkdir -p packages
  178. cp emqx/_packages/emqx/*.zip packages
  179. cp emqx/*.zip packages
  180. lux -v \
  181. --timeout 600000 \
  182. --var PACKAGE_PATH=$(pwd)/packages \
  183. --var BENCH_PATH=$(pwd)/emqtt-bench \
  184. --var ONE_MORE_EMQX_PATH=$(pwd)/one_more_emqx \
  185. --var VSN="$VSN" \
  186. --var OLD_VSNS="$OLD_VSNS" \
  187. emqx/.ci/fvt_tests/relup.lux
  188. fi
  189. - uses: actions/upload-artifact@v1
  190. if: failure()
  191. with:
  192. name: lux_logs
  193. path: lux_logs