run_fvt_tests.yaml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. name: Run fvt tests
  2. concurrency:
  3. group: fvt-${{ github.event_name }}-${{ github.ref }}
  4. cancel-in-progress: true
  5. on:
  6. push:
  7. tags:
  8. - "*"
  9. pull_request:
  10. release:
  11. types:
  12. - published
  13. jobs:
  14. fvt_tests_with_edgex:
  15. runs-on: ubuntu-latest
  16. # Service containers to run with `runner-job`
  17. services:
  18. # Label used to access the service container
  19. redis:
  20. # Docker Hub image
  21. image: redis
  22. # Set health checks to wait until redis has started
  23. options: >-
  24. --health-cmd "redis-cli ping"
  25. --health-interval 10s
  26. --health-timeout 5s
  27. --health-retries 5
  28. ports:
  29. # Maps port 6379 on service container to the host
  30. - 6379:6379
  31. emqx:
  32. image: emqx/emqx:4.3.10
  33. ports:
  34. - 1883:1883
  35. - 18083:18083
  36. steps:
  37. - uses: actions/setup-go@v1
  38. with:
  39. go-version: '1.16'
  40. - uses: actions/setup-java@v1
  41. with:
  42. java-version: '8' # The JDK version to make available on the path.
  43. java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
  44. architecture: x64 # (x64 or x86) - defaults to x64
  45. - uses: actions/setup-python@v2 # For the test of python portable plugin
  46. with:
  47. python-version: '3.x'
  48. architecture: 'x64'
  49. - name: Install dependencies
  50. run: |
  51. python -m pip install --upgrade pip
  52. pip install pynng
  53. - name: install jmeter
  54. timeout-minutes: 10
  55. env:
  56. JMETER_VERSION: 5.3
  57. run: |
  58. wget --no-check-certificate -O /tmp/apache-jmeter.tgz https://downloads.apache.org//jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz
  59. cd /tmp && tar -xvf apache-jmeter.tgz
  60. echo "jmeter.save.saveservice.output_format=xml" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  61. echo "jmeter.save.saveservice.response_data.on_error=true" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  62. 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
  63. ln -s /tmp/apache-jmeter-$JMETER_VERSION /opt/jmeter
  64. - uses: actions/checkout@v2
  65. - name: build kuiper
  66. run: |
  67. sudo apt update && sudo apt install pkg-config libczmq-dev -y
  68. make build_with_edgex
  69. go build -trimpath -modfile extensions.mod --buildmode=plugin -o plugins/sources/Zmq.so extensions/sources/zmq/zmq.go
  70. go build -trimpath -modfile extensions.mod --buildmode=plugin -o plugins/functions/Image.so extensions/functions/image/*.go
  71. - name: run edgex && kuiper
  72. run: |
  73. ./test/setup_env.sh
  74. ln -s _build/kuiper-$(git describe --tags --always)-$(uname -s | tr "[A-Z]" "[a-z]")-amd64/log kuiper_logs
  75. - name: run fvt tests
  76. timeout-minutes: 8
  77. run: ./test/run_jmeter.sh with_edgex=true
  78. - uses: actions/upload-artifact@v1
  79. if: always()
  80. with:
  81. name: kuiper_logs_with_edgex
  82. path: ./kuiper_logs
  83. - uses: actions/upload-artifact@v1
  84. if: always()
  85. with:
  86. name: jmeter_logs_with_edgex
  87. path: ./jmeter_logs
  88. - name: check logs
  89. run: |
  90. sudo apt update && sudo apt install -y libxml2-utils
  91. cd jmeter_logs
  92. if [ ! -z "$(cat *.jtl| grep '<failure>' | awk -F '>' '{print $2}' | awk -F '<' '{print $1}' | grep true)" ] ||
  93. [ "$(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
  94. echo -e "---------------------------------------------\n"
  95. echo "FVT tests error"
  96. exit 1
  97. fi
  98. fvt_tests_redis_as_storage:
  99. runs-on: ubuntu-latest
  100. # Service containers to run with `runner-job`
  101. services:
  102. # Label used to access the service container
  103. redis:
  104. # Docker Hub image
  105. image: redis
  106. # Set health checks to wait until redis has started
  107. options: >-
  108. --health-cmd "redis-cli ping"
  109. --health-interval 10s
  110. --health-timeout 5s
  111. --health-retries 5
  112. ports:
  113. # Maps port 6379 on service container to the host
  114. - 6379:6379
  115. emqx:
  116. image: emqx/emqx:4.3.10
  117. ports:
  118. - 1883:1883
  119. - 18083:18083
  120. steps:
  121. - uses: actions/setup-go@v1
  122. with:
  123. go-version: '1.16'
  124. - uses: actions/setup-java@v1
  125. with:
  126. java-version: '8' # The JDK version to make available on the path.
  127. java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
  128. architecture: x64 # (x64 or x86) - defaults to x64
  129. - name: install jmeter
  130. timeout-minutes: 10
  131. env:
  132. JMETER_VERSION: 5.3
  133. run: |
  134. wget --no-check-certificate -O /tmp/apache-jmeter.tgz https://downloads.apache.org//jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz
  135. cd /tmp && tar -xvf apache-jmeter.tgz
  136. echo "jmeter.save.saveservice.output_format=xml" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  137. echo "jmeter.save.saveservice.response_data.on_error=true" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  138. 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
  139. ln -s /tmp/apache-jmeter-$JMETER_VERSION /opt/jmeter
  140. - uses: actions/checkout@v2
  141. - name: build kuiper
  142. run: |
  143. sudo apt update && sudo apt install pkg-config libczmq-dev -y
  144. make build_with_edgex
  145. go build -trimpath -modfile extensions.mod --buildmode=plugin -o plugins/sources/Zmq.so extensions/sources/zmq/zmq.go
  146. go build -trimpath -modfile extensions.mod --buildmode=plugin -o plugins/functions/Image.so extensions/functions/image/*.go
  147. - name: run edgex && kuiper
  148. env:
  149. KUIPER__STORE__TYPE: redis
  150. KUIPER__STORE__REDIS__PASSWORD: ""
  151. run: |
  152. ./test/setup_env.sh
  153. ln -s _build/kuiper-$(git describe --tags --always)-$(uname -s | tr "[A-Z]" "[a-z]")-amd64/log kuiper_logs
  154. - name: run fvt tests
  155. timeout-minutes: 8
  156. run: |
  157. rm -rf test/redis/set
  158. go build -o test/redis/set test/redis/set.go
  159. chmod +x test/redis/set
  160. fvt_dir=`pwd`
  161. /opt/jmeter/bin/jmeter.sh -Jjmeter.save.saveservice.output_format=xml -n -t test/redis_kv_storage.jmx -Dfvt="$fvt_dir" -l jmeter_logs/redis_kv_storage.jtl -j jmeter_logs/redis_kv_storage.log
  162. - uses: actions/upload-artifact@v1
  163. if: always()
  164. with:
  165. name: kuiper_logs_redis_storage
  166. path: ./kuiper_logs
  167. - uses: actions/upload-artifact@v1
  168. if: always()
  169. with:
  170. name: jmeter_logs_redis_storage
  171. path: ./jmeter_logs
  172. - name: check logs
  173. run: |
  174. sudo apt update && sudo apt install -y libxml2-utils
  175. cd jmeter_logs
  176. if [ ! -z "$(cat *.jtl| grep '<failure>' | awk -F '>' '{print $2}' | awk -F '<' '{print $1}' | grep true)" ] ||
  177. [ "$(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
  178. echo -e "---------------------------------------------\n"
  179. echo "FVT tests error"
  180. exit 1
  181. fi
  182. fvt_tests_for_container_in_helm:
  183. runs-on: ubuntu-latest
  184. steps:
  185. - uses: actions/checkout@v2
  186. - uses: actions/setup-java@v1
  187. with:
  188. java-version: '8' # The JDK version to make available on the path.
  189. java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
  190. architecture: x64 # (x64 or x86) - defaults to x64
  191. - name: install jmeter
  192. timeout-minutes: 10
  193. env:
  194. JMETER_VERSION: 5.3
  195. run: |
  196. wget --no-check-certificate -O /tmp/apache-jmeter.tgz https://downloads.apache.org//jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz
  197. cd /tmp && tar -xvf apache-jmeter.tgz
  198. echo "jmeter.save.saveservice.output_format=xml" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  199. echo "jmeter.save.saveservice.response_data.on_error=true" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  200. 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
  201. ln -s /tmp/apache-jmeter-$JMETER_VERSION /opt/jmeter
  202. - name: setup jmeter
  203. timeout-minutes: 10
  204. run: |
  205. 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
  206. 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
  207. 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
  208. 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
  209. 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
  210. 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
  211. - name: install docker
  212. run: |
  213. sudo apt-get remove docker docker-engine docker.io containerd runc
  214. sudo apt-get update
  215. sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
  216. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  217. sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  218. sudo apt-get update
  219. sudo apt-get install docker-ce docker-ce-cli containerd.io
  220. - name: install k3s
  221. env:
  222. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  223. run: |
  224. sudo sh -c "echo \"127.0.0.1 $(hostname)\" >> /etc/hosts"
  225. curl -sfL https://get.k3s.io | sh -
  226. sudo chmod 644 /etc/rancher/k3s/k3s.yaml
  227. kubectl cluster-info
  228. - name: install helm
  229. run: |
  230. curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
  231. sudo chmod 700 get_helm.sh
  232. sudo ./get_helm.sh
  233. helm version
  234. - name: build kuiper for docker
  235. run: sudo docker build --no-cache -t lfedge/ekuiper:$(git describe --tags --alway)-alpine -f deploy/docker/Dockerfile-alpine .
  236. - name: run emqx on chart
  237. env:
  238. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  239. timeout-minutes: 5
  240. run: |
  241. helm repo add emqx https://repos.emqx.io/charts
  242. helm repo update
  243. helm install emqx --set replicaCount=1 emqx/emqx
  244. while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.replicas}')" \
  245. != "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
  246. echo "waiting emqx started"
  247. sleep 10
  248. done
  249. - name: run kuiper for chart
  250. env:
  251. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  252. timeout-minutes: 5
  253. run: |
  254. version=$(git describe --tags --always)
  255. emqx_address=$(kubectl get svc --namespace default emqx -o jsonpath="{.spec.clusterIP}")
  256. sudo docker save lfedge/ekuiper:$version-alpine -o kuier.tar.gz
  257. sudo k3s ctr image import kuier.tar.gz
  258. sed -i -r "s/^appVersion: .*$/appVersion: \"${version}\"/g" deploy/chart/kuiper/Chart.yaml
  259. sed -i -r 's/ pullPolicy: .*$/ pullPolicy: Never/g' deploy/chart/kuiper/values.yaml
  260. sed -i -r "s/ servers: \[.*\]$/ servers: \[tcp:\/\/${emqx_address}:1883\]/g" deploy/chart/kuiper/values.yaml
  261. helm install kuiper deploy/chart/kuiper --debug --dry-run
  262. helm install kuiper deploy/chart/kuiper
  263. while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=kuiper -o jsonpath='{.items[0].status.replicas}')" \
  264. != "$(kubectl get StatefulSet -l app.kubernetes.io/name=kuiper -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
  265. echo "=============================="
  266. kubectl describe pods kuiper-0
  267. echo "=============================="
  268. kubectl get pods
  269. echo "=============================="
  270. echo "waiting kuiper started"
  271. sleep 10
  272. done
  273. kuiper_address=$(kubectl get svc --namespace default kuiper -o jsonpath="{.spec.clusterIP}")
  274. if [ $(curl -w %{http_code} -fsSL -o /dev/null $kuiper_address:9081) != 200 ];then
  275. kubectl logs kuiper-0
  276. exit 1;
  277. fi
  278. - name: check kuiper
  279. env:
  280. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  281. timeout-minutes: 5
  282. run: |
  283. emqx_address=$(kubectl get svc --namespace default emqx -o jsonpath="{.spec.clusterIP}")
  284. kuiper_address=$(kubectl get svc --namespace default kuiper -o jsonpath="{.spec.clusterIP}")
  285. /opt/jmeter/bin/jmeter.sh -Jjmeter.save.saveservice.output_format=xml -n -t test/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
  286. mkdir -p kuiper_logs
  287. kubectl exec kuiper-0 -- cat /kuiper/log/stream.log > kuiper_logs/stream.log
  288. - uses: actions/upload-artifact@v1
  289. if: always()
  290. with:
  291. name: kuiper_logs_with_helm
  292. path: ./kuiper_logs
  293. - uses: actions/upload-artifact@v1
  294. if: always()
  295. with:
  296. name: jmeter_logs_with_helm
  297. path: ./jmeter_logs
  298. - name: check logs
  299. run: |
  300. sudo apt update && sudo apt install -y libxml2-utils
  301. cd jmeter_logs
  302. if [ ! -z "$(cat *.jtl| grep '<failure>' | awk -F '>' '{print $2}' | awk -F '<' '{print $1}' | grep true)" ] ||
  303. [ "$(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
  304. echo -e "---------------------------------------------\n"
  305. echo "FVT tests error"
  306. exit 1
  307. fi