run_fvt_tests.yaml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. name: Run fvt tests
  2. on:
  3. push:
  4. pull_request:
  5. release:
  6. types:
  7. - published
  8. jobs:
  9. fvt_tests_with_edgex:
  10. runs-on: ubuntu-latest
  11. steps:
  12. - uses: actions/setup-go@v1
  13. with:
  14. go-version: '1.14'
  15. - uses: actions/setup-java@v1
  16. with:
  17. java-version: '8' # The JDK version to make available on the path.
  18. java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
  19. architecture: x64 # (x64 or x86) - defaults to x64
  20. - name: install jmeter
  21. timeout-minutes: 10
  22. env:
  23. JMETER_VERSION: 5.3
  24. run: |
  25. wget --no-check-certificate -O /tmp/apache-jmeter.tgz https://downloads.apache.org//jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz
  26. cd /tmp && tar -xvf apache-jmeter.tgz
  27. echo "jmeter.save.saveservice.output_format=xml" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  28. echo "jmeter.save.saveservice.response_data.on_error=true" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  29. 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
  30. ln -s /tmp/apache-jmeter-$JMETER_VERSION /opt/jmeter
  31. - name: install emqx
  32. env:
  33. EMQX_VERSION: v4.0.2
  34. run: |
  35. wget -O emqx.deb https://www.emqx.io/downloads/broker/v4.0.2/emqx-ubuntu18.04-${EMQX_VERSION}_amd64.deb
  36. sudo dpkg -i emqx.deb
  37. - uses: actions/checkout@v2
  38. - name: build kuiper
  39. run: |
  40. sudo apt update && sudo apt install pkg-config libczmq-dev -y
  41. make build_with_edgex
  42. go build -trimpath --buildmode=plugin -o plugins/sources/Zmq.so plugins/sources/zmq/zmq.go
  43. go build -trimpath --buildmode=plugin -o plugins/functions/Image.so plugins/functions/image/*.go
  44. - name: run edgex && emqx && kuiper
  45. run: |
  46. sudo ./fvt_scripts/setup_env.sh
  47. ln -s _build/kuiper-$(git describe --tags --always)-$(uname -s | tr "[A-Z]" "[a-z]")-x86_64/log kuiper_logs
  48. - name: run fvt tests
  49. timeout-minutes: 8
  50. run: ./fvt_scripts/run_jmeter.sh with_edgex=true
  51. - uses: actions/upload-artifact@v1
  52. if: always()
  53. with:
  54. name: kuiper_logs_with_edgex
  55. path: ./kuiper_logs
  56. - uses: actions/upload-artifact@v1
  57. if: always()
  58. with:
  59. name: jmeter_logs_with_edgex
  60. path: ./jmeter_logs
  61. - name: check logs
  62. run: |
  63. sudo apt update && sudo apt install -y libxml2-utils
  64. cd jmeter_logs
  65. if [ ! -z "$(cat *.jtl| grep '<failure>' | awk -F '>' '{print $2}' | awk -F '<' '{print $1}' | grep true)" ] ||
  66. [ "$(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
  67. echo -e "---------------------------------------------\n"
  68. echo "FVT tests error"
  69. exit 1
  70. fi
  71. fvt_tests_for_container_in_helm:
  72. runs-on: ubuntu-latest
  73. steps:
  74. - uses: actions/checkout@v2
  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.3
  84. run: |
  85. wget --no-check-certificate -O /tmp/apache-jmeter.tgz https://downloads.apache.org//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: setup jmeter
  92. timeout-minutes: 10
  93. run: |
  94. 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
  95. 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
  96. 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
  97. 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
  98. 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
  99. 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
  100. - name: install docker
  101. run: |
  102. sudo apt-get remove docker docker-engine docker.io containerd runc
  103. sudo apt-get update
  104. sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
  105. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  106. sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  107. sudo apt-get update
  108. sudo apt-get install docker-ce docker-ce-cli containerd.io
  109. - name: install k3s
  110. env:
  111. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  112. run: |
  113. sudo sh -c "echo \"127.0.0.1 $(hostname)\" >> /etc/hosts"
  114. curl -sfL https://get.k3s.io | sh -
  115. sudo chmod 644 /etc/rancher/k3s/k3s.yaml
  116. kubectl cluster-info
  117. - name: install helm
  118. run: |
  119. curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
  120. sudo chmod 700 get_helm.sh
  121. sudo ./get_helm.sh
  122. helm version
  123. - name: build kuiper for docker
  124. run: sudo docker build --no-cache -t emqx/kuiper:$(git describe --tags --alway)-alpine -f deploy/docker/Dockerfile-alpine .
  125. - name: run emqx on chart
  126. env:
  127. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  128. timeout-minutes: 5
  129. run: |
  130. helm repo add emqx https://repos.emqx.io/charts
  131. helm repo update
  132. helm install emqx --set replicaCount=1 emqx/emqx
  133. while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.replicas}')" \
  134. != "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
  135. echo "waiting emqx started"
  136. sleep 10
  137. done
  138. - name: run kuiper for chart
  139. env:
  140. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  141. timeout-minutes: 5
  142. run: |
  143. version=$(git describe --tags --always)
  144. emqx_address=$(kubectl get svc --namespace default emqx -o jsonpath="{.spec.clusterIP}")
  145. sudo docker save emqx/kuiper:$version-alpine -o kuier.tar.gz
  146. sudo k3s ctr image import kuier.tar.gz
  147. sed -i -r "s/^appVersion: .*$/appVersion: \"${version}\"/g" deploy/chart/kuiper/Chart.yaml
  148. sed -i -r 's/ pullPolicy: .*$/ pullPolicy: Never/g' deploy/chart/kuiper/values.yaml
  149. sed -i -r "s/ servers: \[.*\]$/ servers: \[tcp:\/\/${emqx_address}:1883\]/g" deploy/chart/kuiper/values.yaml
  150. helm install kuiper deploy/chart/kuiper --debug --dry-run
  151. helm install kuiper deploy/chart/kuiper
  152. while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=kuiper -o jsonpath='{.items[0].status.replicas}')" \
  153. != "$(kubectl get StatefulSet -l app.kubernetes.io/name=kuiper -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
  154. echo "=============================="
  155. kubectl describe pods kuiper-0
  156. echo "=============================="
  157. kubectl get pods
  158. echo "=============================="
  159. echo "waiting kuiper started"
  160. sleep 10
  161. done
  162. kuiper_address=$(kubectl get svc --namespace default kuiper -o jsonpath="{.spec.clusterIP}")
  163. if [ $(curl -w %{http_code} -fsSL -o /dev/null $kuiper_address:9081) != 200 ];then
  164. kubectl logs kuiper-0
  165. exit 1;
  166. fi
  167. - name: check kuiper
  168. env:
  169. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  170. timeout-minutes: 5
  171. run: |
  172. emqx_address=$(kubectl get svc --namespace default emqx -o jsonpath="{.spec.clusterIP}")
  173. kuiper_address=$(kubectl get svc --namespace default kuiper -o jsonpath="{.spec.clusterIP}")
  174. /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
  175. mkdir -p kuiper_logs
  176. kubectl exec kuiper-0 -- cat /kuiper/log/stream.log > kuiper_logs/stream.log
  177. - uses: actions/upload-artifact@v1
  178. if: always()
  179. with:
  180. name: kuiper_logs_with_helm
  181. path: ./kuiper_logs
  182. - uses: actions/upload-artifact@v1
  183. if: always()
  184. with:
  185. name: jmeter_logs_with_helm
  186. path: ./jmeter_logs
  187. - name: check logs
  188. run: |
  189. sudo apt update && sudo apt install -y libxml2-utils
  190. cd jmeter_logs
  191. if [ ! -z "$(cat *.jtl| grep '<failure>' | awk -F '>' '{print $2}' | awk -F '<' '{print $1}' | grep true)" ] ||
  192. [ "$(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
  193. echo -e "---------------------------------------------\n"
  194. echo "FVT tests error"
  195. exit 1
  196. fi