You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2021/11/29 02:03:12 UTC
[skywalking-swck] branch master updated: add adapter e2e (#50)
This is an automated email from the ASF dual-hosted git repository.
hanahmily pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-swck.git
The following commit(s) were added to refs/heads/master by this push:
new 338239d add adapter e2e (#50)
338239d is described below
commit 338239db2bf8a5d1b005729659b61ee37bdf517c
Author: dashanji <71...@users.noreply.github.com>
AuthorDate: Mon Nov 29 10:03:05 2021 +0800
add adapter e2e (#50)
* add adapter e2e
---
.github/workflows/go.yml | 21 ++++++++++--
Makefile | 2 ++
config/adapter/namespaced/apiservice/external.yaml | 1 +
config/dev/adapter/adapter.yaml | 2 +-
docs/custom-metrics-adapter.md | 8 ++---
test/e2e/demo.yaml | 7 ++++
test/e2e/hpa-demo.yaml | 40 ++++++++++++++++++++++
.../e2e.yaml | 38 ++++++++++----------
test/e2e/oap-ui-agent-external-storage/e2e.yaml | 2 +-
test/e2e/oap-ui-agent-internal-storage/e2e.yaml | 2 +-
test/e2e/oap-ui-agent/e2e.yaml | 2 +-
test/e2e/verify/hpa-metrics.yaml | 19 ++++++++++
test/e2e/verify/replicas.yaml | 19 ++++++++++
13 files changed, 134 insertions(+), 29 deletions(-)
diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
index 252397b..16ec706 100644
--- a/.github/workflows/go.yml
+++ b/.github/workflows/go.yml
@@ -130,10 +130,27 @@ jobs:
- name: Run E2E Test
uses: apache/skywalking-infra-e2e@996ed8902e941e2883fcf0ac5b3090364942d205
with:
- e2e-file: test/e2e/oap-ui-agent-external-storage/e2e.yaml
+ e2e-file: test/e2e/oap-ui-agent-external-storage/e2e.yaml
+ adapter-hpa-e2e-tests:
+ name: e2e tests(oap+agent+adapter+hpa)
+ runs-on: ubuntu-latest
+ steps:
+ - name: Install Go
+ uses: actions/setup-go@v2
+ with:
+ go-version: 1.17
+ id: go
+ - name: Check out code into the Go module directory
+ uses: actions/checkout@v2
+ - name: Update dependencies
+ run: GOPROXY=https://proxy.golang.org go mod download
+ - name: Run E2E Test
+ uses: apache/skywalking-infra-e2e@996ed8902e941e2883fcf0ac5b3090364942d205
+ with:
+ e2e-file: test/e2e/oap-agent-adapter-hpa/e2e.yaml
checks:
name: build
runs-on: ubuntu-20.04
- needs: [check, build, unit-tests, e2e-tests, internel-storage-e2e-tests, external-storage-e2e-tests]
+ needs: [check, build, unit-tests, e2e-tests, internel-storage-e2e-tests, external-storage-e2e-tests , adapter-hpa-e2e-tests]
steps:
- run: echo 'success'
diff --git a/Makefile b/Makefile
index 3e4851a..2858255 100644
--- a/Makefile
+++ b/Makefile
@@ -58,6 +58,8 @@ e2e-test:
e2e run -c test/e2e/oap-ui-agent-internal-storage/e2e.yaml
@echo "Run oap+ui+agent+storage(external) e2e..."
e2e run -c test/e2e/oap-ui-agent-external-storage/e2e.yaml
+ @echo "Run oap+agent+adapter+hpa e2e..."
+ e2e run -c test/e2e/oap-agent-adapter-hpa/e2e.yaml
# Build manager binary
operator: generate
diff --git a/config/adapter/namespaced/apiservice/external.yaml b/config/adapter/namespaced/apiservice/external.yaml
index 6d941e3..75526c4 100644
--- a/config/adapter/namespaced/apiservice/external.yaml
+++ b/config/adapter/namespaced/apiservice/external.yaml
@@ -22,6 +22,7 @@ metadata:
spec:
service:
name: apiserver
+ namespace: skywalking-custom-metrics-system
group: external.metrics.k8s.io
version: v1beta1
insecureSkipTLSVerify: true
diff --git a/config/dev/adapter/adapter.yaml b/config/dev/adapter/adapter.yaml
index 863de1c..9831a33 100644
--- a/config/dev/adapter/adapter.yaml
+++ b/config/dev/adapter/adapter.yaml
@@ -39,5 +39,5 @@ spec:
- --secure-port=6443
- --logtostderr=true
- --v=10
- - --oap-addr=http://host.docker.internal:12800/graphql
+ - --oap-addr=http://skywalking-system-oap.skywalking-system:12800/graphql #the address is used for testing, please use your oap address
diff --git a/docs/custom-metrics-adapter.md b/docs/custom-metrics-adapter.md
index 2690ae4..859aa9c 100644
--- a/docs/custom-metrics-adapter.md
+++ b/docs/custom-metrics-adapter.md
@@ -13,7 +13,7 @@ git clone git@github.com:apache/skywalking-swck.git
```
2. Edit file `config/adapter/adapter/kustomization.yaml` file to change your preferences. If you prefer to your private
- docker image, a quick path to override `ADAPTER_IMG` environment variable : `export ADAPTER_IMG=<private registry>/adapter:<tag>`
+ docker image, a quick path to override `ADAPTER_IMG` environment variable : `export ADAPTER_IMG=<private registry>/metrics-adapter:<tag>`
3. Use `make` to generate the final manifests and deploy:
@@ -43,7 +43,7 @@ External metrics allow you to autoscale your cluster based on any metric availab
external:
metric:
name: <metric_name>
- metricSelector:
+ selector:
matchLabels:
<label_key>: <label_value>
...
@@ -87,7 +87,7 @@ your HorizontalPodAutoscaler manifest to specify that you need less than 80ms of
external:
metric:
name: skywalking.apache.org|service_percentile
- metricSelector:
+ selector:
matchLabels:
service: front_gateway
# The index of [P50, P75, P90, P95, P99]. 2 is the index of P90(90%)
@@ -104,7 +104,7 @@ If the service is `v1|productpage|bookinfo|demo|-`:
external:
metric:
name: skywalking.apache.org|service_cpm
- metricSelector:
+ selector:
matchLabels:
"service.str.0": "v1"
"service.byte.1": "7c"
diff --git a/test/e2e/demo.yaml b/test/e2e/demo.yaml
index e9acb7e..8c96688 100644
--- a/test/e2e/demo.yaml
+++ b/test/e2e/demo.yaml
@@ -39,6 +39,13 @@ spec:
args: ["$(AGENT_OPTS)","-jar","/app.jar"]
ports:
- containerPort: 8085
+ readinessProbe:
+ httpGet:
+ path: /hello
+ port: 8085
+ initialDelaySeconds: 3
+ periodSeconds: 3
+ failureThreshold: 10
---
apiVersion: v1
kind: Service
diff --git a/test/e2e/hpa-demo.yaml b/test/e2e/hpa-demo.yaml
new file mode 100644
index 0000000..f5324ab
--- /dev/null
+++ b/test/e2e/hpa-demo.yaml
@@ -0,0 +1,40 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+apiVersion: autoscaling/v2beta2
+kind: HorizontalPodAutoscaler
+metadata:
+ name: hpa-demo
+ namespace: skywalking-system
+spec:
+ scaleTargetRef:
+ apiVersion: apps/v1
+ kind: Deployment
+ name: demo
+ minReplicas: 1
+ maxReplicas: 3
+ metrics:
+ - type: External
+ external:
+ metric:
+ name: skywalking.apache.org|service_cpm
+ selector:
+ matchLabels:
+ "service.str.0": "Your"
+ "service.byte.1": "5f"
+ "service.str.2": "ApplicationName"
+ target:
+ type: Value
+ value: 5
\ No newline at end of file
diff --git a/test/e2e/oap-ui-agent/e2e.yaml b/test/e2e/oap-agent-adapter-hpa/e2e.yaml
similarity index 73%
copy from test/e2e/oap-ui-agent/e2e.yaml
copy to test/e2e/oap-agent-adapter-hpa/e2e.yaml
index 62f4c8b..e018501 100644
--- a/test/e2e/oap-ui-agent/e2e.yaml
+++ b/test/e2e/oap-agent-adapter-hpa/e2e.yaml
@@ -42,17 +42,23 @@ setup:
- name: wait webhook installing
command: |
bash hack/wait-webhook.sh
+ - name: install metrics-adapter
+ command: |
+ export ADAPTER_IMG=metrics-adapter
+ make adapter-docker-build
+ make adapter-deploy
+ wait:
+ - namespace: skywalking-custom-metrics-system
+ resource: pod
+ for: condition=Ready
- name: setup oapserver and ui
command: |
kubectl create namespace skywalking-system
- kubectl apply -f test/e2e/skywalking-components.yaml
+ grep -B20 "\-\-\-" test/e2e/skywalking-components.yaml | kubectl apply -f -
wait:
- namespace: skywalking-system
resource: OAPServer/skywalking-system
for: condition=Available
- - namespace: skywalking-system
- resource: UI/skywalking-system
- for: condition=Available
- name: setup java agent demo
command: |
kubectl label namespace skywalking-system swck-injection=enabled
@@ -60,7 +66,10 @@ setup:
wait:
- namespace: skywalking-system
resource: deployment/demo
- for: condition=Available
+ for: condition=Available
+ - name: setup the hpa of java agent demo
+ command: |
+ kubectl apply -f test/e2e/hpa-demo.yaml
kind:
expose-ports:
- namespace: skywalking-system
@@ -69,9 +78,6 @@ setup:
- namespace: skywalking-system
resource: service/skywalking-system-oap
port: 12800
- - namespace: skywalking-system
- resource: service/skywalking-system-ui
- port: 80
timeout: 20m
cleanup:
@@ -81,7 +87,7 @@ cleanup:
trigger:
action: http
interval: 30s
- times: 5
+ times: 30
url: http://${service_demo_host}:${service_demo_8085}/hello
method: GET
@@ -93,14 +99,8 @@ verify:
# the interval between two attempts, e.g. 10s, 1m.
interval: 10s
cases:
- # test oapserver
- - query: swctl --display yaml --base-url=http://${service_skywalking_system_oap_host}:${service_skywalking_system_oap_12800}/graphql service ls
- expected: ../verify/service.yaml
- query: swctl --display yaml --base-url=http://${service_skywalking_system_oap_host}:${service_skywalking_system_oap_12800}/graphql metrics linear --name service_cpm --service-name Your_ApplicationName | yq e 'to_entries' -
- expected: ../verify/metrics.yaml
- - query: swctl --display yaml --base-url=http://${service_skywalking_system_oap_host}:${service_skywalking_system_oap_12800}/graphql endpoint list --keyword=hello --service-name Your_ApplicationName
- expected: ../verify/endpoint.yaml
- - query: swctl --display yaml --base-url=http://${service_skywalking_system_oap_host}:${service_skywalking_system_oap_12800}/graphql metrics linear --name endpoint_cpm --endpoint-name GET:/hello --service-name Your_ApplicationName | yq e 'to_entries' -
- expected: ../verify/metrics.yaml
- - includes:
- - ../ui-cases.yaml
\ No newline at end of file
+ expected: ../verify/hpa-metrics.yaml
+ # the trigger will do 30 times, as the hpa's value is set as 5, so the deployment's replicas will be 3(maxReplicas).
+ - query: 'kubectl get deployment demo -n skywalking-system -o jsonpath=''{.status.replicas}'' | yq e ''{"replicas": .}'' - | yq e ''to_entries'' -'
+ expected: ../verify/replicas.yaml
\ No newline at end of file
diff --git a/test/e2e/oap-ui-agent-external-storage/e2e.yaml b/test/e2e/oap-ui-agent-external-storage/e2e.yaml
index 550b495..c3a82e5 100644
--- a/test/e2e/oap-ui-agent-external-storage/e2e.yaml
+++ b/test/e2e/oap-ui-agent-external-storage/e2e.yaml
@@ -94,7 +94,7 @@ cleanup:
trigger:
action: http
- interval: 30s
+ interval: 10s
times: 5
url: http://${service_demo_host}:${service_demo_8085}/hello
method: GET
diff --git a/test/e2e/oap-ui-agent-internal-storage/e2e.yaml b/test/e2e/oap-ui-agent-internal-storage/e2e.yaml
index 41fdfe4..c7acbee 100644
--- a/test/e2e/oap-ui-agent-internal-storage/e2e.yaml
+++ b/test/e2e/oap-ui-agent-internal-storage/e2e.yaml
@@ -90,7 +90,7 @@ cleanup:
trigger:
action: http
- interval: 30s
+ interval: 10s
times: 5
url: http://${service_demo_host}:${service_demo_8085}/hello
method: GET
diff --git a/test/e2e/oap-ui-agent/e2e.yaml b/test/e2e/oap-ui-agent/e2e.yaml
index 62f4c8b..1760fdd 100644
--- a/test/e2e/oap-ui-agent/e2e.yaml
+++ b/test/e2e/oap-ui-agent/e2e.yaml
@@ -80,7 +80,7 @@ cleanup:
trigger:
action: http
- interval: 30s
+ interval: 10s
times: 5
url: http://${service_demo_host}:${service_demo_8085}/hello
method: GET
diff --git a/test/e2e/verify/hpa-metrics.yaml b/test/e2e/verify/hpa-metrics.yaml
new file mode 100644
index 0000000..54084dd
--- /dev/null
+++ b/test/e2e/verify/hpa-metrics.yaml
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+{{- contains . }}
+- key: {{ notEmpty .key }}
+ value: {{ gt .value 15 }}
+{{- end }}
\ No newline at end of file
diff --git a/test/e2e/verify/replicas.yaml b/test/e2e/verify/replicas.yaml
new file mode 100644
index 0000000..7c2dadd
--- /dev/null
+++ b/test/e2e/verify/replicas.yaml
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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.
+
+{{- contains . }}
+- key: "replicas"
+ value: 3
+{{- end }}
\ No newline at end of file