run_fvt_tests.yaml 14 KB

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