-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: wrongerror <wangyifei@kubesphere.io>
- Loading branch information
1 parent
0b12620
commit 3cbd781
Showing
35 changed files
with
4,954 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
#! /bin/bash | ||
|
||
# Copyright 2022 The OpenFunction Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
function verify_bindings_http() { | ||
kubectl apply -f test/http/bindings/manifests.yaml | ||
|
||
data_expected="hello: world" | ||
plugin_expected="sum: 2" | ||
while /bin/true; do | ||
data_result=$(kubectl logs --tail=2 -l app="bindings-target" -c target | grep Data | awk '{ print $8 }' | yq -P '.' -) | ||
plugin_result=$(kubectl logs --tail=2 -l app="bindings-target" -c target | grep plugin | awk '{ print $8 }' | yq -P '.' -) | ||
if [ "${data_result}" != "${data_expected}" ] || [ "${plugin_result}" != "${plugin_expected}" ]; then | ||
sleep 1 | ||
continue | ||
else | ||
echo "bindings http tested successfully!" | ||
kubectl delete -f test/http/bindings/manifests.yaml | ||
break | ||
fi | ||
done | ||
} | ||
|
||
function verify_pubsub_http() { | ||
kubectl apply -f test/http/pubsub/manifests.yaml | ||
|
||
data_expected="hello: world" | ||
plugin_expected="sum: 2" | ||
while /bin/true; do | ||
data_result=$(kubectl logs --tail=2 -l app="pubsub-subscriber" -c sub | grep Data | awk '{ print $8 }' | yq -P '.' -) | ||
plugin_result=$(kubectl logs --tail=2 -l app="pubsub-subscriber" -c sub | grep plugin | awk '{ print $8 }' | yq -P '.' -) | ||
if [ "${data_result}" != "${data_expected}" ] || [ "${plugin_result}" != "${plugin_expected}" ]; then | ||
sleep 1 | ||
continue | ||
else | ||
echo "bindings http tested successfully!" | ||
kubectl delete -f test/http/pubsub/manifests.yaml | ||
break | ||
fi | ||
done | ||
} | ||
|
||
function verify_bindings_grpc() { | ||
kubectl apply -f test/grpc/bindings/manifests.yaml | ||
|
||
data_expected="hello: world" | ||
plugin_expected="sum: 2" | ||
while /bin/true; do | ||
data_result=$(kubectl logs --tail=2 -l app="bindings-target" -c target | grep Data | awk '{ print $8 }' | yq -P '.' -) | ||
plugin_result=$(kubectl logs --tail=2 -l app="bindings-target" -c target | grep plugin | awk '{ print $8 }' | yq -P '.' -) | ||
if [ "${data_result}" != "${data_expected}" ] || [ "${plugin_result}" != "${plugin_expected}" ]; then | ||
sleep 1 | ||
continue | ||
else | ||
echo "bindings http tested successfully!" | ||
kubectl delete -f test/grpc/bindings/manifests.yaml | ||
break | ||
fi | ||
done | ||
} | ||
|
||
function verify_pubsub_grpc() { | ||
kubectl apply -f test/grpc/pubsub/manifests.yaml | ||
|
||
data_expected="hello: world" | ||
plugin_expected="sum: 2" | ||
while /bin/true; do | ||
data_result=$(kubectl logs --tail=2 -l app="pubsub-subscriber" -c sub | grep Data | awk '{ print $8 }' | yq -P '.' -) | ||
plugin_result=$(kubectl logs --tail=2 -l app="pubsub-subscriber" -c sub | grep plugin | awk '{ print $8 }' | yq -P '.' -) | ||
if [ "${data_result}" != "${data_expected}" ] || [ "${plugin_result}" != "${plugin_expected}" ]; then | ||
sleep 1 | ||
continue | ||
else | ||
echo "bindings http tested successfully!" | ||
kubectl delete -f test/grpc/pubsub/manifests.yaml | ||
break | ||
fi | ||
done | ||
} | ||
|
||
case $1 in | ||
|
||
bindings_http) | ||
verify_bindings_http | ||
;; | ||
|
||
pubsub_http) | ||
verify_pubsub_http | ||
;; | ||
|
||
bindings_grpc) | ||
verify_bindings_grpc | ||
;; | ||
|
||
pubsub_grpc) | ||
verify_pubsub_grpc | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
name: Main CI | ||
|
||
on: | ||
pull_request: | ||
branches: [ main ] | ||
paths: | ||
- '.github/workflows/**' | ||
- 'pkg/**' | ||
- 'test/**' | ||
- 'go.mod' | ||
- 'main.go' | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.18 | ||
|
||
- name: Build | ||
run: go build -v ./... | ||
|
||
- name: Test | ||
run: go test -v ./... | ||
|
||
e2e_test: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
name: E2E Tests | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.18.x | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Create kind cluster | ||
uses: container-tools/kind-action@v1 | ||
|
||
- name: install yq | ||
env: | ||
VERSION: v4.22.1 | ||
BINARY: yq_linux_amd64 | ||
run: | | ||
wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - |\ | ||
tar xz && mv ${BINARY} /usr/local/bin/yq | ||
- name: Install dependent components | ||
run: | | ||
# Install Dapr | ||
dapr -v || (wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash) | ||
dapr init -k --runtime-version 1.8.3 --log-as-json --wait --timeout 600 | ||
# Install kafka | ||
helm repo add strimzi https://strimzi.io/charts/ | ||
helm install kafka-operator -n default strimzi/strimzi-kafka-operator | ||
kubectl apply -f test/kafka.yaml | ||
- name: Build and Push dapr-proxy image | ||
run: | | ||
docker build . -t openfunctiondev/dapr-proxy:ci -f Dockerfile --build-arg GOPROXY="https://proxy.golang.org" | ||
docker push openfunctiondev/dapr-proxy:ci | ||
- name: Bindings HTTP e2e test | ||
run: | | ||
chmod +x "${GITHUB_WORKSPACE}/.github/workflows/e2e-test.sh" | ||
bash "${GITHUB_WORKSPACE}"/.github/workflows/e2e-test.sh bindings_http | ||
- name: Pubsub HTTP e2e test | ||
run: | | ||
chmod +x "${GITHUB_WORKSPACE}/.github/workflows/e2e-test.sh" | ||
bash "${GITHUB_WORKSPACE}"/.github/workflows/e2e-test.sh pubsub_http | ||
- name: Bindings GRPC e2e test | ||
run: | | ||
chmod +x "${GITHUB_WORKSPACE}/.github/workflows/e2e-test.sh" | ||
bash "${GITHUB_WORKSPACE}"/.github/workflows/e2e-test.sh bindings_grpc | ||
- name: Pubsub GRPC e2e test | ||
run: | | ||
chmod +x "${GITHUB_WORKSPACE}/.github/workflows/e2e-test.sh" | ||
bash "${GITHUB_WORKSPACE}"/.github/workflows/e2e-test.sh pubsub_grpc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
ARG GOPROXY="https://goproxy.cn" | ||
|
||
# Build the dapr-proxy binary | ||
FROM golang:1.18 as builder | ||
WORKDIR /workspace | ||
|
||
# Copy the Go Modules manifests | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
# Download go module | ||
RUN go env -w GOPROXY=${GOPROXY} && go mod download | ||
|
||
# Copy the go source | ||
Copy pkg/ pkg/ | ||
COPY main.go main.go | ||
|
||
# Build | ||
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o proxy main.go | ||
|
||
# Use distroless as minimal base image to package the proxy binary | ||
FROM openfunction/distroless-static:nonroot | ||
WORKDIR / | ||
COPY --from=builder /workspace/proxy . | ||
USER 65532:65532 | ||
|
||
ENTRYPOINT ["/proxy"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
module github.com/OpenFunction/dapr-proxy | ||
|
||
go 1.18 | ||
|
||
require ( | ||
github.com/OpenFunction/functions-framework-go v0.0.0-20220925145105-86f7bcc9cf8c | ||
github.com/dapr/components-contrib v1.8.1-rc.1 | ||
github.com/dapr/dapr v1.8.3 | ||
github.com/dapr/go-sdk v1.5.0 | ||
github.com/fatih/structs v1.1.0 | ||
github.com/pkg/errors v0.9.1 | ||
github.com/valyala/fasthttp v1.31.1-0.20211216042702-258a4c17b4f4 | ||
go.opencensus.io v0.23.0 | ||
google.golang.org/grpc v1.47.0 | ||
k8s.io/klog/v2 v2.30.0 | ||
) | ||
|
||
require ( | ||
contrib.go.opencensus.io/exporter/prometheus v0.4.1 // indirect | ||
contrib.go.opencensus.io/exporter/zipkin v0.1.1 // indirect | ||
github.com/AdhityaRamadhanus/fasthttpcors v0.0.0-20170121111917-d4c07198763a // indirect | ||
github.com/PuerkitoBio/purell v1.1.1 // indirect | ||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect | ||
github.com/SkyAPM/go2sky v1.4.1 // indirect | ||
github.com/andybalholm/brotli v1.0.2 // indirect | ||
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20210826220005-b48c857c3a0e // indirect | ||
github.com/beorn7/perks v1.0.1 // indirect | ||
github.com/cenkalti/backoff/v4 v4.1.2 // indirect | ||
github.com/cespare/xxhash/v2 v2.1.2 // indirect | ||
github.com/cloudevents/sdk-go/v2 v2.4.1 // indirect | ||
github.com/dapr/kit v0.0.2-0.20210614175626-b9074b64d233 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/evanphx/json-patch v4.12.0+incompatible // indirect | ||
github.com/fasthttp/router v1.3.8 // indirect | ||
github.com/fsnotify/fsnotify v1.5.4 // indirect | ||
github.com/ghodss/yaml v1.0.0 // indirect | ||
github.com/go-kit/log v0.2.0 // indirect | ||
github.com/go-logfmt/logfmt v0.5.1 // indirect | ||
github.com/go-logr/logr v1.2.3 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect | ||
github.com/golang/mock v1.6.0 // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/google/cel-go v0.9.0 // indirect | ||
github.com/google/go-cmp v0.5.8 // indirect | ||
github.com/google/gofuzz v1.2.0 // indirect | ||
github.com/google/uuid v1.3.0 // indirect | ||
github.com/googleapis/gnostic v0.5.5 // indirect | ||
github.com/gorilla/mux v1.8.0 // indirect | ||
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect | ||
github.com/hashicorp/errwrap v1.1.0 // indirect | ||
github.com/hashicorp/go-multierror v1.1.1 // indirect | ||
github.com/hashicorp/golang-lru v0.5.4 // indirect | ||
github.com/imdario/mergo v0.3.12 // indirect | ||
github.com/json-iterator/go v1.1.12 // indirect | ||
github.com/klauspost/compress v1.14.4 // indirect | ||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect | ||
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect | ||
github.com/mitchellh/mapstructure v1.5.0 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.2 // indirect | ||
github.com/openzipkin/zipkin-go v0.2.2 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/prometheus/client_golang v1.12.2 // indirect | ||
github.com/prometheus/client_model v0.2.0 // indirect | ||
github.com/prometheus/common v0.34.0 // indirect | ||
github.com/prometheus/procfs v0.7.3 // indirect | ||
github.com/prometheus/statsd_exporter v0.22.3 // indirect | ||
github.com/savsgio/gotils v0.0.0-20210217112953-d4a072536008 // indirect | ||
github.com/sirupsen/logrus v1.8.1 // indirect | ||
github.com/sony/gobreaker v0.4.2-0.20210216022020-dd874f9dd33b // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
github.com/stoewer/go-strcase v1.2.0 // indirect | ||
github.com/stretchr/objx v0.4.0 // indirect | ||
github.com/stretchr/testify v1.7.4 // indirect | ||
github.com/valyala/bytebufferpool v1.0.0 // indirect | ||
go.opentelemetry.io/otel v1.7.0 // indirect | ||
go.uber.org/atomic v1.9.0 // indirect | ||
go.uber.org/multierr v1.7.0 // indirect | ||
go.uber.org/zap v1.21.0 // indirect | ||
golang.org/x/net v0.0.0-20220621193019-9d032be2e588 // indirect | ||
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a // indirect | ||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect | ||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect | ||
golang.org/x/text v0.3.7 // indirect | ||
golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 // indirect | ||
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect | ||
google.golang.org/appengine v1.6.7 // indirect | ||
google.golang.org/genproto v0.0.0-20220622171453-ea41d75dfa0f // indirect | ||
google.golang.org/protobuf v1.28.0 // indirect | ||
gopkg.in/inf.v0 v0.9.1 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
k8s.io/api v0.23.0 // indirect | ||
k8s.io/apiextensions-apiserver v0.23.0 // indirect | ||
k8s.io/apimachinery v0.23.0 // indirect | ||
k8s.io/client-go v0.23.0 // indirect | ||
k8s.io/component-base v0.23.0 // indirect | ||
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect | ||
k8s.io/utils v0.0.0-20210930125809-cb0fa318a74b // indirect | ||
sigs.k8s.io/controller-runtime v0.11.0 // indirect | ||
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect | ||
sigs.k8s.io/structured-merge-diff/v4 v4.2.0 // indirect | ||
sigs.k8s.io/yaml v1.3.0 // indirect | ||
skywalking.apache.org/repo/goapi v0.0.0-20220401015832-2c9eee9481eb // indirect | ||
) | ||
|
||
replace go.opentelemetry.io/otel => go.opentelemetry.io/otel v0.20.0 |
Oops, something went wrong.