run_fvt_tests.yaml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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. for file in `ls *.jtl`
  93. do
  94. if [ ! -z "$(cat $file| grep '<failure>' | awk -F '>' '{print $2}' | awk -F '<' '{print $1}' | grep true)" ] ||
  95. [ "$(xmllint --format --xpath '/testResults/sample/@rc' $file | sed -r 's/ /\n/g;' | sort -u | grep -E 'rc=\"[45][0-9][0-9]\"|rc=\"\"')" != "" ]; then
  96. echo -e "---------------------------------------------\n"
  97. echo "FVT tests error for $file"
  98. exit 1
  99. fi
  100. done
  101. fvt_tests_redis_as_storage:
  102. runs-on: ubuntu-latest
  103. # Service containers to run with `runner-job`
  104. services:
  105. # Label used to access the service container
  106. redis:
  107. # Docker Hub image
  108. image: redis
  109. # Set health checks to wait until redis has started
  110. options: >-
  111. --health-cmd "redis-cli ping"
  112. --health-interval 10s
  113. --health-timeout 5s
  114. --health-retries 5
  115. ports:
  116. # Maps port 6379 on service container to the host
  117. - 6379:6379
  118. emqx:
  119. image: emqx/emqx:4.3.10
  120. ports:
  121. - 1883:1883
  122. - 18083:18083
  123. steps:
  124. - uses: actions/setup-go@v1
  125. with:
  126. go-version: '1.16'
  127. - uses: actions/setup-java@v1
  128. with:
  129. java-version: '8' # The JDK version to make available on the path.
  130. java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
  131. architecture: x64 # (x64 or x86) - defaults to x64
  132. - name: install jmeter
  133. timeout-minutes: 10
  134. env:
  135. JMETER_VERSION: 5.3
  136. run: |
  137. wget --no-check-certificate -O /tmp/apache-jmeter.tgz https://downloads.apache.org//jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz
  138. cd /tmp && tar -xvf apache-jmeter.tgz
  139. echo "jmeter.save.saveservice.output_format=xml" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  140. echo "jmeter.save.saveservice.response_data.on_error=true" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  141. 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
  142. ln -s /tmp/apache-jmeter-$JMETER_VERSION /opt/jmeter
  143. - uses: actions/checkout@v2
  144. - name: build kuiper
  145. run: |
  146. sudo apt update && sudo apt install pkg-config libczmq-dev -y
  147. make build_with_edgex
  148. go build -trimpath -modfile extensions.mod --buildmode=plugin -o plugins/sources/Zmq.so extensions/sources/zmq/zmq.go
  149. go build -trimpath -modfile extensions.mod --buildmode=plugin -o plugins/functions/Image.so extensions/functions/image/*.go
  150. - name: run edgex && kuiper
  151. env:
  152. KUIPER__STORE__TYPE: redis
  153. KUIPER__STORE__REDIS__PASSWORD: ""
  154. run: |
  155. ./test/setup_env.sh
  156. ln -s _build/kuiper-$(git describe --tags --always)-$(uname -s | tr "[A-Z]" "[a-z]")-amd64/log kuiper_logs
  157. - name: run fvt tests
  158. timeout-minutes: 8
  159. run: |
  160. rm -rf test/redis/set
  161. go build -o test/redis/set test/redis/set.go
  162. chmod +x test/redis/set
  163. fvt_dir=`pwd`
  164. /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
  165. - uses: actions/upload-artifact@v1
  166. if: always()
  167. with:
  168. name: kuiper_logs_redis_storage
  169. path: ./kuiper_logs
  170. - uses: actions/upload-artifact@v1
  171. if: always()
  172. with:
  173. name: jmeter_logs_redis_storage
  174. path: ./jmeter_logs
  175. - name: check logs
  176. run: |
  177. sudo apt update && sudo apt install -y libxml2-utils
  178. cd jmeter_logs
  179. for file in `ls *.jtl`
  180. do
  181. if [ ! -z "$(cat $file| grep '<failure>' | awk -F '>' '{print $2}' | awk -F '<' '{print $1}' | grep true)" ] ||
  182. [ "$(xmllint --format --xpath '/testResults/sample/@rc' $file | sed -r 's/ /\n/g;' | sort -u | grep -E 'rc=\"[45][0-9][0-9]\"|rc=\"\"')" != "" ]; then
  183. echo -e "---------------------------------------------\n"
  184. echo "FVT tests error for $file"
  185. exit 1
  186. fi
  187. done
  188. fvt_tests_for_container_in_helm:
  189. runs-on: ubuntu-latest
  190. steps:
  191. - uses: actions/checkout@v2
  192. - uses: actions/setup-java@v1
  193. with:
  194. java-version: '8' # The JDK version to make available on the path.
  195. java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
  196. architecture: x64 # (x64 or x86) - defaults to x64
  197. - name: install jmeter
  198. timeout-minutes: 10
  199. env:
  200. JMETER_VERSION: 5.3
  201. run: |
  202. wget --no-check-certificate -O /tmp/apache-jmeter.tgz https://downloads.apache.org//jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz
  203. cd /tmp && tar -xvf apache-jmeter.tgz
  204. echo "jmeter.save.saveservice.output_format=xml" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  205. echo "jmeter.save.saveservice.response_data.on_error=true" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
  206. 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
  207. ln -s /tmp/apache-jmeter-$JMETER_VERSION /opt/jmeter
  208. - name: setup jmeter
  209. timeout-minutes: 10
  210. run: |
  211. 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
  212. 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
  213. 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
  214. 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
  215. 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
  216. 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
  217. - name: install docker
  218. run: |
  219. sudo apt-get remove docker docker-engine docker.io containerd runc
  220. sudo apt-get update
  221. sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
  222. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  223. sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  224. sudo apt-get update
  225. sudo apt-get install docker-ce docker-ce-cli containerd.io
  226. - name: install k3s
  227. env:
  228. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  229. run: |
  230. sudo sh -c "echo \"127.0.0.1 $(hostname)\" >> /etc/hosts"
  231. curl -sfL https://get.k3s.io | sh -
  232. sudo chmod 644 /etc/rancher/k3s/k3s.yaml
  233. kubectl cluster-info
  234. - name: install helm
  235. run: |
  236. curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
  237. sudo chmod 700 get_helm.sh
  238. sudo ./get_helm.sh
  239. helm version
  240. - name: build kuiper for docker
  241. run: sudo docker build --no-cache -t lfedge/ekuiper:$(git describe --tags --alway)-alpine -f deploy/docker/Dockerfile-alpine .
  242. - name: run emqx on chart
  243. env:
  244. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  245. timeout-minutes: 5
  246. run: |
  247. helm repo add emqx https://repos.emqx.io/charts
  248. helm repo update
  249. helm install emqx --set replicaCount=1 emqx/emqx
  250. while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.replicas}')" \
  251. != "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
  252. echo "waiting emqx started"
  253. sleep 10
  254. done
  255. - name: run kuiper for chart
  256. env:
  257. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  258. timeout-minutes: 5
  259. run: |
  260. version=$(git describe --tags --always)
  261. emqx_address=$(kubectl get svc --namespace default emqx -o jsonpath="{.spec.clusterIP}")
  262. sudo docker save lfedge/ekuiper:$version-alpine -o kuier.tar.gz
  263. sudo k3s ctr image import kuier.tar.gz
  264. sed -i -r "s/^appVersion: .*$/appVersion: \"${version}\"/g" deploy/chart/kuiper/Chart.yaml
  265. sed -i -r 's/ pullPolicy: .*$/ pullPolicy: Never/g' deploy/chart/kuiper/values.yaml
  266. sed -i -r "s/ servers: \[.*\]$/ servers: \[tcp:\/\/${emqx_address}:1883\]/g" deploy/chart/kuiper/values.yaml
  267. helm install kuiper deploy/chart/kuiper --debug --dry-run
  268. helm install kuiper deploy/chart/kuiper
  269. while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=kuiper -o jsonpath='{.items[0].status.replicas}')" \
  270. != "$(kubectl get StatefulSet -l app.kubernetes.io/name=kuiper -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
  271. echo "=============================="
  272. kubectl describe pods kuiper-0
  273. echo "=============================="
  274. kubectl get pods
  275. echo "=============================="
  276. echo "waiting kuiper started"
  277. sleep 10
  278. done
  279. kuiper_address=$(kubectl get svc --namespace default kuiper -o jsonpath="{.spec.clusterIP}")
  280. if [ $(curl -w %{http_code} -fsSL -o /dev/null $kuiper_address:9081) != 200 ];then
  281. kubectl logs kuiper-0
  282. exit 1;
  283. fi
  284. - name: check kuiper
  285. env:
  286. KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
  287. timeout-minutes: 5
  288. run: |
  289. emqx_address=$(kubectl get svc --namespace default emqx -o jsonpath="{.spec.clusterIP}")
  290. kuiper_address=$(kubectl get svc --namespace default kuiper -o jsonpath="{.spec.clusterIP}")
  291. /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
  292. mkdir -p kuiper_logs
  293. kubectl exec kuiper-0 -- cat /kuiper/log/stream.log > kuiper_logs/stream.log
  294. - uses: actions/upload-artifact@v1
  295. if: always()
  296. with:
  297. name: kuiper_logs_with_helm
  298. path: ./kuiper_logs
  299. - uses: actions/upload-artifact@v1
  300. if: always()
  301. with:
  302. name: jmeter_logs_with_helm
  303. path: ./jmeter_logs
  304. - name: check logs
  305. run: |
  306. sudo apt update && sudo apt install -y libxml2-utils
  307. cd jmeter_logs
  308. for file in `ls *.jtl`
  309. do
  310. if [ ! -z "$(cat $file| grep '<failure>' | awk -F '>' '{print $2}' | awk -F '<' '{print $1}' | grep true)" ] ||
  311. [ "$(xmllint --format --xpath '/testResults/sample/@rc' $file | sed -r 's/ /\n/g;' | sort -u | grep -E 'rc=\"[45][0-9][0-9]\"|rc=\"\"')" != "" ]; then
  312. echo -e "---------------------------------------------\n"
  313. echo "FVT tests error for $file"
  314. exit 1
  315. fi
  316. done