add e2e test for kafka transporter (#42)

This commit is contained in:
Daming 2021-10-18 09:46:16 +08:00 committed by GitHub
parent fb5e48438a
commit fbdfc42b4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 509 additions and 239 deletions

View File

@ -23,8 +23,16 @@ on:
jobs: jobs:
E2E: E2E:
name: Basic function + gRPC transport(Java8) name: Basic function + ${{ matrix.case.name }} transport(Java8)
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 90
strategy:
matrix:
case:
- name: gRPC
path: test/e2e/case/grpc/e2e.yaml
- name: Kafka
path: test/e2e/case/kafka/e2e.yaml
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
with: with:
@ -42,7 +50,11 @@ jobs:
SW_VERSION=$(./mvnw -q -DforceStdout -N org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version) SW_VERSION=$(./mvnw -q -DforceStdout -N org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version)
./mvnw -B package -f ./test/e2e/base/pom.xml -Dsw.version=${SW_VERSION} ./mvnw -B package -f ./test/e2e/base/pom.xml -Dsw.version=${SW_VERSION}
echo "::endgroup::" echo "::endgroup::"
- name: Run E2E Tests - name: Setup go
uses: apache/skywalking-infra-e2e@7d55a252c35bf69f65dc64675a80699dc3c21bde uses: actions/setup-go@v2
with: with:
e2e-file: test/e2e/case/base/e2e.yaml go-version: '1.16'
- name: Run E2E Tests
uses: apache/skywalking-infra-e2e@main
with:
e2e-file: ${{ matrix.case.path }}

View File

@ -245,7 +245,7 @@ plugin.kafka.topic_profiling=${SW_PLUGIN_KAFKA_TOPIC_PROFILINGS:skywalking-profi
# Specify which Kafka topic name for the register or heartbeat data of Service Instance to report to. # Specify which Kafka topic name for the register or heartbeat data of Service Instance to report to.
plugin.kafka.topic_management=${SW_PLUGIN_KAFKA_TOPIC_MANAGEMENT:skywalking-managements} plugin.kafka.topic_management=${SW_PLUGIN_KAFKA_TOPIC_MANAGEMENT:skywalking-managements}
# Specify which Kafka topic name for the logging data to report to. # Specify which Kafka topic name for the logging data to report to.
plugin.kafka.topic_logging=${SW_PLUGIN_KAFKA_TOPIC_LOGGING:skywalking-logging} plugin.kafka.topic_logging=${SW_PLUGIN_KAFKA_TOPIC_LOGGING:skywalking-logs}
# isolate multi OAP server when using same Kafka cluster (final topic name will append namespace before Kafka topics with `-` ). # isolate multi OAP server when using same Kafka cluster (final topic name will append namespace before Kafka topics with `-` ).
plugin.kafka.namespace=${SW_KAFKA_NAMESPACE:} plugin.kafka.namespace=${SW_KAFKA_NAMESPACE:}
# Match spring beans with regular expression for the class name. Multiple expressions could be separated by a comma. This only works when `Spring annotation plugin` has been activated. # Match spring beans with regular expression for the class name. Multiple expressions could be separated by a comma. This only works when `Spring annotation plugin` has been activated.

View File

@ -35,6 +35,8 @@ services:
build: build:
context: provider context: provider
dockerfile: Dockerfile dockerfile: Dockerfile
args:
ENABLE_KAFKA_REPORTER: "false"
expose: expose:
- 9090 - 9090
networks: networks:
@ -42,7 +44,7 @@ services:
environment: environment:
SW_AGENT_NAME: e2e-service-provider SW_AGENT_NAME: e2e-service-provider
SW_AGENT_COLLECTOR_BACKEND_SERVICES: oap:11800 SW_AGENT_COLLECTOR_BACKEND_SERVICES: oap:11800
SW_INSTANCE_NAME: provider1 SW_AGENT_INSTANCE_NAME: provider1
SW_LOGGING_OUTPUT: CONSOLE SW_LOGGING_OUTPUT: CONSOLE
healthcheck: healthcheck:
test: [ "CMD", "sh", "-c", "nc -zn 127.0.0.1 9090"] test: [ "CMD", "sh", "-c", "nc -zn 127.0.0.1 9090"]
@ -54,15 +56,16 @@ services:
build: build:
context: consumer context: consumer
dockerfile: Dockerfile dockerfile: Dockerfile
args:
ENABLE_KAFKA_REPORTER: "false"
expose: expose:
- 9090 - 9090
networks: networks:
- e2e - e2e
environment: environment:
PROVIDER_URL: http://provider:9090
SW_AGENT_COLLECTOR_BACKEND_SERVICES: oap:11800 SW_AGENT_COLLECTOR_BACKEND_SERVICES: oap:11800
SW_AGENT_NAME: e2e-service-consumer SW_AGENT_NAME: e2e-service-consumer
SW_INSTANCE_NAME: consumer1 SW_AGENT_INSTANCE_NAME: consumer1
SW_LOGGING_OUTPUT: CONSOLE SW_LOGGING_OUTPUT: CONSOLE
healthcheck: healthcheck:
test: [ "CMD", "sh", "-c", "nc -zn 127.0.0.1 9090"] test: [ "CMD", "sh", "-c", "nc -zn 127.0.0.1 9090"]

View File

@ -15,6 +15,10 @@
FROM skywalking/skywalking-java:latest-java8 FROM skywalking/skywalking-java:latest-java8
ARG ENABLE_KAFKA_REPORTER
RUN if [[ "${ENABLE_KAFKA_REPORTER}" == "true" ]]; then cp -rf /skywalking/agent/optional-reporter-plugins/* /skywalking/agent/plugins/ ; fi
VOLUME /services VOLUME /services
ADD target/e2e-service-consumer.jar /services/ ADD target/e2e-service-consumer.jar /services/

View File

@ -15,6 +15,10 @@
FROM skywalking/skywalking-java:latest-java8 FROM skywalking/skywalking-java:latest-java8
ARG ENABLE_KAFKA_REPORTER
RUN if [[ "${ENABLE_KAFKA_REPORTER}" == "true" ]]; then cp -rf /skywalking/agent/optional-reporter-plugins/* /skywalking/agent/plugins/ ; fi
VOLUME /services VOLUME /services
ADD target/e2e-service-provider.jar /services/ ADD target/e2e-service-provider.jar /services/

View File

@ -1,100 +0,0 @@
# 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.
# This file is used to show how to write configuration files and can be used to test.
setup:
env: compose
file: docker-compose.yml
timeout: 1200
steps:
- name: install yq
command: |
if ! command -v yq &> /dev/null; then
mkdir -p /tmp/skywalking-infra-e2e/bin && cd /tmp/skywalking-infra-e2e
mkdir -p yq && cd yq
curl -kLo yq.tar.gz https://github.com/mikefarah/yq/archive/v4.11.1.tar.gz
tar -zxf yq.tar.gz --strip=1
go install && go build -ldflags -s && mv yq ../bin/yq
export PATH="$PATH:/tmp/skywalking-infra-e2e/bin"
echo "success to install yq"
fi
- name: install swctl
command: |
if ! command -v swctl &> /dev/null; then
mkdir -p /tmp/skywalking-infra-e2e/bin && cd /tmp/skywalking-infra-e2e
mkdir -p swctl && cd swctl
curl -kLo skywalking-cli.tar.gz https://github.com/apache/skywalking-cli/archive/4d1cb83e24ff58988f4aba0daa50259593b11670.tar.gz
tar -zxf skywalking-cli.tar.gz --strip=1
utype=$(uname | awk '{print tolower($0)}')
make $utype && mv bin/swctl-*-$utype-amd64 ../bin/swctl
export PATH="$PATH:/tmp/skywalking-infra-e2e/bin"
echo "success to install swctl"
fi
cleanup:
# always never success failure
on: always
trigger:
action: http
interval: 3s
times: 5
url: http://${consumer_host}:${consumer_9090}/info
method: POST
verify:
# verify with retry strategy
retry:
# max retry count
count: 20
# the interval between two retries, in millisecond.
interval: 10000
cases:
# basic check: service list
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql service ls
expected: expected/service.yml
# basic check: service metrics
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name service_sla --service=e2e-service-provider |yq e 'to_entries' -
expected: expected/metrics-has-value.yml
# basic check: service endpoint
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql endpoint list --keyword=info --service-id=$(swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql service ls|grep -B 1 'provider'|yq e '.[0].id' -)
expected: expected/service-endpoint.yml
# basic check: service endpoint metrics
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name endpoint_cpm --endpoint=POST:/info --service=e2e-service-provider |yq e 'to_entries' -
expected: expected/metrics-has-value.yml
# native management: service instance list
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql instance list --service-name=e2e-service-provider
expected: expected/service-instance.yml
# native jvm: service instance jvm metrics
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name instance_jvm_thread_live_count --instance=provider1 --service=e2e-service-provider |yq e 'to_entries' -
expected: expected/metrics-has-value.yml
# native tracing: trace segment list
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql trace ls
expected: expected/traces-list.yml
# native tracing: trace detail
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql trace $(swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql trace ls|grep -A 5 'POST:/info'|tail -n1|awk -F ' ' '{print $2}')
expected: expected/trace-info-detail.yml
# native event: event list
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql event list --service=e2e-service-provider --instance=provider1
expected: expected/event-list.yml
# native log: logs list
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql logs list --service-id=$(swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql service ls|grep -B 1 'provider'|yq e '.[0].id' -) --trace-id=$(swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql trace ls|grep -A 5 'POST:/info'|tail -n1|awk -F ' ' '{print $2}')
expected: expected/logs-list.yml

View File

@ -1,47 +0,0 @@
# 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.
traces:
{{- range .traces }}
- segmentid: {{ notEmpty .segmentid }}
endpointnames:
{{- if eq (index .endpointnames 0) "HikariCP/Connection/getConnection" }}
- HikariCP/Connection/getConnection
{{- end }}
{{- if eq (index .endpointnames 0) "HikariCP/Connection/close" }}
- HikariCP/Connection/close
{{- end }}
{{- if eq (index .endpointnames 0) "H2/JDBI/Statement/execute" }}
- H2/JDBI/Statement/execute
{{- end}}
{{- if eq (index .endpointnames 0) "H2/JDBI/Statement/executeQuery" }}
- H2/JDBI/Statement/executeQuery
{{- end}}
{{- if eq (index .endpointnames 0) "H2/JDBI/PreparedStatement/executeQuery" }}
- H2/JDBI/PreparedStatement/executeQuery
{{- end }}
{{- if eq (index .endpointnames 0) "POST:/info" }}
- POST:/info
{{- end }}
{{- if eq (index .endpointnames 0) "POST:/users" }}
- POST:/users
{{- end }}
duration: {{ ge .duration 0 }}
start: "{{ notEmpty .start}}"
iserror: false
traceids:
- {{ (index .traceids 0) }}
{{- end }}
total: {{ gt .total 0 }}

View File

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
events: events:
{{- range .events }} {{- contains .events }}
- uuid: {{ notEmpty .uuid }} - uuid: {{ notEmpty .uuid }}
source: source:
service: e2e-service-provider service: e2e-service-provider
@ -24,12 +24,10 @@ events:
type: Normal type: Normal
message: Start Java Application message: Start Java Application
parameters: parameters:
{{- range .parameters }} {{- contains .parameters }}
{{- if eq .key "OPTS"}}
- key: OPTS - key: OPTS
value: {{ notEmpty .value }} value: {{ notEmpty .value }}
{{- end }} {{- end }}
{{- end }}
starttime: {{ gt .starttime 0 }} starttime: {{ gt .starttime 0 }}
endtime: {{ gt .endtime 0 }} endtime: {{ gt .endtime 0 }}
{{- end }} {{- end }}

View File

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
logs: logs:
{{- range .logs }} {{- contains .logs }}
- servicename: e2e-service-provider - servicename: e2e-service-provider
serviceid: {{ b64enc "e2e-service-provider" }}.1 serviceid: {{ b64enc "e2e-service-provider" }}.1
serviceinstancename: provider1 serviceinstancename: provider1
@ -27,19 +27,13 @@ logs:
content: | content: |
{{ notEmpty .content }} {{ notEmpty .content }}
tags: tags:
{{- range .tags }} {{- contains .tags }}
{{- if eq .key "level"}}
- key: level - key: level
value: INFO value: INFO
{{- end }}
{{- if eq .key "logger" }}
- key: logger - key: logger
value: {{ notEmpty .value }} value: {{ notEmpty .value }}
{{- end }}
{{- if eq .key "thread" }}
- key: thread - key: thread
value: {{ notEmpty .value }} value: {{ notEmpty .value }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- end }}
total: {{ gt .total 0 }} total: {{ gt .total 0 }}

View File

@ -13,9 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
{{- range .}} {{- contains .}}
{{- if eq .name "POST:/info" }}
- id: {{ b64enc "e2e-service-provider" }}.1_{{ b64enc "POST:/info" }} - id: {{ b64enc "e2e-service-provider" }}.1_{{ b64enc "POST:/info" }}
name: POST:/info name: POST:/info
{{- end}}
{{- end}} {{- end}}

View File

@ -15,40 +15,26 @@
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
{{- range .}} {{- contains .}}
- id: {{ b64enc "e2e-service-provider" }}.1_{{ b64enc "provider1" }} - id: {{ b64enc "e2e-service-provider" }}.1_{{ b64enc "provider1" }}
name: {{ notEmpty .name }} name: {{ notEmpty .name }}
attributes: attributes:
{{- range .attributes }} {{- contains .attributes }}
{{- if eq .name "OS Name" }}
- name: OS Name - name: OS Name
value: Linux value: Linux
{{- end }}
{{- if eq .name "hostname" }}
- name: hostname - name: hostname
value: {{ notEmpty .value }} value: {{ notEmpty .value }}
{{- end }}
{{- if eq .name "Process No." }}
- name: Process No. - name: Process No.
value: "1" value: "1"
{{- end }}
{{- if eq .name "Start Time" }}
- name: Start Time - name: Start Time
value: {{ notEmpty .value }} value: {{ notEmpty .value }}
{{- end }}
{{- if eq .name "JVM Arguments" }}
- name: JVM Arguments - name: JVM Arguments
value: '{{ notEmpty .value }}' value: '{{ notEmpty .value }}'
{{- end }}
{{- if eq .name "Jar Dependencies" }}
- name: Jar Dependencies - name: Jar Dependencies
value: '{{ notEmpty .value }}' value: '{{ notEmpty .value }}'
{{- end }}
{{- if eq .name "ipv4s" }}
- name: ipv4s - name: ipv4s
value: {{ notEmpty .value }} value: {{ notEmpty .value }}
{{- end }} {{- end }}
{{- end}}
language: JAVA language: JAVA
instanceuuid: {{ b64enc "e2e-service-provider" }}.1_{{ b64enc "provider1" }} instanceuuid: {{ b64enc "e2e-service-provider" }}.1_{{ b64enc "provider1" }}
{{- end}} {{- end}}

View File

@ -14,60 +14,34 @@
# limitations under the License. # limitations under the License.
spans: spans:
{{- range .spans}} {{- contains .spans}}
- traceid: {{ notEmpty .traceid }} - traceid: {{ notEmpty .traceid }}
segmentid: {{ notEmpty .segmentid }} segmentid: {{ notEmpty .segmentid }}
spanid: {{ .spanid }} spanid: {{ .spanid }}
parentspanid: {{ .parentspanid }} parentspanid: {{ .parentspanid }}
refs: refs:
{{- if eq .servicecode "e2e-service-provider" }} {{- contains .refs }}
{{- range .refs }} - traceid: {{ notEmpty .traceid }}
- traceid: {{ notEmpty .traceid }} parentsegmentid: {{ notEmpty .parentsegmentid }}
parentsegmentid: {{ notEmpty .parentsegmentid }} parentspanid: 1
parentspanid: 1 type: CROSS_PROCESS
type: CROSS_PROCESS
{{- end }} {{- end }}
{{- end }} servicecode: "e2e-service-provider"
{{- if eq .servicecode "e2e-service-consumer" }} serviceinstancename: "provider1"
[]
{{- end }}
servicecode: {{ notEmpty .servicecode }}
serviceinstancename: {{ notEmpty .serviceinstancename }}
starttime: {{ gt .starttime 0 }} starttime: {{ gt .starttime 0 }}
endtime: {{ gt .endtime 0 }} endtime: {{ gt .endtime 0 }}
endpointname: endpointname: POST:/info
{{- if eq .type "Exit" }} type: Entry
/info peer: ""
{{- end }} component: Tomcat
{{- if eq .type "Entry" }}
POST:/info
{{- end }}
type: {{ notEmpty .type }}
peer:
{{- if eq .type "Exit" }}
provider:9090
{{ else }}
""
{{- end }}
component:
{{- if eq .type "Exit" }}
SpringRestTemplate
{{- end }}
{{- if eq .type "Entry" }}
Tomcat
{{- end }}
iserror: false iserror: false
layer: Http layer: Http
tags: tags:
{{- range .tags }} {{- contains .tags }}
{{- if eq .key "http.method" }}
- key: http.method - key: http.method
value: POST value: POST
{{- end }}
{{- if eq .key "url" }}
- key: url - key: url
value: {{ notEmpty .value }} value: {{ notEmpty .value }}
{{- end }} {{- end }}
{{- end }}
logs: [] logs: []
{{- end }} {{- end }}

View File

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
spans: spans:
{{- range .spans}} {{- contains .spans}}
- traceid: {{ notEmpty .traceid }} - traceid: {{ notEmpty .traceid }}
segmentid: {{ notEmpty .segmentid }} segmentid: {{ notEmpty .segmentid }}
spanid: 0 spanid: 0
@ -31,15 +31,11 @@ spans:
iserror: false iserror: false
layer: Http layer: Http
tags: tags:
{{- range .tags }} {{- contains .tags }}
{{- if eq .key "http.method" }}
- key: http.method - key: http.method
value: POST value: POST
{{- end }}
{{- if eq .key "url" }}
- key: url - key: url
value: {{ notEmpty .value }} value: {{ notEmpty .value }}
{{- end }} {{- end }}
{{- end }}
logs: [] logs: []
{{- end }} {{- end }}

View File

@ -0,0 +1,29 @@
# 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.
traces:
{{- contains .traces }}
- segmentid: {{ notEmpty .segmentid }}
endpointnames:
{{- contains .endpointnames }}
- POST:/info
{{- end }}
duration: {{ ge .duration 0 }}
start: "{{ notEmpty .start}}"
iserror: false
traceids:
- {{ (index .traceids 0) }}
{{- end }}
total: {{ gt .total 0 }}

View File

@ -27,9 +27,6 @@ services:
extends: extends:
file: ../../base/base-compose.yml file: ../../base/base-compose.yml
service: provider service: provider
environment:
SW_AGENT_INSTANCE_NAME: provider1
SW_LOGGING_OUTPUT: CONSOLE
ports: ports:
- 9090 - 9090
depends_on: depends_on:
@ -41,8 +38,7 @@ services:
file: ../../base/base-compose.yml file: ../../base/base-compose.yml
service: consumer service: consumer
environment: environment:
SW_AGENT_INSTANCE_NAME: consumer1 PROVIDER_URL: http://provider:9090
SW_LOGGING_OUTPUT: CONSOLE
ports: ports:
- 9090 - 9090
depends_on: depends_on:

View File

@ -0,0 +1,90 @@
# 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.
# This file is used to show how to write configuration files and can be used to test.
setup:
env: compose
file: docker-compose.yml
timeout: 1200
init-system-environment: ../../script/env
steps:
- name: install yq
command: bash test/e2e/script/prepare/install.sh yq
- name: install swctl
command: bash test/e2e/script/prepare/install.sh swctl
cleanup:
# always never success failure
on: always
trigger:
action: http
interval: 3s
times: 5
url: http://${consumer_host}:${consumer_9090}/info
method: POST
verify:
# verify with retry strategy
retry:
# max retry count
count: 20
# the interval between two retries, in millisecond.
interval: 10s
cases:
# basic check: service list
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql service ls
expected: ../expected/service.yml
# basic check: service metrics
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name service_sla --service-name=e2e-service-provider |yq e 'to_entries' -
expected: ../expected/metrics-has-value.yml
# basic check: service endpoint
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql endpoint list --keyword=info --service-name=e2e-service-provider
expected: ../expected/service-endpoint.yml
# basic check: service endpoint metrics
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name endpoint_cpm --endpoint-name=POST:/info --service-name=e2e-service-provider |yq e 'to_entries' -
expected: ../expected/metrics-has-value.yml
# service instance list
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql instance list --service-name=e2e-service-provider
expected: ../expected/service-instance.yml
# service instance jvm metrics
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name instance_jvm_thread_live_count --instance-name=provider1 --service-name=e2e-service-provider |yq e 'to_entries' -
expected: ../expected/metrics-has-value.yml
# trace segment list
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql trace ls
expected: ../expected/traces-list.yml
# trace detail
- query: |
swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql trace $( \
swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql trace ls \
| yq e '.traces | select(.[].endpointnames[0]=="POST:/info") | .[0].traceids[0]' - \
)
expected: ../expected/trace-info-detail.yml
# event list
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql event list --service-name=e2e-service-provider --instance-name=provider1
expected: ../expected/event-list.yml
# logs list
- query: |
swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql logs list --service-name=e2e-service-provider --trace-id=$( \
swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql trace ls \
| yq e '.traces | select(.[].endpointnames[0]=="POST:/info") | .[0].traceids[0]' -
)
expected: ../expected/logs-list.yml

View File

@ -0,0 +1,129 @@
# 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.
version: '2.1'
services:
zookeeper:
image: zookeeper:3.4
hostname: zookeeper
expose:
- 2181
networks:
- e2e
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
healthcheck:
test: ["CMD", "sh", "-c", "nc -nz 127.0.0.1 2181"]
interval: 5s
timeout: 60s
retries: 120
broker-a:
image: bitnami/kafka:2.4.1
hostname: broker-a
expose:
- 9092
networks:
- e2e
environment:
- KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
- KAFKA_BROKER_ID=10
- ALLOW_PLAINTEXT_LISTENER=yes
depends_on:
zookeeper:
condition: service_healthy
healthcheck:
test: ["CMD", "kafka-topics.sh", "--list", "--zookeeper", "zookeeper:2181"]
interval: 5s
timeout: 60s
retries: 120
broker-b:
image: bitnami/kafka:2.4.1
hostname: broker-b
expose:
- 9092
networks:
- e2e
environment:
- KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
- KAFKA_BROKER_ID=24
- ALLOW_PLAINTEXT_LISTENER=yes
depends_on:
zookeeper:
condition: service_healthy
healthcheck:
test: ["CMD", "kafka-topics.sh", "--list", "--zookeeper", "zookeeper:2181"]
interval: 5s
timeout: 60s
retries: 12
oap:
extends:
file: ../../base/base-compose.yml
service: oap
environment:
SW_KAFKA_FETCHER: default
SW_KAFKA_FETCHER_ENABLE_NATIVE_PROTO_LOG: "true"
SW_KAFKA_FETCHER_SERVERS: broker-a:9092,broker-b:9092
SW_KAFKA_FETCHER_PARTITIONS: 2
SW_KAFKA_FETCHER_PARTITIONS_FACTOR: 1
ports:
- 12800
depends_on:
broker-a:
condition: service_healthy
broker-b:
condition: service_healthy
kafkaprovider:
extends:
file: ../../base/base-compose.yml
service: provider
build:
args:
ENABLE_KAFKA_REPORTER: "true"
environment:
SW_KAFKA_BOOTSTRAP_SERVERS: broker-a:9092,broker-b:9092
SW_GET_TOPIC_TIMEOUT: 60
SW_PLUGIN_KAFKA_TOPIC_LOGGING: skywalking-logs
ports:
- 9090
depends_on:
oap:
condition: service_healthy
kafkaconsumer:
extends:
file: ../../base/base-compose.yml
service: consumer
build:
args:
ENABLE_KAFKA_REPORTER: "true"
environment:
SW_KAFKA_BOOTSTRAP_SERVERS: broker-a:9092,broker-b:9092
SW_GET_TOPIC_TIMEOUT: 60
SW_PLUGIN_KAFKA_TOPIC_LOGGING: skywalking-logs
PROVIDER_URL: http://kafkaprovider:9090
ports:
- 9090
depends_on:
kafkaprovider:
condition: service_healthy
networks:
e2e:

View File

@ -0,0 +1,90 @@
# 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.
# This file is used to show how to write configuration files and can be used to test.
setup:
env: compose
file: docker-compose.yml
timeout: 1200
init-system-environment: ../../script/env
steps:
- name: install yq
command: bash test/e2e/script/prepare/install.sh yq
- name: install swctl
command: bash test/e2e/script/prepare/install.sh swctl
cleanup:
# always never success failure
on: always
trigger:
action: http
interval: 3s
times: 5
url: http://${kafkaconsumer_host}:${kafkaconsumer_9090}/info
method: POST
verify:
# verify with retry strategy
retry:
# max retry count
count: 20
# the interval between two retries, in millisecond.
interval: 10s
cases:
# basic check: service list
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql service ls
expected: ../expected/service.yml
# basic check: service metrics
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name service_sla --service-name=e2e-service-provider |yq e 'to_entries' -
expected: ../expected/metrics-has-value.yml
# basic check: service endpoint
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql endpoint list --keyword=info --service-name=e2e-service-provider
expected: ../expected/service-endpoint.yml
# basic check: service endpoint metrics
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name endpoint_cpm --endpoint-name=POST:/info --service-name=e2e-service-provider |yq e 'to_entries' -
expected: ../expected/metrics-has-value.yml
# service instance list
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql instance list --service-name=e2e-service-provider
expected: ../expected/service-instance.yml
# service instance jvm metrics
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name instance_jvm_thread_live_count --instance-name=provider1 --service-name=e2e-service-provider |yq e 'to_entries' -
expected: ../expected/metrics-has-value.yml
# trace segment list
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql trace ls
expected: ../expected/traces-list.yml
# trace detail
- query: |
swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql trace $( \
swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql trace ls \
| yq e '.traces | select(.[].endpointnames[0]=="POST:/info") | .[0].traceids[0]' - \
)
expected: ../expected/trace-info-detail.yml
# event list
- query: swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql event list --service-name=e2e-service-provider --instance-name=provider1
expected: ../expected/event-list.yml
# logs list
- query: |
swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql logs list --service-name=e2e-service-provider --trace-id=$( \
swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql trace ls \
| yq e '.traces | select(.[].endpointnames[0]=="POST:/info") | .[0].traceids[0]' -
)
expected: ../expected/logs-list.yml

16
test/e2e/script/env Normal file
View File

@ -0,0 +1,16 @@
# 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.
SW_CTL_COMMIT=b90255132f916f53eb90955cc8a6445b03a4bec3

View File

@ -0,0 +1,33 @@
#!/usr/bin/env bash
# ----------------------------------------------------------------------------
# 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.
# ----------------------------------------------------------------------------
BASE_DIR=$1
BIN_DIR=$2
set -ex
if ! command -v swctl &> /dev/null; then
mkdir -p $BASE_DIR/swctl && cd $BASE_DIR/swctl
curl -kLo skywalking-cli.tar.gz https://github.com/apache/skywalking-cli/archive/${SW_CTL_COMMIT}.tar.gz
tar -zxf skywalking-cli.tar.gz --strip=1
utype=$(uname | awk '{print tolower($0)}')
make $utype && mv bin/swctl-*-$utype-amd64 $BIN_DIR/swctl
fi

View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
# ----------------------------------------------------------------------------
# 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.
# ----------------------------------------------------------------------------
BASE_DIR=$1
BIN_DIR=$2
if ! command -v yq &> /dev/null; then
mkdir -p $BASE_DIR/yq && cd $BASE_DIR/yq
curl -kLo yq.tar.gz https://github.com/mikefarah/yq/archive/v4.11.1.tar.gz
tar -zxf yq.tar.gz --strip=1
go install && go build -ldflags -s && cp yq $BIN_DIR/
fi

View File

@ -0,0 +1,35 @@
#!/usr/bin/env bash
# ----------------------------------------------------------------------------
# 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.
# ----------------------------------------------------------------------------
set -ex
NAME=$1
CURRENT_DIR="$(cd "$(dirname $0)"; pwd)"
# prepare base dir
TMP_DIR=/tmp/skywalking-infra-e2e
BIN_DIR=/usr/local/bin
mkdir -p $TMP_DIR && cd $TMP_DIR
# execute install
bash $CURRENT_DIR/install-$NAME.sh $TMP_DIR $BIN_DIR
echo "success to install $NAME"