run_fvt_tests.yaml 15 KB

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