run_fvt_tests.yaml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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.13.10'
  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 [ ! -z "$(cat *.jtl| grep '<failure>' | awk -F '>' '{print $2}' | awk -F '<' '{print $1}' | grep true)" ] ||
  65. [ "$(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
  66. echo -e "---------------------------------------------\n"
  67. echo "FVT tests error"
  68. exit 1
  69. fi
  70. fvt_tests_without_edgex:
  71. runs-on: ubuntu-latest
  72. steps:
  73. - uses: actions/setup-go@v1
  74. with:
  75. go-version: '1.13.10'
  76. - uses: actions/setup-java@v1
  77. with:
  78. java-version: '8' # The JDK version to make available on the path.
  79. java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
  80. architecture: x64 # (x64 or x86) - defaults to x64
  81. - name: install jmeter
  82. timeout-minutes: 10
  83. env:
  84. JMETER_VERSION: 5.2.1
  85. run: |
  86. wget -O /tmp/apache-jmeter.tgz http://us.mirrors.quenda.co/apache//jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz
  87. cd /tmp && tar -xvf apache-jmeter.tgz
  88. echo "jmeter.save.saveservice.output_format=xml" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  89. echo "jmeter.save.saveservice.response_data.on_error=true" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  90. 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
  91. ln -s /tmp/apache-jmeter-$JMETER_VERSION /opt/jmeter
  92. - name: install emqx
  93. env:
  94. EMQX_VERSION: v4.0.2
  95. run: |
  96. wget -O emqx.deb https://www.emqx.io/downloads/broker/v4.0.2/emqx-ubuntu18.04-${EMQX_VERSION}_amd64.deb
  97. sudo dpkg -i emqx.deb
  98. - uses: actions/checkout@v2
  99. - name: build kuiper
  100. run: |
  101. sudo apt update && sudo apt install pkg-config libczmq-dev -y
  102. make
  103. - name: run edgex && emqx && kuiper
  104. run: |
  105. sudo ./fvt_scripts/setup_env.sh
  106. ln -s _build/kuiper-$(git describe --tags --always)-$(uname -s | tr "[A-Z]" "[a-z]")-x86_64/log kuiper_logs
  107. - name: run fvt tests
  108. timeout-minutes: 5
  109. run: ./fvt_scripts/run_jmeter.sh with_edgex=false
  110. - uses: actions/upload-artifact@v1
  111. if: always()
  112. with:
  113. name: kuiper_logs_without_edgex
  114. path: ./kuiper_logs
  115. - uses: actions/upload-artifact@v1
  116. if: always()
  117. with:
  118. name: jmeter_logs_without_edgex
  119. path: ./jmeter_logs
  120. - name: check logs
  121. run: |
  122. sudo apt update && sudo apt install -y libxml2-utils
  123. cd jmeter_logs
  124. if [ ! -z "$(cat *.jtl| grep '<failure>' | awk -F '>' '{print $2}' | awk -F '<' '{print $1}' | grep true)" ] ||
  125. [ "$(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
  126. echo -e "---------------------------------------------\n"
  127. echo "FVT tests error"
  128. exit 1
  129. fi
  130. fvt_tests_for_container_in_helm:
  131. runs-on: ubuntu-latest
  132. steps:
  133. - uses: actions/checkout@v2
  134. - uses: actions/setup-java@v1
  135. with:
  136. java-version: '8' # The JDK version to make available on the path.
  137. java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
  138. architecture: x64 # (x64 or x86) - defaults to x64
  139. - name: install jmeter
  140. timeout-minutes: 10
  141. env:
  142. JMETER_VERSION: 5.2.1
  143. run: |
  144. wget -O /tmp/apache-jmeter.tgz http://us.mirrors.quenda.co/apache//jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz
  145. cd /tmp && tar -xvf apache-jmeter.tgz
  146. echo "jmeter.save.saveservice.output_format=xml" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  147. echo "jmeter.save.saveservice.response_data.on_error=true" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  148. 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
  149. ln -s /tmp/apache-jmeter-$JMETER_VERSION /opt/jmeter
  150. - name: setup jmeter
  151. timeout-minutes: 10
  152. run: |
  153. wget -O "/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
  154. wget -O "/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
  155. wget -O "/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
  156. wget -O "/opt/jmeter/lib/commons-lang-2.5.jar" https://repo1.maven.org/maven2/commons-lang/commons-lang/2.5/commons-lang-2.5.jar
  157. wget -O "/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
  158. wget -O "/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
  159. - name: install docker
  160. run: |
  161. sudo apt-get remove docker docker-engine docker.io containerd runc
  162. sudo apt-get update
  163. sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
  164. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  165. sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  166. sudo apt-get update
  167. sudo apt-get install docker-ce docker-ce-cli containerd.io
  168. - name: install k3s
  169. env:
  170. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  171. run: |
  172. sudo sh -c "echo \"127.0.0.1 $(hostname)\" >> /etc/hosts"
  173. curl -sfL https://get.k3s.io | sh -
  174. sudo chmod 644 /etc/rancher/k3s/k3s.yaml
  175. kubectl cluster-info
  176. - name: install helm
  177. run: |
  178. curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
  179. sudo chmod 700 get_helm.sh
  180. sudo ./get_helm.sh
  181. helm version
  182. - name: build kuiper for docker
  183. run: make docker
  184. - name: run emqx on chart
  185. env:
  186. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  187. timeout-minutes: 5
  188. run: |
  189. helm repo add emqx https://repos.emqx.io/charts
  190. helm repo update
  191. helm install emqx --set replicaCount=1 emqx/emqx
  192. while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.replicas}')" \
  193. != "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
  194. echo "waiting emqx started"
  195. sleep 10
  196. done
  197. - name: run kuiper for chart
  198. env:
  199. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  200. timeout-minutes: 5
  201. run: |
  202. version=$(git describe --tags --always)
  203. emqx_address=$(kubectl get svc --namespace default emqx -o jsonpath="{.spec.clusterIP}")
  204. sudo docker save emqx/kuiper:$version -o kuier.tar.gz
  205. sudo k3s ctr image import kuier.tar.gz
  206. sed -i -r "s/^appVersion: .*$/appVersion: ${version}/g" deploy/chart/kuiper/Chart.yaml
  207. sed -i -r 's/ pullPolicy: .*$/ pullPolicy: Never/g' deploy/chart/kuiper/values.yaml
  208. sed -i -r "s/ servers: \[.*\]$/ servers: \[tcp:\/\/${emqx_address}:1883\]/g" deploy/chart/kuiper/values.yaml
  209. helm install kuiper deploy/chart/kuiper
  210. while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=kuiper -o jsonpath='{.items[0].status.replicas}')" \
  211. != "$(kubectl get StatefulSet -l app.kubernetes.io/name=kuiper -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
  212. echo "waiting kuiper started"
  213. sleep 10
  214. done
  215. kuiper_address=$(kubectl get svc --namespace default kuiper -o jsonpath="{.spec.clusterIP}")
  216. if [ $(curl -w %{http_code} -fsSL -o /dev/null $kuiper_address:9081) != 200 ];then exit 1; fi
  217. - name: check kuiper
  218. env:
  219. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  220. timeout-minutes: 5
  221. run: |
  222. emqx_address=$(kubectl get svc --namespace default emqx -o jsonpath="{.spec.clusterIP}")
  223. kuiper_address=$(kubectl get svc --namespace default kuiper -o jsonpath="{.spec.clusterIP}")
  224. /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
  225. mkdir -p kuiper_logs
  226. kubectl exec kuiper-0 -- cat /kuiper/log/stream.log > kuiper_logs/stream.log
  227. - uses: actions/upload-artifact@v1
  228. if: always()
  229. with:
  230. name: kuiper_logs_with_helm
  231. path: ./kuiper_logs
  232. - uses: actions/upload-artifact@v1
  233. if: always()
  234. with:
  235. name: jmeter_logs_with_helm
  236. path: ./jmeter_logs
  237. - name: check logs
  238. run: |
  239. sudo apt update && sudo apt install -y libxml2-utils
  240. cd jmeter_logs
  241. if [ ! -z "$(cat *.jtl| grep '<failure>' | awk -F '>' '{print $2}' | awk -F '<' '{print $1}' | grep true)" ] ||
  242. [ "$(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
  243. echo -e "---------------------------------------------\n"
  244. echo "FVT tests error"
  245. exit 1
  246. fi