未验证 提交 c9b28e4d 编写于 作者: W wankai123 提交者: GitHub

Replace e2e cases to e2e-v2: TTL (#8028)

上级 50cc0445
......@@ -39,9 +39,15 @@ jobs:
timeout-minutes: 90
strategy:
matrix:
storage: ['es6', 'es7', 'influxdb', 'tidb', 'postgresql']
env:
SW_STORAGE: ${{ matrix.storage }}
config-file:
- ttl/tidb/e2e.yaml
- ttl/influxdb/e2e.yaml
- ttl/postgresql/e2e.yaml
include:
- es-version: 6.3.2
config-file: ttl/es/e2e.yaml
- es-version: 7.15.0
config-file: ttl/es/e2e.yaml
steps:
- uses: actions/checkout@v2
with:
......@@ -50,6 +56,8 @@ jobs:
uses: ./.github/actions/skip
- name: Run E2E Test
if: env.SKIP_CI != 'true'
uses: ./.github/actions/e2e-test
uses: ./.github/actions/infra-e2e-test
env:
ES_VERSION: ${{ matrix.es-version }}
with:
test_class: org.apache.skywalking.e2e.ttl.StorageTTLE2E
config-file: ${{ matrix.config-file }}
......@@ -10,3 +10,6 @@
[submodule "test/e2e/e2e-protocol/src/main/proto"]
path = test/e2e/e2e-protocol/src/main/proto
url = https://github.com/apache/skywalking-data-collect-protocol.git
[submodule "test/e2e-v2/java-test-service/e2e-protocol/src/main/proto"]
path = test/e2e-v2/java-test-service/e2e-protocol/src/main/proto
url = git@github.com:apache/skywalking-data-collect-protocol.git
......@@ -26,6 +26,7 @@ Release Notes.
- Kafka: Base, Meter, Log, Profile
- Client-JS
- Istio: ALS, Metrics
- TTL
* Support JDK 16 and 17.
#### OAP Server
......
# 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:
es:
image: elastic/elasticsearch:${ES_VERSION}
expose:
- 9200
networks:
- e2e
environment:
- discovery.type=single-node
- cluster.routing.allocation.disk.threshold_enabled=false
healthcheck:
test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9200"]
interval: 5s
timeout: 60s
retries: 120
oap:
extends:
file: ../../../script/docker-compose/base-compose.yml
service: oap
environment:
SW_STORAGE: elasticsearch
SW_STORAGE_ES_BULK_ACTIONS: 1
SW_CORE_DATA_KEEPER_EXECUTE_PERIOD: 1
SW_STORAGE_ES_FLUSH_INTERVAL: 1
SW_CORE_METRICS_DATA_TTL: 7
depends_on:
es:
condition: service_healthy
ports:
- 12800
sender:
image: "adoptopenjdk/openjdk8:alpine-jre"
volumes:
- ./../../../java-test-service/e2e-mock-sender/target/e2e-mock-sender-2.0.0.jar:/e2e-mock-sender-2.0.0.jar
command: [ "java", "-jar", "/e2e-mock-sender-2.0.0.jar" ]
environment:
OAP_HOST: oap
OAP_GRPC_PORT: 11800
networks:
- e2e
ports:
- 9093
healthcheck:
test: ["CMD", "sh", "-c", "nc -nz 127.0.0.1 9093"]
interval: 5s
timeout: 60s
retries: 120
depends_on:
oap:
condition: service_healthy
networks:
e2e:
# 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-v2/script/prepare/setup-e2e-shell/install.sh yq
- name: install swctl
command: bash test/e2e-v2/script/prepare/setup-e2e-shell/install.sh swctl
- name: install etcdctl
command: bash test/e2e-v2/script/prepare/setup-e2e-shell/install.sh etcdctl
verify:
retry:
count: 30
interval: 3s
cases:
- includes:
- ../ttl-cases.yaml
# 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.
{{- range . }}
- key: {{ notEmpty .key }}
value: 0
{{- end }}
# 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: {{ ge .value 1 }}
{{- end }}
# 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:
influxdb:
image: influxdb:1.7.9
expose:
- 8086
networks:
- e2e
healthcheck:
test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/8086"]
interval: 5s
timeout: 60s
retries: 120
oap:
extends:
file: ../../../script/docker-compose/base-compose.yml
service: oap
environment:
SW_STORAGE: influxdb
SW_CORE_DATA_KEEPER_EXECUTE_PERIOD: 1
SW_CORE_METRICS_DATA_TTL: 7
depends_on:
influxdb:
condition: service_healthy
ports:
- 12800
sender:
image: "adoptopenjdk/openjdk8:alpine-jre"
volumes:
- ./../../../java-test-service/e2e-mock-sender/target/e2e-mock-sender-2.0.0.jar:/e2e-mock-sender-2.0.0.jar
command: [ "java", "-jar", "/e2e-mock-sender-2.0.0.jar" ]
environment:
OAP_HOST: oap
OAP_GRPC_PORT: 11800
networks:
- e2e
ports:
- 9093
healthcheck:
test: ["CMD", "sh", "-c", "nc -nz 127.0.0.1 9093"]
interval: 5s
timeout: 60s
retries: 120
depends_on:
oap:
condition: service_healthy
networks:
e2e:
# 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-v2/script/prepare/setup-e2e-shell/install.sh yq
- name: install swctl
command: bash test/e2e-v2/script/prepare/setup-e2e-shell/install.sh swctl
- name: install etcdctl
command: bash test/e2e-v2/script/prepare/setup-e2e-shell/install.sh etcdctl
verify:
retry:
count: 30
interval: 3s
cases:
- includes:
- ../ttl-cases.yaml
# 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:
postgres:
image: postgres:13
networks:
- e2e
expose:
- 5432
environment:
- POSTGRES_PASSWORD=123456
- POSTGRES_DB=skywalking
healthcheck:
test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/5432"]
interval: 5s
timeout: 60s
retries: 120
oap:
extends:
file: ../../../script/docker-compose/base-compose.yml
service: oap
environment:
SW_STORAGE: postgresql
SW_CORE_DATA_KEEPER_EXECUTE_PERIOD: 1
SW_CORE_METRICS_DATA_TTL: 7
SW_JDBC_URL: "jdbc:postgresql://postgres:5432/skywalking"
depends_on:
postgres:
condition: service_healthy
ports:
- 12800
sender:
image: "adoptopenjdk/openjdk8:alpine-jre"
volumes:
- ./../../../java-test-service/e2e-mock-sender/target/e2e-mock-sender-2.0.0.jar:/e2e-mock-sender-2.0.0.jar
command: [ "java", "-jar", "/e2e-mock-sender-2.0.0.jar" ]
environment:
OAP_HOST: oap
OAP_GRPC_PORT: 11800
networks:
- e2e
ports:
- 9093
healthcheck:
test: ["CMD", "sh", "-c", "nc -nz 127.0.0.1 9093"]
interval: 5s
timeout: 60s
retries: 120
depends_on:
oap:
condition: service_healthy
networks:
e2e:
# 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-v2/script/prepare/setup-e2e-shell/install.sh yq
- name: install swctl
command: bash test/e2e-v2/script/prepare/setup-e2e-shell/install.sh swctl
- name: install etcdctl
command: bash test/e2e-v2/script/prepare/setup-e2e-shell/install.sh etcdctl
verify:
retry:
count: 30
interval: 3s
cases:
- includes:
- ../ttl-cases.yaml
# 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:
tidb:
image: pingcap/tidb:v4.0.12
expose:
- 4000
volumes:
- ./tidbconfig/tidb.toml:/tidb.toml:ro
restart: on-failure
healthcheck:
test: ["CMD", "sh", "-c", "nc -zn 127.0.0.1 4000"]
interval: 5s
timeout: 60s
retries: 120
networks:
- e2e
oap:
extends:
file: ../../../script/docker-compose/base-compose.yml
service: oap
environment:
SW_STORAGE: tidb
SW_CORE_DATA_KEEPER_EXECUTE_PERIOD: 1
SW_CORE_METRICS_DATA_TTL: 7
SW_JDBC_URL: "jdbc:mysql://tidb:4000/test"
SW_DATA_SOURCE_PASSWORD: ""
entrypoint: ['sh', '-c', 'apk add --no-cache bash && /download-mysql.sh && /skywalking/docker-entrypoint.sh']
depends_on:
tidb:
condition: service_healthy
ports:
- 12800
sender:
image: "adoptopenjdk/openjdk8:alpine-jre"
volumes:
- ./../../../java-test-service/e2e-mock-sender/target/e2e-mock-sender-2.0.0.jar:/e2e-mock-sender-2.0.0.jar
command: [ "java", "-jar", "/e2e-mock-sender-2.0.0.jar" ]
environment:
OAP_HOST: oap
OAP_GRPC_PORT: 11800
networks:
- e2e
ports:
- 9093
healthcheck:
test: ["CMD", "sh", "-c", "nc -nz 127.0.0.1 9093"]
interval: 5s
timeout: 60s
retries: 120
depends_on:
oap:
condition: service_healthy
networks:
e2e:
# 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-v2/script/prepare/setup-e2e-shell/install.sh yq
- name: install swctl
command: bash test/e2e-v2/script/prepare/setup-e2e-shell/install.sh swctl
- name: install etcdctl
command: bash test/e2e-v2/script/prepare/setup-e2e-shell/install.sh etcdctl
verify:
retry:
count: 30
interval: 3s
cases:
- includes:
- ../ttl-cases.yaml
# 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.
cases:
# send metrics and ensure metrics exist, SW_CORE_METRICS_DATA_TTL=7
- query: |
curl -s -XPOST http://${sender_host}:${sender_9093}/sendMetrics4TTL/7 > /dev/null;
sleep 10;
swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=service_resp_time --service-name=e2e-test-dest-service --start="-193h" --end="-191h" |yq e 'to_entries' -
expected: expected/metrics-has-value.yml
# verify metrics has been deleted
- query: |
sleep 30;
swctl --display yaml --base-url=http://${oap_host}:${oap_12800}/graphql metrics linear --name=service_resp_time --service-id=ZTJlLXRlc3QtZGVzdC1zZXJ2aWNl.1 --start="-193h" --end="-191h" |yq e 'to_entries' -
expected: expected/metrics-has-no-value.yml
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>apache-skywalking-e2e</artifactId>
<groupId>org.apache.skywalking</groupId>
<version>2.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<artifactId>e2e-mock-sender</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>e2e-protocol</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<configuration>
<executable>true</executable>
<addResources>true</addResources>
<excludeDevtools>true</excludeDevtools>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
/*
* 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.
*
*/
package org.apache.skywalking.e2e;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Data
@Configuration
@ConfigurationProperties("e2e")
public class E2EConfiguration {
private String oapHost;
private String oapGrpcPort;
}
/*
* 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.
*
*/
package org.apache.skywalking.e2e;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@ComponentScan({"org.apache.skywalking"})
public class ServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ServiceApplication.class, args);
}
}
/*
* 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.
*
*/
package org.apache.skywalking.e2e.controller;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequiredArgsConstructor
public class HealthController {
@GetMapping("/health")
@SuppressWarnings("EmptyMethod")
@ResponseStatus(code = HttpStatus.OK)
public void hello() {
}
}
/*
* 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.
*
*/
package org.apache.skywalking.e2e.controller;
import io.grpc.ManagedChannel;
import io.grpc.internal.DnsNameResolverProvider;
import io.grpc.netty.NettyChannelBuilder;
import io.grpc.stub.StreamObserver;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.concurrent.CountDownLatch;
import org.apache.skywalking.apm.network.common.v3.DetectPoint;
import org.apache.skywalking.apm.network.servicemesh.v3.MeshProbeDownstream;
import org.apache.skywalking.apm.network.servicemesh.v3.Protocol;
import org.apache.skywalking.apm.network.servicemesh.v3.ServiceMeshMetric;
import org.apache.skywalking.apm.network.servicemesh.v3.ServiceMeshMetricServiceGrpc;
import org.apache.skywalking.e2e.E2EConfiguration;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class ServiceMeshMetricSenderController {
private static final int MAX_INBOUND_MESSAGE_SIZE = 1024 * 1024 * 50;
private static final boolean SUCCESS = true;
private final ServiceMeshMetricServiceGrpc.ServiceMeshMetricServiceStub grpcStub;
public ServiceMeshMetricSenderController(final E2EConfiguration configuration) {
final ManagedChannel channel = NettyChannelBuilder.forAddress(
configuration.getOapHost(), Integer.parseInt(configuration.getOapGrpcPort()))
.nameResolverFactory(new DnsNameResolverProvider())
.maxInboundMessageSize(MAX_INBOUND_MESSAGE_SIZE)
.usePlaintext()
.build();
grpcStub = ServiceMeshMetricServiceGrpc.newStub(channel);
}
@PostMapping("/sendMetrics4TTL/{metricsTTL}")
public String sendMetrics4TTL(@PathVariable("metricsTTL") int metricsTTL) throws Exception {
final ServiceMeshMetric.Builder builder =
ServiceMeshMetric.newBuilder()
.setSourceServiceName("e2e-test-source-service")
.setSourceServiceInstance("e2e-test-source-service-instance")
.setDestServiceName("e2e-test-dest-service")
.setDestServiceInstance("e2e-test-dest-service-instance")
.setEndpoint("e2e/test")
.setLatency(2000)
.setResponseCode(200)
.setStatus(SUCCESS)
.setProtocol(Protocol.HTTP)
.setDetectPoint(DetectPoint.server);
final LocalDateTime now = LocalDateTime.now(ZoneOffset.UTC);
final LocalDateTime startTime = now.minusDays(metricsTTL + 1);
final LocalDateTime endTime = startTime.plusMinutes(1);
sendMetrics(builder
.setStartTime(startTime.toEpochSecond(ZoneOffset.UTC) * 1000)
.setEndTime(endTime.toEpochSecond(ZoneOffset.UTC) * 1000).build());
return "Metrics send success!";
}
void sendMetrics(final ServiceMeshMetric metrics) throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
StreamObserver<ServiceMeshMetric> collect = grpcStub.collect(new StreamObserver<MeshProbeDownstream>() {
@Override
public void onNext(final MeshProbeDownstream meshProbeDownstream) {
}
@Override
public void onError(final Throwable throwable) {
throwable.printStackTrace();
latch.countDown();
}
@Override
public void onCompleted() {
latch.countDown();
}
});
collect.onNext(metrics);
collect.onCompleted();
latch.await();
}
}
# 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.
server:
port: 9093
spring:
main:
banner-mode: 'off'
e2e:
oap-host: ${OAP_HOST:127.0.0.1}
oap-grpc-port: ${OAP_GRPC-PORT:11800}
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>apache-skywalking-e2e</artifactId>
<groupId>org.apache.skywalking</groupId>
<version>2.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>e2e-protocol</artifactId>
<properties>
<grpc.version>1.14.0</grpc.version>
<os-maven-plugin.version>1.5.0.Final</os-maven-plugin.version>
<protobuf-maven-plugin.version>0.5.0</protobuf-maven-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>${grpc.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>${os-maven-plugin.version}</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>detect</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>${protobuf-maven-plugin.version}</version>
<configuration>
<!--
The version of protoc must match protobuf-java. If you don't depend on
protobuf-java directly, you will be transitively depending on the
protobuf-java version that grpc depends on.
-->
<protocArtifact>com.google.protobuf:protoc:3.3.0:exe:${os.detected.classifier}
</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.8.0:exe:${os.detected.classifier}
</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Subproject commit 21492e496b797567d0e127f4510509baf73e10fd
......@@ -30,6 +30,8 @@
<modules>
<module>e2e-service-provider</module>
<module>e2e-service-consumer</module>
<module>e2e-mock-sender</module>
<module>e2e-protocol</module>
</modules>
<properties>
......
......@@ -23,4 +23,4 @@ SW_AGENT_CLIENT_JS_COMMIT=af0565a67d382b683c1dbd94c379b7080db61449
SW_AGENT_CLIENT_JS_TEST_COMMIT=4f1eb1dcdbde3ec4a38534bf01dded4ab5d2f016
SW_KUBERNETES_COMMIT_SHA=0f3ec68e5a7e1608cec8688716b848ed15e971e5
SW_CTL_COMMIT=48338d3827bddd47f7db320a43978a29c1084e64
SW_CTL_COMMIT=45a5f9807126dc6ea9fe06e17e7aafbe212436d2
......@@ -95,4 +95,4 @@
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
</project>
Subproject commit e626ee04850703c220f64b642d2893fa65572943
Subproject commit 21492e496b797567d0e127f4510509baf73e10fd
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册