Skip to content

Commit

Permalink
Merge pull request #172 from emqx/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
jinfahua authored Mar 23, 2020
2 parents e89863b + 80f92e1 commit 35c4940
Show file tree
Hide file tree
Showing 90 changed files with 7,995 additions and 1,006 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: prepare
run: |
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install curl zip unzip gnu-sed upx
brew install curl zip unzip gnu-sed upx pkg-config zmq
echo "/usr/local/bin:$PATH" >> ~/.bashrc
- name: build
run: |
Expand Down
210 changes: 201 additions & 9 deletions .github/workflows/fvt_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- prereleased

jobs:
fvt_tests:
fvt_tests_with_edgex:
runs-on: ubuntu-latest

steps:
Expand All @@ -21,11 +21,12 @@ jobs:
java-version: '8' # The JDK version to make available on the path.
java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
architecture: x64 # (x64 or x86) - defaults to x64
- name: set up jmeter
- name: install jmeter
timeout-minutes: 10
env:
JMETER_VERSION: 5.2.1
run: |
wget -O /tmp/apache-jmeter.tgz http://mirror.bit.edu.cn/apache//jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz
wget -O /tmp/apache-jmeter.tgz http://us.mirrors.quenda.co/apache//jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz
cd /tmp && tar -xvf apache-jmeter.tgz
echo "jmeter.save.saveservice.output_format=xml" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
echo "jmeter.save.saveservice.response_data.on_error=true" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
Expand All @@ -39,17 +40,27 @@ jobs:
sudo dpkg -i emqx.deb
- uses: actions/checkout@v2
- name: build kuiper
run: make
- name: run emqx and kuiper
run: sudo ./fvt_scripts/setup_env.sh
run: |
sudo apt update && sudo apt install pkg-config libczmq-dev -y
make build_with_edgex
- name: run edgex && emqx && kuiper
run: |
sudo ./fvt_scripts/setup_env.sh
ln -s _build/kuiper-$(git describe --tags --always)-$(uname -s | tr "[A-Z]" "[a-z]")-x86_64/log kuiper_logs
- name: run fvt tests
timeout-minutes: 5
run: ./fvt_scripts/run_jmeter.sh
run: ./fvt_scripts/run_jmeter.sh with_edgex=true
- uses: actions/upload-artifact@v1
if: always()
with:
name: kuiper_logs_with_edgex
path: ./kuiper_logs
- uses: actions/upload-artifact@v1
if: always()
with:
name: jmeter.logs
name: jmeter_logs_with_edgex
path: ./jmeter_logs
- name: checkout out
- name: check logs
run: |
sudo apt update && sudo apt install -y libxml2-utils
cd jmeter_logs
Expand All @@ -59,3 +70,184 @@ jobs:
exit 1
fi
fvt_tests_without_edgex:
runs-on: ubuntu-latest

