run_fvt_tests.yaml 13 KB

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