fvt_tests.yaml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. name: Run fvt tests
  2. on:
  3. push:
  4. pull_request:
  5. release:
  6. types:
  7. - published
  8. - prereleased
  9. jobs:
  10. fvt_tests_with_edgex:
  11. runs-on: ubuntu-latest
  12. steps:
  13. - uses: actions/setup-go@v1
  14. with:
  15. go-version: '1.11.5'
  16. - uses: actions/setup-java@v1
  17. with:
  18. java-version: '8' # The JDK version to make available on the path.
  19. java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
  20. architecture: x64 # (x64 or x86) - defaults to x64
  21. - name: install jmeter
  22. timeout-minutes: 10
  23. env:
  24. JMETER_VERSION: 5.2.1
  25. run: |
  26. wget -O /tmp/apache-jmeter.tgz http://us.mirrors.quenda.co/apache//jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz
  27. cd /tmp && tar -xvf apache-jmeter.tgz
  28. echo "jmeter.save.saveservice.output_format=xml" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  29. echo "jmeter.save.saveservice.response_data.on_error=true" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  30. wget -O /tmp/apache-jmeter-$JMETER_VERSION/lib/ext/mqtt-xmeter-1.13-jar-with-dependencies.jar https://github.com/emqx/mqtt-jmeter/raw/master/Download/v1.13.0/mqtt-xmeter-1.13-jar-with-dependencies.jar
  31. ln -s /tmp/apache-jmeter-$JMETER_VERSION /opt/jmeter
  32. - name: install emqx
  33. env:
  34. EMQX_VERSION: v4.0.2
  35. run: |
  36. wget -O emqx.deb https://www.emqx.io/downloads/broker/v4.0.2/emqx-ubuntu18.04-${EMQX_VERSION}_amd64.deb
  37. sudo dpkg -i emqx.deb
  38. - uses: actions/checkout@v2
  39. - name: build kuiper
  40. run: |
  41. sudo apt update && sudo apt install pkg-config libczmq-dev -y
  42. make build_with_edgex
  43. - name: run edgex && emqx && kuiper
  44. run: |
  45. sudo ./fvt_scripts/setup_env.sh
  46. ln -s _build/kuiper-$(git describe --tags --always)-$(uname -s | tr "[A-Z]" "[a-z]")-x86_64/log kuiper_logs
  47. - name: run fvt tests
  48. timeout-minutes: 5
  49. run: ./fvt_scripts/run_jmeter.sh with_edgex=true
  50. - uses: actions/upload-artifact@v1
  51. if: always()
  52. with:
  53. name: kuiper_logs_with_edgex
  54. path: ./kuiper_logs
  55. - uses: actions/upload-artifact@v1
  56. if: always()
  57. with:
  58. name: jmeter_logs_with_edgex
  59. path: ./jmeter_logs
  60. - name: check logs
  61. run: |
  62. sudo apt update && sudo apt install -y libxml2-utils
  63. cd jmeter_logs
  64. if [ "$(xmllint --format --xpath '/testResults/sample/@rc' $(ls *.jtl) | sed -r 's/ /\n/g;' | sort -u | grep -E 'rc=\"[45][0-9][0-9]\"|rc=\"\"')" != "" ]; then
  65. echo -e "---------------------------------------------\n"
  66. echo "FVT tests error"
  67. exit 1
  68. fi
  69. fvt_tests_without_edgex:
  70. runs-on: ubuntu-latest
  71. steps:
  72. - uses: actions/setup-go@v1
  73. with:
  74. go-version: '1.11.5'
  75. - uses: actions/setup-java@v1
  76. with:
  77. java-version: '8' # The JDK version to make available on the path.
  78. java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
  79. architecture: x64 # (x64 or x86) - defaults to x64
  80. - name: install jmeter
  81. timeout-minutes: 10
  82. env:
  83. JMETER_VERSION: 5.2.1
  84. run: |
  85. wget -O /tmp/apache-jmeter.tgz http://us.mirrors.quenda.co/apache//jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz
  86. cd /tmp && tar -xvf apache-jmeter.tgz
  87. echo "jmeter.save.saveservice.output_format=xml" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  88. echo "jmeter.save.saveservice.response_data.on_error=true" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  89. wget -O /tmp/apache-jmeter-$JMETER_VERSION/lib/ext/mqtt-xmeter-1.13-jar-with-dependencies.jar https://github.com/emqx/mqtt-jmeter/raw/master/Download/v1.13.0/mqtt-xmeter-1.13-jar-with-dependencies.jar
  90. ln -s /tmp/apache-jmeter-$JMETER_VERSION /opt/jmeter
  91. - name: install emqx
  92. env:
  93. EMQX_VERSION: v4.0.2
  94. run: |
  95. wget -O emqx.deb https://www.emqx.io/downloads/broker/v4.0.2/emqx-ubuntu18.04-${EMQX_VERSION}_amd64.deb
  96. sudo dpkg -i emqx.deb
  97. - uses: actions/checkout@v2
  98. - name: build kuiper
  99. run: |
  100. sudo apt update && sudo apt install pkg-config libczmq-dev -y
  101. make
  102. - name: run edgex && emqx && kuiper
  103. run: |
  104. sudo ./fvt_scripts/setup_env.sh
  105. ln -s _build/kuiper-$(git describe --tags --always)-$(uname -s | tr "[A-Z]" "[a-z]")-x86_64/log kuiper_logs
  106. - name: run fvt tests
  107. timeout-minutes: 5
  108. run: ./fvt_scripts/run_jmeter.sh with_edgex=false
  109. - uses: actions/upload-artifact@v1
  110. if: always()
  111. with:
  112. name: kuiper_logs_without_edgex
  113. path: ./kuiper_logs
  114. - uses: actions/upload-artifact@v1
  115. if: always()
  116. with:
  117. name: jmeter_logs_without_edgex
  118. path: ./jmeter_logs
  119. - name: check logs
  120. run: |
  121. sudo apt update && sudo apt install -y libxml2-utils
  122. cd jmeter_logs
  123. if [ "$(xmllint --format --xpath '/testResults/sample/@rc' $(ls *.jtl) | sed -r 's/ /\n/g;' | sort -u | grep -E 'rc=\"[45][0-9][0-9]\"|rc=\"\"')" != "" ]; then
  124. echo -e "---------------------------------------------\n"
  125. echo "FVT tests error"
  126. exit 1
  127. fi
  128. fvt_tests_for_container_in_helm:
  129. runs-on: ubuntu-latest
  130. steps:
  131. - uses: actions/checkout@v2
  132. - uses: actions/setup-java@v1
  133. with:
  134. java-version: '8' # The JDK version to make available on the path.
  135. java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
  136. architecture: x64 # (x64 or x86) - defaults to x64
  137. - name: install jmeter
  138. timeout-minutes: 10
  139. env:
  140. JMETER_VERSION: 5.2.1
  141. run: |
  142. wget -O /tmp/apache-jmeter.tgz http://us.mirrors.quenda.co/apache//jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz
  143. cd /tmp && tar -xvf apache-jmeter.tgz
  144. echo "jmeter.save.saveservice.output_format=xml" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  145. echo "jmeter.save.saveservice.response_data.on_error=true" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  146. wget -O /tmp/apache-jmeter-$JMETER_VERSION/lib/ext/mqtt-xmeter-1.13-jar-with-dependencies.jar https://github.com/emqx/mqtt-jmeter/raw/master/Download/v1.13.0/mqtt-xmeter-1.13-jar-with-dependencies.jar
  147. ln -s /tmp/apache-jmeter-$JMETER_VERSION /opt/jmeter
  148. - name: setup jmeter
  149. timeout-minutes: 10
  150. run: |
  151. curl -fsSL "/opt/jmeter/lib/json-lib-2.4-jdk15.jar" https://repo1.maven.org/maven2/net/sf/json-lib/json-lib/2.4/json-lib-2.4-jdk15.jar
  152. curl -fsSL "/opt/jmeter/lib/commons-beanutils-1.8.0.jar" https://repo1.maven.org/maven2/commons-beanutils/commons-beanutils/1.8.0/commons-beanutils-1.8.0.jar
  153. curl -fsSL "/opt/jmeter/lib/commons-collections-3.2.1.jar" https://repo1.maven.org/maven2/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar
  154. curl -fsSL "/opt/jmeter/lib/commons-lang-2.5.jar" https://repo1.maven.org/maven2/commons-lang/commons-lang/2.5/commons-lang-2.5.jar
  155. curl -fsSL "/opt/jmeter/lib/commons-logging-1.1.1.jar" https://repo1.maven.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
  156. curl -fsSL "/opt/jmeter/lib/ezmorph-1.0.6.jar" https://repo1.maven.org/maven2/net/sf/ezmorph/ezmorph/1.0.6/ezmorph-1.0.6.jar
  157. - name: install docker
  158. run: |
  159. sudo apt-get remove docker docker-engine docker.io containerd runc
  160. sudo apt-get update
  161. sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
  162. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  163. sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  164. sudo apt-get update
  165. sudo apt-get install docker-ce docker-ce-cli containerd.io
  166. - name: install k3s
  167. env:
  168. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  169. run: |
  170. sudo sh -c "echo \"127.0.0.1 $(hostname)\" >> /etc/hosts"
  171. curl -sfL https://get.k3s.io | sh -
  172. sudo chmod 644 /etc/rancher/k3s/k3s.yaml
  173. kubectl cluster-info
  174. - name: install helm
  175. run: |
  176. curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
  177. sudo chmod 700 get_helm.sh
  178. sudo ./get_helm.sh
  179. helm version
  180. - name: build kuiper for docker
  181. run: make docker
  182. - name: run emqx on chart
  183. env:
  184. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  185. timeout-minutes: 5
  186. run: |
  187. helm repo add emqx https://repos.emqx.io/charts
  188. helm repo update
  189. helm install emqx --set replicaCount=1 emqx/emqx
  190. while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.replicas}')" \
  191. != "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
  192. echo "waiting emqx started"
  193. sleep 10
  194. done
  195. - name: run kuiper for chart
  196. env:
  197. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  198. timeout-minutes: 5
  199. run: |
  200. version=$(git describe --tags --always)
  201. emqx_address=$(kubectl get svc --namespace default emqx -o jsonpath="{.spec.clusterIP}")
  202. sudo docker save emqx/kuiper:$version -o kuier.tar.gz
  203. sudo k3s ctr image import kuier.tar.gz
  204. sed -i -r "s/^appVersion: .*$/appVersion: ${version}/g" deploy/chart/kuiper/Chart.yaml
  205. sed -i -r 's/ pullPolicy: .*$/ pullPolicy: Never/g' deploy/chart/kuiper/values.yaml
  206. sed -i -r "s/ servers: [.*]$/ servers: [tcp:\/\/${emqx_address}:1883]/g" deploy/chart/kuiper/values.yaml
  207. helm install kuiper deploy/chart/kuiper
  208. while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=kuiper -o jsonpath='{.items[0].status.replicas}')" \
  209. != "$(kubectl get StatefulSet -l app.kubernetes.io/name=kuiper -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
  210. echo "waiting kuiper started"
  211. sleep 10
  212. done
  213. kuiper_address=$(kubectl get svc --namespace default kuiper -o jsonpath="{.spec.clusterIP}")
  214. if [ $(curl -w %{http_code} -fsSL -o /dev/null $kuiper_address:9081/rules) != 200 ];then exit 1; fi
  215. - name: check kuiper
  216. env:
  217. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  218. timeout-minutes: 5
  219. run: |
  220. emqx_address=$(kubectl get svc --namespace default emqx -o jsonpath="{.spec.clusterIP}")
  221. kuiper_address=$(kubectl get svc --namespace default kuiper -o jsonpath="{.spec.clusterIP}")
  222. /opt/jmeter/bin/jmeter.sh -Jjmeter.save.saveservice.output_format=xml -n -t fvt_scripts/select_aggr_rule.jmx -Dsrv=${kuiper_address} -Dmqtt_srv=${emqx_address} -l jmeter_logs/select_aggr_rule.jtl -j jmeter_logs/select_aggr_rule.log
  223. - uses: actions/upload-artifact@v1
  224. if: always()
  225. with:
  226. name: jmeter_logs_without_helm
  227. path: ./jmeter_logs
  228. - name: check logs
  229. run: |
  230. sudo apt update && sudo apt install -y libxml2-utils
  231. cd jmeter_logs
  232. if [ "$(xmllint --format --xpath '/testResults/sample/@rc' $(ls *.jtl) | sed -r 's/ /\n/g;' | sort -u | grep -E 'rc=\"[45][0-9][0-9]\"|rc=\"\"')" != "" ]; then
  233. echo -e "---------------------------------------------\n"
  234. echo "FVT tests error"
  235. exit 1
  236. fi