steps:
- uses: actions/setup-go@v1
with:
go-version: '1.11.5'
- uses: actions/setup-java@v1
with:
java-version: '8' # The JDK version to make available on the path.
java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
architecture: x64 # (x64 or x86) - defaults to x64
- name: install jmeter
timeout-minutes: 10
env:
JMETER_VERSION: 5.2.1
run: |
wget -O /tmp/apache-jmeter.tgz http://us.mirrors.quenda.co/apache//jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz
cd /tmp && tar -xvf apache-jmeter.tgz
echo "jmeter.save.saveservice.output_format=xml" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
echo "jmeter.save.saveservice.response_data.on_error=true" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
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
ln -s /tmp/apache-jmeter-$JMETER_VERSION /opt/jmeter
- name: install emqx
env:
EMQX_VERSION: v4.0.2
run: |
wget -O emqx.deb https://www.emqx.io/downloads/broker/v4.0.2/emqx-ubuntu18.04-${EMQX_VERSION}_amd64.deb
sudo dpkg -i emqx.deb
- uses: actions/checkout@v2
- name: build kuiper
run: |
sudo apt update && sudo apt install pkg-config libczmq-dev -y
make
- name: run edgex && emqx && kuiper
run: |
sudo ./fvt_scripts/setup_env.sh
ln -s _build/kuiper-$(git describe --tags --always)-$(uname -s | tr "[A-Z]" "[a-z]")-x86_64/log kuiper_logs
- name: run fvt tests
timeout-minutes: 5
run: ./fvt_scripts/run_jmeter.sh with_edgex=false
- uses: actions/upload-artifact@v1
if: always()
with:
name: kuiper_logs_without_edgex
path: ./kuiper_logs
- uses: actions/upload-artifact@v1
if: always()
with:
name: jmeter_logs_without_edgex
path: ./jmeter_logs
- name: check logs
run: |
sudo apt update && sudo apt install -y libxml2-utils
cd jmeter_logs
if [ "$(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
echo -e "---------------------------------------------\n"
echo "FVT tests error"
exit 1
fi
fvt_tests_for_container_in_helm:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: '8' # The JDK version to make available on the path.
java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
architecture: x64 # (x64 or x86) - defaults to x64
- name: install jmeter
timeout-minutes: 10
env:
JMETER_VERSION: 5.2.1
run: |
wget -O /tmp/apache-jmeter.tgz http://us.mirrors.quenda.co/apache//jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz
cd /tmp && tar -xvf apache-jmeter.tgz
echo "jmeter.save.saveservice.output_format=xml" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
echo "jmeter.save.saveservice.response_data.on_error=true" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
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
ln -s /tmp/apache-jmeter-$JMETER_VERSION /opt/jmeter
- name: setup jmeter
timeout-minutes: 10
run: |
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
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
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
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
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
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
- name: install docker
run: |
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
- name: install k3s
env:
KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
run: |
sudo sh -c "echo \"127.0.0.1 $(hostname)\" >> /etc/hosts"
curl -sfL https://get.k3s.io | sh -
sudo chmod 644 /etc/rancher/k3s/k3s.yaml
kubectl cluster-info
- name: install helm
run: |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
sudo chmod 700 get_helm.sh
sudo ./get_helm.sh
helm version
- name: build kuiper for docker
run: make docker
- name: run emqx on chart
env:
KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
timeout-minutes: 5
run: |
helm repo add emqx https://repos.emqx.io/charts
helm repo update
helm install emqx --set replicaCount=1 emqx/emqx
while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.replicas}')" \
!= "$(kubectl get StatefulSet -l app.kubernetes.io/name=emqx -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
echo "waiting emqx started"
sleep 10
done
- name: run kuiper for chart
env:
KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
timeout-minutes: 5
run: |
version=$(git describe --tags --always)
emqx_address=$(kubectl get svc --namespace default emqx -o jsonpath="{.spec.clusterIP}")
sudo docker save emqx/kuiper:$version -o kuier.tar.gz
sudo k3s ctr image import kuier.tar.gz
sed -i -r "s/^appVersion: .*$/appVersion: ${version}/g" deploy/chart/kuiper/Chart.yaml
sed -i -r 's/ pullPolicy: .*$/ pullPolicy: Never/g' deploy/chart/kuiper/values.yaml
sed -i -r "s/ servers: \[.*\]$/ servers: \[tcp:\/\/${emqx_address}:1883\]/g" deploy/chart/kuiper/values.yaml
helm install kuiper deploy/chart/kuiper
while [ "$(kubectl get StatefulSet -l app.kubernetes.io/name=kuiper -o jsonpath='{.items[0].status.replicas}')" \
!= "$(kubectl get StatefulSet -l app.kubernetes.io/name=kuiper -o jsonpath='{.items[0].status.readyReplicas}')" ]; do
echo "waiting kuiper started"
sleep 10
done
kuiper_address=$(kubectl get svc --namespace default kuiper -o jsonpath="{.spec.clusterIP}")
if [ $(curl -w %{http_code} -fsSL -o /dev/null $kuiper_address:9081/rules) != 200 ];then exit 1; fi
- name: check kuiper
env:
KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
timeout-minutes: 5
run: |
emqx_address=$(kubectl get svc --namespace default emqx -o jsonpath="{.spec.clusterIP}")
kuiper_address=$(kubectl get svc --namespace default kuiper -o jsonpath="{.spec.clusterIP}")
/opt/jmeter/bin/jmeter.sh -Jjmeter.save.saveservice.output_format=xml -n -t fvt_scripts/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
mkdir -p kuiper_logs
kubectl exec kuiper-0 -- cat /kuiper/log/stream.log > kuiper_logs/stream.log
- uses: actions/upload-artifact@v1
if: always()
with:
name: kuiper_logs_with_helm
path: ./kuiper_logs
- uses: actions/upload-artifact@v1
if: always()
with:
name: jmeter_logs_with_helm
path: ./jmeter_logs
- name: check logs
run: |
sudo apt update && sudo apt install -y libxml2-utils
cd jmeter_logs
if [ "$(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
echo -e "---------------------------------------------\n"
echo "FVT tests error"
exit 1
fi
1 change: 1 addition & 0 deletions .github/workflows/run_test_case.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ jobs:
go build --buildmode=plugin -o plugins/functions/Echo.so plugins/functions/echo.go
go build --buildmode=plugin -o plugins/functions/CountPlusOne.so plugins/functions/countPlusOne.go
go test ./...
go test --tags=edgex ./...
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM golang:1.13.4 AS builder

COPY . /go/kuiper

RUN apt update && apt install -y zip upx pkg-config libczmq-dev && make -C /go/kuiper pkg
5 changes: 0 additions & 5 deletions Dockerfile-by-corss-build

This file was deleted.

48 changes: 37 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
BUILD_PATH ?= _build
PACKAGES_PATH ?= _packages

GO111MODULE ?=
GOPROXY ?= https://goproxy.io

CGO_ENABLED ?= 1
GOOS ?= ""
GOARCH ?= ""
Expand All @@ -25,7 +22,13 @@ endif
TARGET ?= emqx/kuiper

.PHONY: build
build:
build: build_without_edgex

.PHONY:pkg
pkg: pkg_without_edgex

.PHONY: build_prepare
build_prepare:
@mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/bin
@mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/etc
@mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/etc/sources
Expand All @@ -39,19 +42,42 @@ build:

@cp -r etc/* $(BUILD_PATH)/$(PACKAGE_NAME)/etc

.PHONY: build_without_edgex
build_without_edgex: build_prepare
@if [ ! -z $(GOOS) ] && [ ! -z $(GOARCH) ] && [ $(CGO_ENABLED) == 0 ];then \
GO111MODULE=on GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build -ldflags="-s -w -X main.Version=$(VERSION)" -o cli xstream/cli/main.go; \
GO111MODULE=on GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build -ldflags="-s -w -X main.Version=$(VERSION)" -o server xstream/server/main.go; \
else \
GO111MODULE=on CGO_ENABLED=1 go build -ldflags="-s -w -X main.Version=$(VERSION)" -o cli xstream/cli/main.go; \
GO111MODULE=on CGO_ENABLED=1 go build -ldflags="-s -w -X main.Version=$(VERSION)" -o server xstream/server/main.go; \
fi
@if [ ! -z $$(which upx) ]; then upx ./cli; upx ./server; fi
@mv ./cli ./server $(BUILD_PATH)/$(PACKAGE_NAME)/bin
@echo "Build successfully"

.PHONY: pkg_without_edgex
pkg_without_edgex: build_without_edgex
@make real_pkg

.PHONY: build_with_edgex
build_with_edgex: build_prepare
@if [ ! -z $(GOOS) ] && [ ! -z $(GOARCH) ] && [ $(CGO_ENABLED) == 0 ];then \
GO111MODULE=on GOPROXY=https://goproxy.io GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build -ldflags="-s -w -X main.Version=$(VERSION)" -o cli xstream/cli/main.go; \
GO111MODULE=on GOPROXY=https://goproxy.io GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build -ldflags="-s -w -X main.Version=$(VERSION)" -o server xstream/server/main.go; \
GO111MODULE=on GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build -ldflags="-s -w -X main.Version=$(VERSION)" -tags edgex -o cli xstream/cli/main.go; \
GO111MODULE=on GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build -ldflags="-s -w -X main.Version=$(VERSION)" -tags edgex -o server xstream/server/main.go; \
else \
GO111MODULE=on GOPROXY=https://goproxy.io CGO_ENABLED=1 go build -ldflags="-s -w -X main.Version=$(VERSION)" -o cli xstream/cli/main.go; \
GO111MODULE=on GOPROXY=https://goproxy.io CGO_ENABLED=1 go build -ldflags="-s -w -X main.Version=$(VERSION)" -o server xstream/server/main.go; \
GO111MODULE=on CGO_ENABLED=1 go build -ldflags="-s -w -X main.Version=$(VERSION)" -tags edgex -o cli xstream/cli/main.go; \
GO111MODULE=on CGO_ENABLED=1 go build -ldflags="-s -w -X main.Version=$(VERSION)" -tags edgex -o server xstream/server/main.go; \
fi
@if [ ! -z $$(which upx) ]; then upx ./cli; upx ./server; fi
@mv ./cli ./server $(BUILD_PATH)/$(PACKAGE_NAME)/bin
@echo "Build successfully"

.PHONY: pkg
pkg: build
.PHONY: pkg_whit_edgex
pkg_whit_edgex: build_with_edgex
@make real_pkg

.PHONY: real_pkg
real_pkg:
@mkdir -p $(PACKAGES_PATH)
@cd $(BUILD_PATH) && zip -rq $(PACKAGE_NAME).zip $(PACKAGE_NAME)
@cd $(BUILD_PATH) && tar -czf $(PACKAGE_NAME).tar.gz $(PACKAGE_NAME)
Expand All @@ -68,7 +94,7 @@ cross_build: cross_prepare
--platform=linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/ppc64le \
-t cross_build \
--output type=tar,dest=cross_build.tar \
-f ./Dockerfile-by-corss-build .
-f ./Dockerfile .

@mkdir -p $(PACKAGES_PATH)
@tar -xvf cross_build.tar --wildcards linux_amd64/go/kuiper/_packages/* \
Expand Down
16 changes: 13 additions & 3 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,21 @@ Kuiper 可以运行在各类物联网的边缘使用场景中,比如工业物
#### 编译
+ 编译二进制:``$ make``
+ 编译二进制:
+ 安装文件打包:`` $ make pkg``
- 编译二进制文件: `$ make`
+ Docker 镜像:``$ make docker``
- 编译支持 EdgeX 的二进制文件: `$ make build_with_edgex`
+ 安装文件打包:
- 安装文件打包:: `$ make pkg`
- 支持 EdgeX 的安装文件打包: `$ make pkg_with_edgex`
+ Docker 镜像:`$ make docker`
> Docker 镜像默认支持 EdgeX
如果您要实现交叉编译,请参考[此文档](docs/zh_CN/cross-compile.md)。
Expand Down
Loading

0 comments on commit 35c4940

Please sign in to comment.