From da4e2ca66b4aeb5f4234783169508a051a6a6e78 Mon Sep 17 00:00:00 2001 From: Lize Cai Date: Sat, 6 Aug 2022 15:45:14 +0800 Subject: [PATCH] combine declarative test cases into one test case (#60) * combine tests into one test case Signed-off-by: Lize Cai --- .github/workflows/main.yml | 8 -- plugin/skywalking/test/binding-event/e2e.yaml | 8 +- plugin/skywalking/test/topic-event/e2e.yaml | 8 +- test/bindings/e2e.yaml | 7 +- .../sender/Dockerfile.bindings.sender | 2 +- .../target/Dockerfile.bindings.target | 2 +- .../Dockerfile.sync.cloudevent | 12 --- .../sync-cloudevent-multiple/cloudevent.go | 24 ------ .../sync-cloudevent-multiple/e2e.yaml | 48 ----------- .../expected.data.yaml | 2 - .../sync-cloudevent-multiple/main.go | 85 ------------------- .../sync-cloudevent-multiple/manifests.yaml | 62 -------------- .../sync-cloudevent-multiple/verify.sh | 17 ---- .../Dockerfile.sync.cloudevent | 12 --- .../declarative/sync-cloudevent/cloudevent.go | 18 ---- test/declarative/sync-cloudevent/e2e.yaml | 46 ---------- .../sync-cloudevent/expected.data.yaml | 2 - test/declarative/sync-cloudevent/main.go | 85 ------------------- .../sync-cloudevent/manifests.yaml | 62 -------------- test/declarative/sync-cloudevent/verify.sh | 17 ---- .../sync-http-multiple/Dockerfile.sync.http | 12 --- test/declarative/sync-http-multiple/e2e.yaml | 48 ----------- .../sync-http-multiple/expected.data-foo.yaml | 2 - .../expected.data-helloworld.yaml | 2 - test/declarative/sync-http-multiple/http.go | 31 ------- test/declarative/sync-http-multiple/main.go | 84 ------------------ .../sync-http-multiple/manifests.yaml | 62 -------------- test/declarative/sync-http-multiple/verify.sh | 17 ---- .../Dockerfile.sync.http-variables | 2 +- test/declarative/sync-http-variables/e2e.yaml | 14 ++- test/declarative/sync-http-variables/http.go | 56 ++++++++++++ .../sync-http/Dockerfile.sync.http | 12 --- test/declarative/sync-http/e2e.yaml | 46 ---------- test/declarative/sync-http/expected.data.yaml | 2 - test/declarative/sync-http/http.go | 30 ------- test/declarative/sync-http/main.go | 84 ------------------ test/declarative/sync-http/manifests.yaml | 62 -------------- test/declarative/sync-http/verify.sh | 17 ---- test/pubsub/e2e.yaml | 7 +- test/pubsub/pub/Dockerfile.pubsub.publisher | 2 +- test/pubsub/sub/Dockerfile.pubsub.subscriber | 2 +- .../Dockerfile.sync.cloudevent | 2 +- test/sync-cloudevent/manifests.yaml | 73 +++++++--------- test/sync-http/Dockerfile.sync.http | 2 +- 44 files changed, 133 insertions(+), 1065 deletions(-) delete mode 100644 test/declarative/sync-cloudevent-multiple/Dockerfile.sync.cloudevent delete mode 100644 test/declarative/sync-cloudevent-multiple/cloudevent.go delete mode 100644 test/declarative/sync-cloudevent-multiple/e2e.yaml delete mode 100644 test/declarative/sync-cloudevent-multiple/expected.data.yaml delete mode 100644 test/declarative/sync-cloudevent-multiple/main.go delete mode 100644 test/declarative/sync-cloudevent-multiple/manifests.yaml delete mode 100644 test/declarative/sync-cloudevent-multiple/verify.sh delete mode 100644 test/declarative/sync-cloudevent/Dockerfile.sync.cloudevent delete mode 100644 test/declarative/sync-cloudevent/cloudevent.go delete mode 100644 test/declarative/sync-cloudevent/e2e.yaml delete mode 100644 test/declarative/sync-cloudevent/expected.data.yaml delete mode 100644 test/declarative/sync-cloudevent/main.go delete mode 100644 test/declarative/sync-cloudevent/manifests.yaml delete mode 100644 test/declarative/sync-cloudevent/verify.sh delete mode 100644 test/declarative/sync-http-multiple/Dockerfile.sync.http delete mode 100644 test/declarative/sync-http-multiple/e2e.yaml delete mode 100644 test/declarative/sync-http-multiple/expected.data-foo.yaml delete mode 100644 test/declarative/sync-http-multiple/expected.data-helloworld.yaml delete mode 100644 test/declarative/sync-http-multiple/http.go delete mode 100644 test/declarative/sync-http-multiple/main.go delete mode 100644 test/declarative/sync-http-multiple/manifests.yaml delete mode 100644 test/declarative/sync-http-multiple/verify.sh delete mode 100644 test/declarative/sync-http/Dockerfile.sync.http delete mode 100644 test/declarative/sync-http/e2e.yaml delete mode 100644 test/declarative/sync-http/expected.data.yaml delete mode 100644 test/declarative/sync-http/http.go delete mode 100644 test/declarative/sync-http/main.go delete mode 100644 test/declarative/sync-http/manifests.yaml delete mode 100644 test/declarative/sync-http/verify.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dbe245a..462bc14 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,14 +47,6 @@ jobs: e2e: "test/sync-http/e2e.yaml" - name: Sync Cloudevent e2e test e2e: "test/sync-cloudevent/e2e.yaml" - - name: Declarative Sync HTTP e2e test - e2e: "test/declarative/sync-http/e2e.yaml" - - name: Declarative Sync Cloudevent e2e test - e2e: "test/declarative/sync-cloudevent/e2e.yaml" - - name: Declarative multiple Sync HTTP e2e test - e2e: "test/declarative/sync-http-multiple/e2e.yaml" - - name: Declarative multiple Sync Cloudevent e2e test - e2e: "test/declarative/sync-cloudevent-multiple/e2e.yaml" - name: Declarative multiple functions with variables e2e test e2e: "test/declarative/sync-http-variables/e2e.yaml" steps: diff --git a/plugin/skywalking/test/binding-event/e2e.yaml b/plugin/skywalking/test/binding-event/e2e.yaml index ad70d30..508e1eb 100644 --- a/plugin/skywalking/test/binding-event/e2e.yaml +++ b/plugin/skywalking/test/binding-event/e2e.yaml @@ -5,7 +5,13 @@ setup: - name: install dapr command: | dapr -v || (wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash) - dapr init -k --log-as-json + dapr init -k --runtime-version 1.8.1 --log-as-json --wait --timeout 600 + wait: + - namespace: dapr-system + resource: pod + label-selector: app.kubernetes.io/name=dapr + for: condition=Ready + - name: install helm command: | curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash diff --git a/plugin/skywalking/test/topic-event/e2e.yaml b/plugin/skywalking/test/topic-event/e2e.yaml index d2895d8..8efbf84 100644 --- a/plugin/skywalking/test/topic-event/e2e.yaml +++ b/plugin/skywalking/test/topic-event/e2e.yaml @@ -5,7 +5,13 @@ setup: - name: install dapr command: | dapr -v || (wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash) - dapr init -k --log-as-json + dapr init -k --runtime-version 1.8.1 --log-as-json --wait --timeout 600 + wait: + - namespace: dapr-system + resource: pod + label-selector: app.kubernetes.io/name=dapr + for: condition=Ready + - name: install helm command: | curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash diff --git a/test/bindings/e2e.yaml b/test/bindings/e2e.yaml index 26312af..4b60f69 100644 --- a/test/bindings/e2e.yaml +++ b/test/bindings/e2e.yaml @@ -5,7 +5,12 @@ setup: - name: install dapr command: | dapr -v || (wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash) - dapr init -k --log-as-json + dapr init -k --runtime-version 1.8.1 --log-as-json --wait --timeout 600 + wait: + - namespace: dapr-system + resource: pod + label-selector: app.kubernetes.io/name=dapr + for: condition=Ready - name: install helm command: | diff --git a/test/bindings/sender/Dockerfile.bindings.sender b/test/bindings/sender/Dockerfile.bindings.sender index 7d07102..1b2c4ba 100644 --- a/test/bindings/sender/Dockerfile.bindings.sender +++ b/test/bindings/sender/Dockerfile.bindings.sender @@ -1,4 +1,4 @@ -FROM golang:1.16-alpine +FROM golang:1.17 ENV GO111MODULE=on ENV GOPROXY=https://goproxy.cn,direct diff --git a/test/bindings/target/Dockerfile.bindings.target b/test/bindings/target/Dockerfile.bindings.target index fe3e455..5c1edc6 100644 --- a/test/bindings/target/Dockerfile.bindings.target +++ b/test/bindings/target/Dockerfile.bindings.target @@ -1,4 +1,4 @@ -FROM golang:1.16-alpine +FROM golang:1.17 ENV GO111MODULE=on ENV GOPROXY=https://goproxy.cn,direct diff --git a/test/declarative/sync-cloudevent-multiple/Dockerfile.sync.cloudevent b/test/declarative/sync-cloudevent-multiple/Dockerfile.sync.cloudevent deleted file mode 100644 index cdf5aab..0000000 --- a/test/declarative/sync-cloudevent-multiple/Dockerfile.sync.cloudevent +++ /dev/null @@ -1,12 +0,0 @@ -FROM golang:1.16-alpine - -ENV GO111MODULE=on -ENV GOPROXY=https://goproxy.cn,direct - -WORKDIR /ff - -ADD . /ff - -ENTRYPOINT ["go"] - -CMD ["run", "test/declarative/sync-cloudevent-multiple/main.go", "test/declarative/sync-cloudevent-multiple/cloudevent.go"] \ No newline at end of file diff --git a/test/declarative/sync-cloudevent-multiple/cloudevent.go b/test/declarative/sync-cloudevent-multiple/cloudevent.go deleted file mode 100644 index 2145bb9..0000000 --- a/test/declarative/sync-cloudevent-multiple/cloudevent.go +++ /dev/null @@ -1,24 +0,0 @@ -package main - -import ( - "context" - - "github.com/OpenFunction/functions-framework-go/functions" - cloudevents "github.com/cloudevents/sdk-go/v2" - "k8s.io/klog/v2" -) - -func init() { - functions.CloudEvent("HelloWorld", HelloWorld, functions.WithFunctionPath("/helloworld")) - functions.CloudEvent("Foo", Foo, functions.WithFunctionPath("/foo")) -} - -func HelloWorld(ctx context.Context, ce cloudevents.Event) error { - klog.Infof("cloudevent - Data: %s", ce.Data()) - return nil -} - -func Foo(ctx context.Context, ce cloudevents.Event) error { - klog.Infof("cloudevent - Data: %s", ce.Data()) - return nil -} diff --git a/test/declarative/sync-cloudevent-multiple/e2e.yaml b/test/declarative/sync-cloudevent-multiple/e2e.yaml deleted file mode 100644 index 6f72eb2..0000000 --- a/test/declarative/sync-cloudevent-multiple/e2e.yaml +++ /dev/null @@ -1,48 +0,0 @@ -setup: - env: kind - file: ../../kind.yaml - steps: - - name: build and load image - command: | - docker build -t sync_e2e_cloudevent:latest -f test/declarative/sync-cloudevent-multiple/Dockerfile.sync.cloudevent . - kind load docker-image sync_e2e_cloudevent:latest - - - name: setup manifests - path: manifests.yaml - wait: - - namespace: default - resource: pod - label-selector: app=sync-cloudevent - for: condition=Ready - -# kind: -# expose-ports: -# - namespace: default -# resource: services/sync -# port: 12345 - - timeout: 30m - -cleanup: - # always never success failure - on: success - -#trigger: -# action: "http" -# interval: 3s -# times: 10 -# url: http://127.0.0.1:80 -# method: GET - -verify: - # verify with retry strategy - retry: - # max retry count - count: 60 - # the interval between two attempts, e.g. 10s, 1m. - interval: 10s - cases: - - query: bash test/declarative/sync-cloudevent-multiple/verify.sh 127.0.0.1:80/helloworld | yq - expected: expected.data.yaml - - query: bash test/declarative/sync-cloudevent-multiple/verify.sh 127.0.0.1:80/foo | yq - expected: expected.data.yaml \ No newline at end of file diff --git a/test/declarative/sync-cloudevent-multiple/expected.data.yaml b/test/declarative/sync-cloudevent-multiple/expected.data.yaml deleted file mode 100644 index 8ad232c..0000000 --- a/test/declarative/sync-cloudevent-multiple/expected.data.yaml +++ /dev/null @@ -1,2 +0,0 @@ -hello: world -sum: 2 \ No newline at end of file diff --git a/test/declarative/sync-cloudevent-multiple/main.go b/test/declarative/sync-cloudevent-multiple/main.go deleted file mode 100644 index e2bc72e..0000000 --- a/test/declarative/sync-cloudevent-multiple/main.go +++ /dev/null @@ -1,85 +0,0 @@ -package main - -import ( - "context" - - "github.com/fatih/structs" - "k8s.io/klog/v2" - - ofctx "github.com/OpenFunction/functions-framework-go/context" - "github.com/OpenFunction/functions-framework-go/framework" - "github.com/OpenFunction/functions-framework-go/plugin" -) - -func main() { - ctx := context.Background() - fwk, err := framework.NewFramework() - if err != nil { - klog.Exit(err) - } - fwk.RegisterPlugins(getLocalPlugins()) - - if err := fwk.Start(ctx); err != nil { - klog.Exit(err) - } -} - -func getLocalPlugins() map[string]plugin.Plugin { - localPlugins := map[string]plugin.Plugin{ - Name: New(), - } - - if len(localPlugins) == 0 { - return nil - } else { - return localPlugins - } -} - -// Plugin - -const ( - Name = "plugin-custom" - Version = "v1" -) - -type PluginCustom struct { - PluginName string - PluginVersion string - StateC int64 -} - -var _ plugin.Plugin = &PluginCustom{} - -func New() *PluginCustom { - return &PluginCustom{ - StateC: int64(0), - } -} - -func (p *PluginCustom) Name() string { - return Name -} - -func (p *PluginCustom) Version() string { - return Version -} - -func (p *PluginCustom) Init() plugin.Plugin { - return New() -} - -func (p *PluginCustom) ExecPreHook(ctx ofctx.RuntimeContext, plugins map[string]plugin.Plugin) error { - p.StateC++ - return nil -} - -func (p *PluginCustom) ExecPostHook(ctx ofctx.RuntimeContext, plugins map[string]plugin.Plugin) error { - return nil -} - -func (p *PluginCustom) Get(fieldName string) (interface{}, bool) { - plgMap := structs.Map(p) - value, ok := plgMap[fieldName] - return value, ok -} diff --git a/test/declarative/sync-cloudevent-multiple/manifests.yaml b/test/declarative/sync-cloudevent-multiple/manifests.yaml deleted file mode 100644 index 3208b71..0000000 --- a/test/declarative/sync-cloudevent-multiple/manifests.yaml +++ /dev/null @@ -1,62 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: sync-cloudevent - labels: - app: sync-cloudevent - case: sync -spec: - replicas: 1 - selector: - matchLabels: - app: sync-cloudevent - case: sync - template: - metadata: - labels: - app: sync-cloudevent - case: sync - spec: - containers: - - name: cloudevent - image: sync_e2e_cloudevent:latest - imagePullPolicy: IfNotPresent - env: - - name: FUNC_CONTEXT - value: | - { - "name": "sync-cloudevent", - "version": "v1", - "requestID": "a0f2ad8d-5062-4812-91e9-95416489fb01", - "port": "8080", - "prePlugins": ["plugin-custom", "plugin-example"], - "postPlugins": ["plugin-custom", "plugin-example"], - "inputs": {}, - "outputs": {}, - "runtime": "Knative" - } - - name: POD_NAME - valueFrom: - fieldRef: - apiVersion: v1 - fieldPath: metadata.name - - name: POD_NAMESPACE - value: default - ports: - - containerPort: 8080 - name: function-port - protocol: TCP ---- -apiVersion: v1 -kind: Service -metadata: - name: sync -spec: - type: NodePort - selector: - app: sync-cloudevent - ports: - - protocol: TCP - port: 12345 - targetPort: 8080 - nodePort: 31234 diff --git a/test/declarative/sync-cloudevent-multiple/verify.sh b/test/declarative/sync-cloudevent-multiple/verify.sh deleted file mode 100644 index 3ea5a46..0000000 --- a/test/declarative/sync-cloudevent-multiple/verify.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -url=http://$1 -while true; do - st=$(curl -s -o /dev/null -w "%{http_code}" "$url" -H "Ce-Specversion: 1.0" -H "Ce-Type: io.openfunction.samples.helloworld" -H "Ce-Source: io.openfunction.samples/helloworldsource" -H "Ce-Id: 536808d3-88be-4077-9d7a-a3f162705f79" -H "Content-Type: application/json" -d '{"hello":"world"}') - if [ "$st" -eq 200 ]; then - data_result=$(KUBECONFIG=/tmp/e2e-k8s.config kubectl logs --tail=2 -l app="sync-cloudevent" -c cloudevent | grep Data | awk '{ print $8 }' | yq -P '.' -) - plugin_result=$(KUBECONFIG=/tmp/e2e-k8s.config kubectl logs --tail=2 -l app="sync-cloudevent" -c cloudevent | grep plugin | awk '{ print $8 }' | yq -P '.' -) - break - else - sleep 1 - continue - fi -done - -echo "$data_result" -echo "$plugin_result" diff --git a/test/declarative/sync-cloudevent/Dockerfile.sync.cloudevent b/test/declarative/sync-cloudevent/Dockerfile.sync.cloudevent deleted file mode 100644 index f11de01..0000000 --- a/test/declarative/sync-cloudevent/Dockerfile.sync.cloudevent +++ /dev/null @@ -1,12 +0,0 @@ -FROM golang:1.16-alpine - -ENV GO111MODULE=on -ENV GOPROXY=https://goproxy.cn,direct - -WORKDIR /ff - -ADD . /ff - -ENTRYPOINT ["go"] - -CMD ["run", "test/declarative/sync-cloudevent/main.go", "test/declarative/sync-cloudevent/cloudevent.go"] \ No newline at end of file diff --git a/test/declarative/sync-cloudevent/cloudevent.go b/test/declarative/sync-cloudevent/cloudevent.go deleted file mode 100644 index 46ccbe3..0000000 --- a/test/declarative/sync-cloudevent/cloudevent.go +++ /dev/null @@ -1,18 +0,0 @@ -package main - -import ( - "context" - - "github.com/OpenFunction/functions-framework-go/functions" - cloudevents "github.com/cloudevents/sdk-go/v2" - "k8s.io/klog/v2" -) - -func init() { - functions.CloudEvent("HelloWorld", HelloWorld, functions.WithFunctionPath("/")) -} - -func HelloWorld(ctx context.Context, ce cloudevents.Event) error { - klog.Infof("cloudevent - Data: %s", ce.Data()) - return nil -} diff --git a/test/declarative/sync-cloudevent/e2e.yaml b/test/declarative/sync-cloudevent/e2e.yaml deleted file mode 100644 index afec111..0000000 --- a/test/declarative/sync-cloudevent/e2e.yaml +++ /dev/null @@ -1,46 +0,0 @@ -setup: - env: kind - file: ../../kind.yaml - steps: - - name: build and load image - command: | - docker build -t sync_e2e_cloudevent:latest -f test/declarative/sync-cloudevent/Dockerfile.sync.cloudevent . - kind load docker-image sync_e2e_cloudevent:latest - - - name: setup manifests - path: manifests.yaml - wait: - - namespace: default - resource: pod - label-selector: app=sync-cloudevent - for: condition=Ready - -# kind: -# expose-ports: -# - namespace: default -# resource: services/sync -# port: 12345 - - timeout: 30m - -cleanup: - # always never success failure - on: success - -#trigger: -# action: "http" -# interval: 3s -# times: 10 -# url: http://127.0.0.1:80 -# method: GET - -verify: - # verify with retry strategy - retry: - # max retry count - count: 60 - # the interval between two attempts, e.g. 10s, 1m. - interval: 10s - cases: - - query: bash test/declarative/sync-cloudevent/verify.sh 127.0.0.1:80 | yq - expected: expected.data.yaml diff --git a/test/declarative/sync-cloudevent/expected.data.yaml b/test/declarative/sync-cloudevent/expected.data.yaml deleted file mode 100644 index 8ad232c..0000000 --- a/test/declarative/sync-cloudevent/expected.data.yaml +++ /dev/null @@ -1,2 +0,0 @@ -hello: world -sum: 2 \ No newline at end of file diff --git a/test/declarative/sync-cloudevent/main.go b/test/declarative/sync-cloudevent/main.go deleted file mode 100644 index e2bc72e..0000000 --- a/test/declarative/sync-cloudevent/main.go +++ /dev/null @@ -1,85 +0,0 @@ -package main - -import ( - "context" - - "github.com/fatih/structs" - "k8s.io/klog/v2" - - ofctx "github.com/OpenFunction/functions-framework-go/context" - "github.com/OpenFunction/functions-framework-go/framework" - "github.com/OpenFunction/functions-framework-go/plugin" -) - -func main() { - ctx := context.Background() - fwk, err := framework.NewFramework() - if err != nil { - klog.Exit(err) - } - fwk.RegisterPlugins(getLocalPlugins()) - - if err := fwk.Start(ctx); err != nil { - klog.Exit(err) - } -} - -func getLocalPlugins() map[string]plugin.Plugin { - localPlugins := map[string]plugin.Plugin{ - Name: New(), - } - - if len(localPlugins) == 0 { - return nil - } else { - return localPlugins - } -} - -// Plugin - -const ( - Name = "plugin-custom" - Version = "v1" -) - -type PluginCustom struct { - PluginName string - PluginVersion string - StateC int64 -} - -var _ plugin.Plugin = &PluginCustom{} - -func New() *PluginCustom { - return &PluginCustom{ - StateC: int64(0), - } -} - -func (p *PluginCustom) Name() string { - return Name -} - -func (p *PluginCustom) Version() string { - return Version -} - -func (p *PluginCustom) Init() plugin.Plugin { - return New() -} - -func (p *PluginCustom) ExecPreHook(ctx ofctx.RuntimeContext, plugins map[string]plugin.Plugin) error { - p.StateC++ - return nil -} - -func (p *PluginCustom) ExecPostHook(ctx ofctx.RuntimeContext, plugins map[string]plugin.Plugin) error { - return nil -} - -func (p *PluginCustom) Get(fieldName string) (interface{}, bool) { - plgMap := structs.Map(p) - value, ok := plgMap[fieldName] - return value, ok -} diff --git a/test/declarative/sync-cloudevent/manifests.yaml b/test/declarative/sync-cloudevent/manifests.yaml deleted file mode 100644 index 3208b71..0000000 --- a/test/declarative/sync-cloudevent/manifests.yaml +++ /dev/null @@ -1,62 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: sync-cloudevent - labels: - app: sync-cloudevent - case: sync -spec: - replicas: 1 - selector: - matchLabels: - app: sync-cloudevent - case: sync - template: - metadata: - labels: - app: sync-cloudevent - case: sync - spec: - containers: - - name: cloudevent - image: sync_e2e_cloudevent:latest - imagePullPolicy: IfNotPresent - env: - - name: FUNC_CONTEXT - value: | - { - "name": "sync-cloudevent", - "version": "v1", - "requestID": "a0f2ad8d-5062-4812-91e9-95416489fb01", - "port": "8080", - "prePlugins": ["plugin-custom", "plugin-example"], - "postPlugins": ["plugin-custom", "plugin-example"], - "inputs": {}, - "outputs": {}, - "runtime": "Knative" - } - - name: POD_NAME - valueFrom: - fieldRef: - apiVersion: v1 - fieldPath: metadata.name - - name: POD_NAMESPACE - value: default - ports: - - containerPort: 8080 - name: function-port - protocol: TCP ---- -apiVersion: v1 -kind: Service -metadata: - name: sync -spec: - type: NodePort - selector: - app: sync-cloudevent - ports: - - protocol: TCP - port: 12345 - targetPort: 8080 - nodePort: 31234 diff --git a/test/declarative/sync-cloudevent/verify.sh b/test/declarative/sync-cloudevent/verify.sh deleted file mode 100644 index 3ea5a46..0000000 --- a/test/declarative/sync-cloudevent/verify.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -url=http://$1 -while true; do - st=$(curl -s -o /dev/null -w "%{http_code}" "$url" -H "Ce-Specversion: 1.0" -H "Ce-Type: io.openfunction.samples.helloworld" -H "Ce-Source: io.openfunction.samples/helloworldsource" -H "Ce-Id: 536808d3-88be-4077-9d7a-a3f162705f79" -H "Content-Type: application/json" -d '{"hello":"world"}') - if [ "$st" -eq 200 ]; then - data_result=$(KUBECONFIG=/tmp/e2e-k8s.config kubectl logs --tail=2 -l app="sync-cloudevent" -c cloudevent | grep Data | awk '{ print $8 }' | yq -P '.' -) - plugin_result=$(KUBECONFIG=/tmp/e2e-k8s.config kubectl logs --tail=2 -l app="sync-cloudevent" -c cloudevent | grep plugin | awk '{ print $8 }' | yq -P '.' -) - break - else - sleep 1 - continue - fi -done - -echo "$data_result" -echo "$plugin_result" diff --git a/test/declarative/sync-http-multiple/Dockerfile.sync.http b/test/declarative/sync-http-multiple/Dockerfile.sync.http deleted file mode 100644 index 821d7d9..0000000 --- a/test/declarative/sync-http-multiple/Dockerfile.sync.http +++ /dev/null @@ -1,12 +0,0 @@ -FROM golang:1.16-alpine - -ENV GO111MODULE=on -ENV GOPROXY=https://goproxy.cn,direct - -WORKDIR /ff - -ADD . /ff - -ENTRYPOINT ["go"] - -CMD ["run", "test/declarative/sync-http-multiple/main.go", "test/declarative/sync-http-multiple/http.go"] \ No newline at end of file diff --git a/test/declarative/sync-http-multiple/e2e.yaml b/test/declarative/sync-http-multiple/e2e.yaml deleted file mode 100644 index eb375cb..0000000 --- a/test/declarative/sync-http-multiple/e2e.yaml +++ /dev/null @@ -1,48 +0,0 @@ -setup: - env: kind - file: ../../kind.yaml - steps: - - name: build and load image - command: | - docker build -t sync_e2e_http:latest -f test/declarative/sync-http-multiple/Dockerfile.sync.http . - kind load docker-image sync_e2e_http:latest - - - name: setup manifests - path: manifests.yaml - wait: - - namespace: default - resource: pod - label-selector: app=sync-http - for: condition=Ready - -# kind: -# expose-ports: -# - namespace: default -# resource: service/sync -# port: 12345 - - timeout: 30m - -cleanup: - # always never success failure - on: success - -#trigger: -# action: "http" -# interval: 3s -# times: 10 -# url: http://127.0.0.1:80 -# method: GET - -verify: - # verify with retry strategy - retry: - # max retry count - count: 60 - # the interval between two attempts, e.g. 10s, 1m. - interval: 10s - cases: - - query: bash test/declarative/sync-http-multiple/verify.sh 127.0.0.1:80/helloworld | yq - expected: expected.data-helloworld.yaml - - query: bash test/declarative/sync-http-multiple/verify.sh 127.0.0.1:80/foo | yq - expected: expected.data-foo.yaml \ No newline at end of file diff --git a/test/declarative/sync-http-multiple/expected.data-foo.yaml b/test/declarative/sync-http-multiple/expected.data-foo.yaml deleted file mode 100644 index 2d50a06..0000000 --- a/test/declarative/sync-http-multiple/expected.data-foo.yaml +++ /dev/null @@ -1,2 +0,0 @@ -hello: foo -sum: 2 \ No newline at end of file diff --git a/test/declarative/sync-http-multiple/expected.data-helloworld.yaml b/test/declarative/sync-http-multiple/expected.data-helloworld.yaml deleted file mode 100644 index 8ad232c..0000000 --- a/test/declarative/sync-http-multiple/expected.data-helloworld.yaml +++ /dev/null @@ -1,2 +0,0 @@ -hello: world -sum: 2 \ No newline at end of file diff --git a/test/declarative/sync-http-multiple/http.go b/test/declarative/sync-http-multiple/http.go deleted file mode 100644 index 9aec9e0..0000000 --- a/test/declarative/sync-http-multiple/http.go +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( - "encoding/json" - "net/http" - - "github.com/OpenFunction/functions-framework-go/functions" -) - -func init() { - functions.HTTP("HelloWorld", helloWorld, functions.WithFunctionPath("/helloworld")) - functions.HTTP("Foo", foo, functions.WithFunctionPath("/foo")) -} - -func helloWorld(w http.ResponseWriter, r *http.Request) { - response := map[string]string{ - "hello": "world", - } - responseBytes, _ := json.Marshal(response) - w.Header().Set("Content-type", "application/json") - w.Write(responseBytes) -} - -func foo(w http.ResponseWriter, r *http.Request) { - response := map[string]string{ - "hello": "foo", - } - responseBytes, _ := json.Marshal(response) - w.Header().Set("Content-type", "application/json") - w.Write(responseBytes) -} diff --git a/test/declarative/sync-http-multiple/main.go b/test/declarative/sync-http-multiple/main.go deleted file mode 100644 index e693e82..0000000 --- a/test/declarative/sync-http-multiple/main.go +++ /dev/null @@ -1,84 +0,0 @@ -package main - -import ( - "context" - - "github.com/fatih/structs" - "k8s.io/klog/v2" - - ofctx "github.com/OpenFunction/functions-framework-go/context" - "github.com/OpenFunction/functions-framework-go/framework" - "github.com/OpenFunction/functions-framework-go/plugin" -) - -func main() { - ctx := context.Background() - fwk, err := framework.NewFramework() - if err != nil { - klog.Exit(err) - } - fwk.RegisterPlugins(getLocalPlugins()) - if err := fwk.Start(ctx); err != nil { - klog.Exit(err) - } -} - -func getLocalPlugins() map[string]plugin.Plugin { - localPlugins := map[string]plugin.Plugin{ - Name: New(), - } - - if len(localPlugins) == 0 { - return nil - } else { - return localPlugins - } -} - -// Plugin - -const ( - Name = "plugin-custom" - Version = "v1" -) - -type PluginCustom struct { - PluginName string - PluginVersion string - StateC int64 -} - -var _ plugin.Plugin = &PluginCustom{} - -func New() *PluginCustom { - return &PluginCustom{ - StateC: int64(0), - } -} - -func (p *PluginCustom) Name() string { - return Name -} - -func (p *PluginCustom) Version() string { - return Version -} - -func (p *PluginCustom) Init() plugin.Plugin { - return New() -} - -func (p *PluginCustom) ExecPreHook(ctx ofctx.RuntimeContext, plugins map[string]plugin.Plugin) error { - p.StateC++ - return nil -} - -func (p *PluginCustom) ExecPostHook(ctx ofctx.RuntimeContext, plugins map[string]plugin.Plugin) error { - return nil -} - -func (p *PluginCustom) Get(fieldName string) (interface{}, bool) { - plgMap := structs.Map(p) - value, ok := plgMap[fieldName] - return value, ok -} diff --git a/test/declarative/sync-http-multiple/manifests.yaml b/test/declarative/sync-http-multiple/manifests.yaml deleted file mode 100644 index f5251d4..0000000 --- a/test/declarative/sync-http-multiple/manifests.yaml +++ /dev/null @@ -1,62 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: sync-http - labels: - app: sync-http - case: sync -spec: - replicas: 1 - selector: - matchLabels: - app: sync-http - case: sync - template: - metadata: - labels: - app: sync-http - case: sync - spec: - containers: - - name: http - image: sync_e2e_http:latest - imagePullPolicy: IfNotPresent - env: - - name: FUNC_CONTEXT - value: | - { - "name": "sync-http", - "version": "v1", - "requestID": "a0f2ad8d-5062-4812-91e9-95416489fb01", - "port": "8080", - "prePlugins": ["plugin-custom", "plugin-example"], - "postPlugins": ["plugin-custom", "plugin-example"], - "inputs": {}, - "outputs": {}, - "runtime": "Knative" - } - - name: POD_NAME - valueFrom: - fieldRef: - apiVersion: v1 - fieldPath: metadata.name - - name: POD_NAMESPACE - value: default - ports: - - containerPort: 8080 - name: function-port - protocol: TCP ---- -apiVersion: v1 -kind: Service -metadata: - name: sync -spec: - type: NodePort - selector: - app: sync-http - ports: - - protocol: TCP - port: 12345 - targetPort: 8080 - nodePort: 31234 diff --git a/test/declarative/sync-http-multiple/verify.sh b/test/declarative/sync-http-multiple/verify.sh deleted file mode 100644 index 174bbc4..0000000 --- a/test/declarative/sync-http-multiple/verify.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -url=http://$1 -while true; do - st=$(curl -s -o /dev/null -w "%{http_code}" -X GET "$url") - if [ "$st" -eq 200 ]; then - data_result=$(curl -X GET -H "Content-type: application/json" -H "Accept: application/json" -s "$url" | yq -P ".") - plugin_result=$(KUBECONFIG=/tmp/e2e-k8s.config kubectl logs --tail=1 -l app="sync-http" -c http | awk '{ print $8 }' | yq -P '.' -) - break - else - sleep 1 - continue - fi -done - -echo "$data_result" -echo "$plugin_result" diff --git a/test/declarative/sync-http-variables/Dockerfile.sync.http-variables b/test/declarative/sync-http-variables/Dockerfile.sync.http-variables index 7affbba..9c89c4c 100644 --- a/test/declarative/sync-http-variables/Dockerfile.sync.http-variables +++ b/test/declarative/sync-http-variables/Dockerfile.sync.http-variables @@ -1,4 +1,4 @@ -FROM golang:1.16-alpine +FROM golang:1.17 ENV GO111MODULE=on ENV GOPROXY=https://goproxy.cn,direct diff --git a/test/declarative/sync-http-variables/e2e.yaml b/test/declarative/sync-http-variables/e2e.yaml index f7545d2..c605e43 100644 --- a/test/declarative/sync-http-variables/e2e.yaml +++ b/test/declarative/sync-http-variables/e2e.yaml @@ -5,7 +5,7 @@ setup: - name: install dapr command: | dapr -v || (wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash) - dapr init -k --runtime-version 1.8.0 --log-as-json --wait --timeout 600 + dapr init -k --runtime-version 1.8.1 --log-as-json --wait --timeout 600 wait: - namespace: dapr-system resource: pod @@ -53,13 +53,25 @@ verify: cases: - query: bash test/declarative/sync-http-variables/verify-http.sh 127.0.0.1:80/hello/openfunction | yq expected: expected.data-hello.yaml + - query: bash test/declarative/sync-http-variables/verify-http.sh 127.0.0.1:80/hellov2/openfunction | yq + expected: expected.data-hello.yaml - query: bash test/declarative/sync-http-variables/verify-cloudevent-binary.sh 127.0.0.1:80/foo/openfunction | yq expected: expected.data-foo.yaml - query: bash test/declarative/sync-http-variables/verify-cloudevent-structured.sh 127.0.0.1:80/foo/openfunction | yq expected: expected.data-foo.yaml + - query: bash test/declarative/sync-http-variables/verify-cloudevent-binary.sh 127.0.0.1:80/foov2/openfunction | yq + expected: expected.data-foo.yaml + - query: bash test/declarative/sync-http-variables/verify-cloudevent-structured.sh 127.0.0.1:80/foov2/openfunction | yq + expected: expected.data-foo.yaml - query: bash test/declarative/sync-http-variables/verify-ofn-http.sh 127.0.0.1:80/bar/openfunction | yq expected: expected.data-bar.yaml - query: bash test/declarative/sync-http-variables/verify-ofn-cloudevent-binary.sh 127.0.0.1:80/bar/openfunction | yq expected: expected.data-bar.yaml - query: bash test/declarative/sync-http-variables/verify-ofn-cloudevent-structured.sh 127.0.0.1:80/bar/openfunction | yq + expected: expected.data-bar.yaml + - query: bash test/declarative/sync-http-variables/verify-ofn-http.sh 127.0.0.1:80/barv2/openfunction | yq + expected: expected.data-bar.yaml + - query: bash test/declarative/sync-http-variables/verify-ofn-cloudevent-binary.sh 127.0.0.1:80/barv2/openfunction | yq + expected: expected.data-bar.yaml + - query: bash test/declarative/sync-http-variables/verify-ofn-cloudevent-structured.sh 127.0.0.1:80/barv2/openfunction | yq expected: expected.data-bar.yaml \ No newline at end of file diff --git a/test/declarative/sync-http-variables/http.go b/test/declarative/sync-http-variables/http.go index 38da44d..d706bf2 100644 --- a/test/declarative/sync-http-variables/http.go +++ b/test/declarative/sync-http-variables/http.go @@ -17,14 +17,28 @@ func init() { functions.WithFunctionMethods("GET", "POST"), ) + functions.HTTP("Hellov2", hellov2, + functions.WithFunctionPath("/hellov2/{name}"), + functions.WithFunctionMethods("GET", "POST"), + ) + functions.CloudEvent("Foo", foo, functions.WithFunctionPath("/foo/{name}"), ) + functions.CloudEvent("Foov2", foov2, + functions.WithFunctionPath("/foov2/{name}"), + ) + functions.OpenFunction("Bar", bar, functions.WithFunctionPath("/bar/{name}"), functions.WithFunctionMethods("GET", "POST"), ) + + functions.OpenFunction("Barv2", barv2, + functions.WithFunctionPath("/barv2/{name}"), + functions.WithFunctionMethods("GET", "POST"), + ) } type Message struct { @@ -41,6 +55,16 @@ func hello(w http.ResponseWriter, r *http.Request) { w.Write(responseBytes) } +func hellov2(w http.ResponseWriter, r *http.Request) { + vars := ofctx.VarsFromCtx(r.Context()) + response := map[string]string{ + "hello": vars["name"], + } + responseBytes, _ := json.Marshal(response) + w.Header().Set("Content-type", "application/json") + w.Write(responseBytes) +} + func foo(ctx context.Context, ce cloudevents.Event) error { vars := ofctx.VarsFromCtx(ctx) @@ -58,6 +82,23 @@ func foo(ctx context.Context, ce cloudevents.Event) error { return nil } +func foov2(ctx context.Context, ce cloudevents.Event) error { + vars := ofctx.VarsFromCtx(ctx) + + msg := &Message{} + err := json.Unmarshal(ce.Data(), msg) + if err != nil { + return err + } + + response := map[string]string{ + msg.Data: vars["name"], + } + responseBytes, _ := json.Marshal(response) + klog.Infof("cloudevent - Data: %s", string(responseBytes)) + return nil +} + func bar(ctx ofctx.Context, in []byte) (ofctx.Out, error) { vars := ofctx.VarsFromCtx(ctx.GetNativeContext()) msg := &Message{} @@ -72,3 +113,18 @@ func bar(ctx ofctx.Context, in []byte) (ofctx.Out, error) { responseBytes, _ := json.Marshal(response) return ctx.ReturnOnSuccess().WithData(responseBytes), nil } + +func barv2(ctx ofctx.Context, in []byte) (ofctx.Out, error) { + vars := ofctx.VarsFromCtx(ctx.GetNativeContext()) + msg := &Message{} + err := json.Unmarshal(in, msg) + if err != nil { + return ctx.ReturnOnInternalError(), err + } + + response := map[string]string{ + msg.Data: vars["name"], + } + responseBytes, _ := json.Marshal(response) + return ctx.ReturnOnSuccess().WithData(responseBytes), nil +} diff --git a/test/declarative/sync-http/Dockerfile.sync.http b/test/declarative/sync-http/Dockerfile.sync.http deleted file mode 100644 index 6c31771..0000000 --- a/test/declarative/sync-http/Dockerfile.sync.http +++ /dev/null @@ -1,12 +0,0 @@ -FROM golang:1.16-alpine - -ENV GO111MODULE=on -ENV GOPROXY=https://goproxy.cn,direct - -WORKDIR /ff - -ADD . /ff - -ENTRYPOINT ["go"] - -CMD ["run", "test/declarative/sync-http/main.go", "test/declarative/sync-http/http.go"] \ No newline at end of file diff --git a/test/declarative/sync-http/e2e.yaml b/test/declarative/sync-http/e2e.yaml deleted file mode 100644 index 9ca57a8..0000000 --- a/test/declarative/sync-http/e2e.yaml +++ /dev/null @@ -1,46 +0,0 @@ -setup: - env: kind - file: ../../kind.yaml - steps: - - name: build and load image - command: | - docker build -t sync_e2e_http:latest -f test/declarative/sync-http/Dockerfile.sync.http . - kind load docker-image sync_e2e_http:latest - - - name: setup manifests - path: manifests.yaml - wait: - - namespace: default - resource: pod - label-selector: app=sync-http - for: condition=Ready - -# kind: -# expose-ports: -# - namespace: default -# resource: service/sync -# port: 12345 - - timeout: 30m - -cleanup: - # always never success failure - on: success - -#trigger: -# action: "http" -# interval: 3s -# times: 10 -# url: http://127.0.0.1:80 -# method: GET - -verify: - # verify with retry strategy - retry: - # max retry count - count: 60 - # the interval between two attempts, e.g. 10s, 1m. - interval: 10s - cases: - - query: bash test/declarative/sync-http/verify.sh 127.0.0.1:80 | yq - expected: expected.data.yaml diff --git a/test/declarative/sync-http/expected.data.yaml b/test/declarative/sync-http/expected.data.yaml deleted file mode 100644 index 8ad232c..0000000 --- a/test/declarative/sync-http/expected.data.yaml +++ /dev/null @@ -1,2 +0,0 @@ -hello: world -sum: 2 \ No newline at end of file diff --git a/test/declarative/sync-http/http.go b/test/declarative/sync-http/http.go deleted file mode 100644 index 84ca9f2..0000000 --- a/test/declarative/sync-http/http.go +++ /dev/null @@ -1,30 +0,0 @@ -package main - -import ( - "encoding/json" - "net/http" - - "github.com/OpenFunction/functions-framework-go/functions" -) - -func init() { - functions.HTTP("HelloWorld", helloWorld, functions.WithFunctionPath("/")) -} - -func helloWorld(w http.ResponseWriter, r *http.Request) { - response := map[string]string{ - "hello": "world", - } - responseBytes, _ := json.Marshal(response) - w.Header().Set("Content-type", "application/json") - w.Write(responseBytes) -} - -func foo(w http.ResponseWriter, r *http.Request) { - response := map[string]string{ - "hello": "bar", - } - responseBytes, _ := json.Marshal(response) - w.Header().Set("Content-type", "application/json") - w.Write(responseBytes) -} diff --git a/test/declarative/sync-http/main.go b/test/declarative/sync-http/main.go deleted file mode 100644 index e693e82..0000000 --- a/test/declarative/sync-http/main.go +++ /dev/null @@ -1,84 +0,0 @@ -package main - -import ( - "context" - - "github.com/fatih/structs" - "k8s.io/klog/v2" - - ofctx "github.com/OpenFunction/functions-framework-go/context" - "github.com/OpenFunction/functions-framework-go/framework" - "github.com/OpenFunction/functions-framework-go/plugin" -) - -func main() { - ctx := context.Background() - fwk, err := framework.NewFramework() - if err != nil { - klog.Exit(err) - } - fwk.RegisterPlugins(getLocalPlugins()) - if err := fwk.Start(ctx); err != nil { - klog.Exit(err) - } -} - -func getLocalPlugins() map[string]plugin.Plugin { - localPlugins := map[string]plugin.Plugin{ - Name: New(), - } - - if len(localPlugins) == 0 { - return nil - } else { - return localPlugins - } -} - -// Plugin - -const ( - Name = "plugin-custom" - Version = "v1" -) - -type PluginCustom struct { - PluginName string - PluginVersion string - StateC int64 -} - -var _ plugin.Plugin = &PluginCustom{} - -func New() *PluginCustom { - return &PluginCustom{ - StateC: int64(0), - } -} - -func (p *PluginCustom) Name() string { - return Name -} - -func (p *PluginCustom) Version() string { - return Version -} - -func (p *PluginCustom) Init() plugin.Plugin { - return New() -} - -func (p *PluginCustom) ExecPreHook(ctx ofctx.RuntimeContext, plugins map[string]plugin.Plugin) error { - p.StateC++ - return nil -} - -func (p *PluginCustom) ExecPostHook(ctx ofctx.RuntimeContext, plugins map[string]plugin.Plugin) error { - return nil -} - -func (p *PluginCustom) Get(fieldName string) (interface{}, bool) { - plgMap := structs.Map(p) - value, ok := plgMap[fieldName] - return value, ok -} diff --git a/test/declarative/sync-http/manifests.yaml b/test/declarative/sync-http/manifests.yaml deleted file mode 100644 index f5251d4..0000000 --- a/test/declarative/sync-http/manifests.yaml +++ /dev/null @@ -1,62 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: sync-http - labels: - app: sync-http - case: sync -spec: - replicas: 1 - selector: - matchLabels: - app: sync-http - case: sync - template: - metadata: - labels: - app: sync-http - case: sync - spec: - containers: - - name: http - image: sync_e2e_http:latest - imagePullPolicy: IfNotPresent - env: - - name: FUNC_CONTEXT - value: | - { - "name": "sync-http", - "version": "v1", - "requestID": "a0f2ad8d-5062-4812-91e9-95416489fb01", - "port": "8080", - "prePlugins": ["plugin-custom", "plugin-example"], - "postPlugins": ["plugin-custom", "plugin-example"], - "inputs": {}, - "outputs": {}, - "runtime": "Knative" - } - - name: POD_NAME - valueFrom: - fieldRef: - apiVersion: v1 - fieldPath: metadata.name - - name: POD_NAMESPACE - value: default - ports: - - containerPort: 8080 - name: function-port - protocol: TCP ---- -apiVersion: v1 -kind: Service -metadata: - name: sync -spec: - type: NodePort - selector: - app: sync-http - ports: - - protocol: TCP - port: 12345 - targetPort: 8080 - nodePort: 31234 diff --git a/test/declarative/sync-http/verify.sh b/test/declarative/sync-http/verify.sh deleted file mode 100644 index 174bbc4..0000000 --- a/test/declarative/sync-http/verify.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -url=http://$1 -while true; do - st=$(curl -s -o /dev/null -w "%{http_code}" -X GET "$url") - if [ "$st" -eq 200 ]; then - data_result=$(curl -X GET -H "Content-type: application/json" -H "Accept: application/json" -s "$url" | yq -P ".") - plugin_result=$(KUBECONFIG=/tmp/e2e-k8s.config kubectl logs --tail=1 -l app="sync-http" -c http | awk '{ print $8 }' | yq -P '.' -) - break - else - sleep 1 - continue - fi -done - -echo "$data_result" -echo "$plugin_result" diff --git a/test/pubsub/e2e.yaml b/test/pubsub/e2e.yaml index 6e8f4c0..80e6816 100644 --- a/test/pubsub/e2e.yaml +++ b/test/pubsub/e2e.yaml @@ -5,7 +5,12 @@ setup: - name: install dapr command: | dapr -v || (wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash) - dapr init -k --log-as-json + dapr init -k --runtime-version 1.8.1 --log-as-json --wait --timeout 600 + wait: + - namespace: dapr-system + resource: pod + label-selector: app.kubernetes.io/name=dapr + for: condition=Ready - name: install helm command: | diff --git a/test/pubsub/pub/Dockerfile.pubsub.publisher b/test/pubsub/pub/Dockerfile.pubsub.publisher index e3ff0f4..3ac4b9c 100644 --- a/test/pubsub/pub/Dockerfile.pubsub.publisher +++ b/test/pubsub/pub/Dockerfile.pubsub.publisher @@ -1,4 +1,4 @@ -FROM golang:1.16-alpine +FROM golang:1.17 ENV GO111MODULE=on ENV GOPROXY=https://goproxy.cn,direct diff --git a/test/pubsub/sub/Dockerfile.pubsub.subscriber b/test/pubsub/sub/Dockerfile.pubsub.subscriber index ea6adc4..20ca270 100644 --- a/test/pubsub/sub/Dockerfile.pubsub.subscriber +++ b/test/pubsub/sub/Dockerfile.pubsub.subscriber @@ -1,4 +1,4 @@ -FROM golang:1.16-alpine +FROM golang:1.17 ENV GO111MODULE=on ENV GOPROXY=https://goproxy.cn,direct diff --git a/test/sync-cloudevent/Dockerfile.sync.cloudevent b/test/sync-cloudevent/Dockerfile.sync.cloudevent index b5ded69..5548cd6 100644 --- a/test/sync-cloudevent/Dockerfile.sync.cloudevent +++ b/test/sync-cloudevent/Dockerfile.sync.cloudevent @@ -1,4 +1,4 @@ -FROM golang:1.16-alpine +FROM golang:1.17 ENV GO111MODULE=on ENV GOPROXY=https://goproxy.cn,direct diff --git a/test/sync-cloudevent/manifests.yaml b/test/sync-cloudevent/manifests.yaml index 3208b71..7b7b85b 100644 --- a/test/sync-cloudevent/manifests.yaml +++ b/test/sync-cloudevent/manifests.yaml @@ -1,51 +1,40 @@ -apiVersion: apps/v1 -kind: Deployment +apiVersion: v1 +kind: Pod metadata: name: sync-cloudevent labels: app: sync-cloudevent case: sync spec: - replicas: 1 - selector: - matchLabels: - app: sync-cloudevent - case: sync - template: - metadata: - labels: - app: sync-cloudevent - case: sync - spec: - containers: - - name: cloudevent - image: sync_e2e_cloudevent:latest - imagePullPolicy: IfNotPresent - env: - - name: FUNC_CONTEXT - value: | - { - "name": "sync-cloudevent", - "version": "v1", - "requestID": "a0f2ad8d-5062-4812-91e9-95416489fb01", - "port": "8080", - "prePlugins": ["plugin-custom", "plugin-example"], - "postPlugins": ["plugin-custom", "plugin-example"], - "inputs": {}, - "outputs": {}, - "runtime": "Knative" - } - - name: POD_NAME - valueFrom: - fieldRef: - apiVersion: v1 - fieldPath: metadata.name - - name: POD_NAMESPACE - value: default - ports: - - containerPort: 8080 - name: function-port - protocol: TCP + containers: + - name: cloudevent + image: sync_e2e_cloudevent:latest + imagePullPolicy: IfNotPresent + env: + - name: FUNC_CONTEXT + value: | + { + "name": "sync-cloudevent", + "version": "v1", + "requestID": "a0f2ad8d-5062-4812-91e9-95416489fb01", + "port": "8080", + "prePlugins": ["plugin-custom", "plugin-example"], + "postPlugins": ["plugin-custom", "plugin-example"], + "inputs": {}, + "outputs": {}, + "runtime": "Knative" + } + - name: POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name + - name: POD_NAMESPACE + value: default + ports: + - containerPort: 8080 + name: function-port + protocol: TCP --- apiVersion: v1 kind: Service diff --git a/test/sync-http/Dockerfile.sync.http b/test/sync-http/Dockerfile.sync.http index b580d7f..77d0b05 100644 --- a/test/sync-http/Dockerfile.sync.http +++ b/test/sync-http/Dockerfile.sync.http @@ -1,4 +1,4 @@ -FROM golang:1.16-alpine +FROM golang:1.17 ENV GO111MODULE=on ENV GOPROXY=https://goproxy.cn,direct