You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ke...@apache.org on 2020/12/05 16:13:10 UTC
[skywalking] 01/01: test: extract so11y test and add logs
This is an automated email from the ASF dual-hosted git repository.
kezhenxu94 pushed a commit to branch e2e/ref
in repository https://gitbox.apache.org/repos/asf/skywalking.git
commit f94e8986614c41e8b1abcd8570d7eee9cdf17c90
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Sun Dec 6 00:12:34 2020 +0800
test: extract so11y test and add logs
---
.github/workflows/e2e.so11y.yaml | 61 ++++++++
docker/oap/log4j2.xml | 1 +
.../provider/PrometheusFetcherProvider.java | 3 +
.../docker/simple/so11y/docker-compose.yml | 36 +++++
.../java/org/apache/skywalking/e2e/ClusterE2E.java | 24 ++--
.../java/org/apache/skywalking/e2e/SO11yE2E.java | 156 +++++++++++++++++++++
.../apache/skywalking/e2e/simple/SimpleE2E.java | 61 +-------
7 files changed, 272 insertions(+), 70 deletions(-)
diff --git a/.github/workflows/e2e.so11y.yaml b/.github/workflows/e2e.so11y.yaml
new file mode 100644
index 0000000..da3f86f
--- /dev/null
+++ b/.github/workflows/e2e.so11y.yaml
@@ -0,0 +1,61 @@
+# 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.
+
+name: E2E
+
+on:
+ pull_request:
+ paths:
+ - '**'
+ - '!**.md'
+ push:
+ branches:
+ - master
+
+env:
+ SKIP_TEST: true
+ SW_AGENT_JDK_VERSION: 8
+ CODECOV_TOKEN: d2065307-8f01-4637-9715-2781ef096db7
+
+jobs:
+ SelfObservability:
+ name: SelfObservability
+ runs-on: ubuntu-latest
+ timeout-minutes: 90
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ submodules: true
+ - name: Cache local Maven repository
+ uses: actions/cache@v2
+ with:
+ path: ~/.m2/repository
+ key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
+ restore-keys: |
+ ${{ runner.os }}-maven-
+ - name: Compile and Build
+ run: make docker
+ - name: Copy dist package
+ run: cp -R dist test/e2e/
+ - name: ${{ matrix.case }}
+ run: ./mvnw --batch-mode -f test/e2e/pom.xml -am -DfailIfNoTests=false verify -Dit.test=org.apache.skywalking.e2e.SO11yE2E
+ - name: Report Coverage
+ run: bash -x tools/coverage/report.sh
+ - uses: actions/upload-artifact@v1
+ if: failure()
+ with:
+ name: logs
+ path: logs
diff --git a/docker/oap/log4j2.xml b/docker/oap/log4j2.xml
index 28994ea..5dd32af 100644
--- a/docker/oap/log4j2.xml
+++ b/docker/oap/log4j2.xml
@@ -29,6 +29,7 @@
<logger name="org.elasticsearch.common.network.IfConfig" level="INFO"/>
<logger name="io.grpc.netty" level="INFO"/>
<logger name="org.apache.skywalking.oap.server.receiver.istio.telemetry" level="DEBUG"/>
+ <logger name="org.apache.skywalking.oap.server.fetcher.prometheus" level="DEBUG"/>
<logger name="org.apache.skywalking.oap.server.receiver.envoy.als" level="DEBUG"/>
<Root level="INFO">
<AppenderRef ref="Console"/>
diff --git a/oap-server/server-fetcher-plugin/prometheus-fetcher-plugin/src/main/java/org/apache/skywalking/oap/server/fetcher/prometheus/provider/PrometheusFetcherProvider.java b/oap-server/server-fetcher-plugin/prometheus-fetcher-plugin/src/main/java/org/apache/skywalking/oap/server/fetcher/prometheus/provider/PrometheusFetcherProvider.java
index ff9025c..3536203 100644
--- a/oap-server/server-fetcher-plugin/prometheus-fetcher-plugin/src/main/java/org/apache/skywalking/oap/server/fetcher/prometheus/provider/PrometheusFetcherProvider.java
+++ b/oap-server/server-fetcher-plugin/prometheus-fetcher-plugin/src/main/java/org/apache/skywalking/oap/server/fetcher/prometheus/provider/PrometheusFetcherProvider.java
@@ -134,6 +134,9 @@ public class PrometheusFetcherProvider extends ModuleProvider {
result.addAll(mf.getMetrics());
}
}
+ if (log.isDebugEnabled()) {
+ log.debug("Fetch metrics from prometheus: {}", result);
+ }
return result;
}))
.flatMap(tryIt -> MetricConvert.log(tryIt, "Load metric"))
diff --git a/test/e2e/e2e-test/docker/simple/so11y/docker-compose.yml b/test/e2e/e2e-test/docker/simple/so11y/docker-compose.yml
new file mode 100644
index 0000000..9860146
--- /dev/null
+++ b/test/e2e/e2e-test/docker/simple/so11y/docker-compose.yml
@@ -0,0 +1,36 @@
+# 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:
+ oap:
+ environment:
+ SW_PROMETHEUS_FETCHER: "default"
+ SW_TELEMETRY: prometheus
+ extends:
+ file: ../../base-compose.yml
+ service: oap
+
+ ui:
+ extends:
+ file: ../../base-compose.yml
+ service: ui
+ depends_on:
+ oap:
+ condition: service_healthy
+
+networks:
+ e2e:
diff --git a/test/e2e/e2e-test/src/test/java/org/apache/skywalking/e2e/ClusterE2E.java b/test/e2e/e2e-test/src/test/java/org/apache/skywalking/e2e/ClusterE2E.java
index e365860..1a949fe 100755
--- a/test/e2e/e2e-test/src/test/java/org/apache/skywalking/e2e/ClusterE2E.java
+++ b/test/e2e/e2e-test/src/test/java/org/apache/skywalking/e2e/ClusterE2E.java
@@ -19,6 +19,7 @@
package org.apache.skywalking.e2e;
import java.util.List;
+import java.util.TimeZone;
import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.e2e.annotation.ContainerHostAndPort;
import org.apache.skywalking.e2e.annotation.DockerCompose;
@@ -67,29 +68,30 @@ import static org.apache.skywalking.e2e.utils.Yamls.load;
import static org.assertj.core.api.Assertions.fail;
@Slf4j
-@SkyWalkingE2E
+// @SkyWalkingE2E
public class ClusterE2E extends SkyWalkingTestAdapter {
- @SuppressWarnings("unused")
- @DockerCompose({
- "docker/cluster/docker-compose.yml",
- "docker/cluster/docker-compose.${SW_COORDINATOR}.yml",
- "docker/cluster/docker-compose.${SW_COORDINATOR}.${SW_STORAGE}.yml",
- })
- protected DockerComposeContainer<?> justForSideEffects;
+ // @SuppressWarnings("unused")
+ // @DockerCompose({
+ // "docker/cluster/docker-compose.yml",
+ // "docker/cluster/docker-compose.${SW_COORDINATOR}.yml",
+ // "docker/cluster/docker-compose.${SW_COORDINATOR}.${SW_STORAGE}.yml",
+ // })
+ // protected DockerComposeContainer<?> justForSideEffects;
@SuppressWarnings("unused")
- @ContainerHostAndPort(name = "ui", port = 8080)
- private HostAndPort swWebappHostPort;
+ // @ContainerHostAndPort(name = "ui", port = 8080)
+ private HostAndPort swWebappHostPort = HostAndPort.builder().host("localhost").port(12800).build();
@SuppressWarnings("unused")
@ContainerHostAndPort(name = "consumer", port = 9092)
- private HostAndPort serviceHostPort;
+ private HostAndPort serviceHostPort = HostAndPort.builder().host("localhost").port(8989).build();
private final String providerName = "e2e-service-provider";
private final String consumerName = "e2e-service-consumer";
@BeforeAll
public void setUp() throws Exception {
+ TimeZone.setDefault(xxxxxxxxxxxxxx);
queryClient(swWebappHostPort);
trafficController(serviceHostPort, "/users");
}
diff --git a/test/e2e/e2e-test/src/test/java/org/apache/skywalking/e2e/SO11yE2E.java b/test/e2e/e2e-test/src/test/java/org/apache/skywalking/e2e/SO11yE2E.java
new file mode 100644
index 0000000..a680d4c
--- /dev/null
+++ b/test/e2e/e2e-test/src/test/java/org/apache/skywalking/e2e/SO11yE2E.java
@@ -0,0 +1,156 @@
+/*
+ * 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 java.util.List;
+import java.util.stream.Collectors;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.skywalking.e2e.annotation.ContainerHostAndPort;
+import org.apache.skywalking.e2e.annotation.DockerCompose;
+import org.apache.skywalking.e2e.base.SkyWalkingE2E;
+import org.apache.skywalking.e2e.base.SkyWalkingTestAdapter;
+import org.apache.skywalking.e2e.common.HostAndPort;
+import org.apache.skywalking.e2e.metrics.AtLeastOneOfMetricsMatcher;
+import org.apache.skywalking.e2e.metrics.Metrics;
+import org.apache.skywalking.e2e.metrics.MetricsValueMatcher;
+import org.apache.skywalking.e2e.metrics.ReadMetrics;
+import org.apache.skywalking.e2e.metrics.ReadMetricsQuery;
+import org.apache.skywalking.e2e.retryable.RetryableTest;
+import org.apache.skywalking.e2e.service.Service;
+import org.apache.skywalking.e2e.service.ServicesMatcher;
+import org.apache.skywalking.e2e.service.ServicesQuery;
+import org.apache.skywalking.e2e.service.instance.Instance;
+import org.apache.skywalking.e2e.service.instance.Instances;
+import org.apache.skywalking.e2e.service.instance.InstancesMatcher;
+import org.apache.skywalking.e2e.service.instance.InstancesQuery;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.testcontainers.containers.DockerComposeContainer;
+
+import static org.apache.skywalking.e2e.metrics.MetricsQuery.ALL_SO11Y_LABELED_METRICS;
+import static org.apache.skywalking.e2e.metrics.MetricsQuery.ALL_SO11Y_LINER_METRICS;
+import static org.apache.skywalking.e2e.utils.Times.now;
+import static org.apache.skywalking.e2e.utils.Yamls.load;
+
+/**
+ * A test case for simple functionality verification
+ *
+ * The components are typically:
+ *
+ * - an single agent, (provider), generating traffic data
+ *
+ * - an OAP node, (oap)
+ *
+ * - a webapp, (ui) for querying
+ *
+ * The verifications are:
+ *
+ * - services
+ *
+ * - services metrics
+ *
+ * - services relations
+ *
+ * - endpoints
+ *
+ * - endpoints metrics
+ *
+ * - instances
+ *
+ * - instance metrics
+ *
+ * - topology
+ *
+ * - traces
+ *
+ * if your case needs the same aforementioned verifications, consider simply provide a docker-compose.yml with the specific orchestration and reuse these codes.
+ */
+@Slf4j
+@SkyWalkingE2E
+public class SO11yE2E extends SkyWalkingTestAdapter {
+ @SuppressWarnings("unused")
+ @DockerCompose("docker/simple/so11y/docker-compose.yml")
+ protected DockerComposeContainer<?> justForSideEffects;
+
+ @SuppressWarnings("unused")
+ @ContainerHostAndPort(name = "ui", port = 8080)
+ protected HostAndPort swWebappHostPort;
+
+ @BeforeAll
+ void setUp() {
+ queryClient(swWebappHostPort);
+ }
+
+ @AfterAll
+ public void tearDown() {
+ trafficController.stop();
+ }
+
+ @RetryableTest
+ void so11y() throws Exception {
+ List<Service> services = graphql.services(new ServicesQuery().start(startTime).end(now()));
+
+ services = services.stream().filter(s -> s.getLabel().equals("oap::oap-server")).collect(Collectors.toList());
+ LOGGER.info("services: {}", services);
+ load("expected/simple/so11y-services.yml").as(ServicesMatcher.class).verify(services);
+ for (final Service service : services) {
+ final Instances instances = graphql.instances(
+ new InstancesQuery().serviceId(service.getKey()).start(startTime).end(now())
+ );
+
+ LOGGER.info("instances: {}", instances);
+
+ load("expected/simple/so11y-instances.yml").as(InstancesMatcher.class).verify(instances);
+ for (Instance instance : instances.getInstances()) {
+ for (String metricsName : ALL_SO11Y_LINER_METRICS) {
+ LOGGER.info("verifying service instance response time: {}", instance);
+ final ReadMetrics instanceMetrics = graphql.readMetrics(
+ new ReadMetricsQuery().stepByMinute().metricsName(metricsName)
+ .serviceName(service.getLabel()).instanceName(instance.getLabel())
+ );
+
+ LOGGER.info("{}: {}", metricsName, instanceMetrics);
+ final AtLeastOneOfMetricsMatcher instanceRespTimeMatcher = new AtLeastOneOfMetricsMatcher();
+ final MetricsValueMatcher greaterThanZero = new MetricsValueMatcher();
+ greaterThanZero.setValue("gt 0");
+ instanceRespTimeMatcher.setValue(greaterThanZero);
+ instanceRespTimeMatcher.verify(instanceMetrics.getValues());
+ }
+ for (String metricsName : ALL_SO11Y_LABELED_METRICS) {
+ LOGGER.info("verifying service instance response time: {}", instance);
+ final List<ReadMetrics> instanceMetrics = graphql.readLabeledMetrics(
+ new ReadMetricsQuery().stepByMinute().metricsName(metricsName)
+ .serviceName(service.getLabel()).instanceName(instance.getLabel())
+ );
+
+ LOGGER.info("{}: {}", metricsName, instanceMetrics);
+ Metrics allValues = new Metrics();
+ for (ReadMetrics readMetrics : instanceMetrics) {
+ allValues.getValues().addAll(readMetrics.getValues().getValues());
+ }
+ final AtLeastOneOfMetricsMatcher instanceRespTimeMatcher = new AtLeastOneOfMetricsMatcher();
+ final MetricsValueMatcher greaterThanZero = new MetricsValueMatcher();
+ greaterThanZero.setValue("gt 0");
+ instanceRespTimeMatcher.setValue(greaterThanZero);
+ instanceRespTimeMatcher.verify(allValues);
+ }
+ }
+ }
+ }
+}
diff --git a/test/e2e/e2e-test/src/test/java/org/apache/skywalking/e2e/simple/SimpleE2E.java b/test/e2e/e2e-test/src/test/java/org/apache/skywalking/e2e/simple/SimpleE2E.java
index bc5268b..09ab846 100644
--- a/test/e2e/e2e-test/src/test/java/org/apache/skywalking/e2e/simple/SimpleE2E.java
+++ b/test/e2e/e2e-test/src/test/java/org/apache/skywalking/e2e/simple/SimpleE2E.java
@@ -18,6 +18,8 @@
package org.apache.skywalking.e2e.simple;
+import java.util.List;
+import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.e2e.annotation.ContainerHostAndPort;
import org.apache.skywalking.e2e.annotation.DockerCompose;
@@ -28,8 +30,6 @@ import org.apache.skywalking.e2e.metrics.AtLeastOneOfMetricsMatcher;
import org.apache.skywalking.e2e.metrics.Metrics;
import org.apache.skywalking.e2e.metrics.MetricsQuery;
import org.apache.skywalking.e2e.metrics.MetricsValueMatcher;
-import org.apache.skywalking.e2e.metrics.ReadMetrics;
-import org.apache.skywalking.e2e.metrics.ReadMetricsQuery;
import org.apache.skywalking.e2e.retryable.RetryableTest;
import org.apache.skywalking.e2e.service.Service;
import org.apache.skywalking.e2e.service.ServicesMatcher;
@@ -56,9 +56,6 @@ import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.testcontainers.containers.DockerComposeContainer;
-import java.util.List;
-import java.util.stream.Collectors;
-
import static org.apache.skywalking.e2e.metrics.MetricsMatcher.verifyMetrics;
import static org.apache.skywalking.e2e.metrics.MetricsMatcher.verifyPercentileMetrics;
import static org.apache.skywalking.e2e.metrics.MetricsQuery.ALL_ENDPOINT_METRICS;
@@ -71,8 +68,6 @@ import static org.apache.skywalking.e2e.metrics.MetricsQuery.ALL_SERVICE_METRICS
import static org.apache.skywalking.e2e.metrics.MetricsQuery.ALL_SERVICE_MULTIPLE_LINEAR_METRICS;
import static org.apache.skywalking.e2e.metrics.MetricsQuery.ALL_SERVICE_RELATION_CLIENT_METRICS;
import static org.apache.skywalking.e2e.metrics.MetricsQuery.ALL_SERVICE_RELATION_SERVER_METRICS;
-import static org.apache.skywalking.e2e.metrics.MetricsQuery.ALL_SO11Y_LABELED_METRICS;
-import static org.apache.skywalking.e2e.metrics.MetricsQuery.ALL_SO11Y_LINER_METRICS;
import static org.apache.skywalking.e2e.utils.Times.now;
import static org.apache.skywalking.e2e.utils.Yamls.load;
@@ -199,58 +194,6 @@ public class SimpleE2E extends SkyWalkingTestAdapter {
verifyServiceInstanceRelationMetrics(topology.getCalls());
}
- @RetryableTest
- void so11y() throws Exception {
- List<Service> services = graphql.services(new ServicesQuery().start(startTime).end(now()));
-
- services = services.stream().filter(s -> s.getLabel().equals("oap::oap-server")).collect(Collectors.toList());
- LOGGER.info("services: {}", services);
- load("expected/simple/so11y-services.yml").as(ServicesMatcher.class).verify(services);
- for (final Service service : services) {
- final Instances instances = graphql.instances(
- new InstancesQuery().serviceId(service.getKey()).start(startTime).end(now())
- );
-
- LOGGER.info("instances: {}", instances);
-
- load("expected/simple/so11y-instances.yml").as(InstancesMatcher.class).verify(instances);
- for (Instance instance : instances.getInstances()) {
- for (String metricsName : ALL_SO11Y_LINER_METRICS) {
- LOGGER.info("verifying service instance response time: {}", instance);
- final ReadMetrics instanceMetrics = graphql.readMetrics(
- new ReadMetricsQuery().stepByMinute().metricsName(metricsName)
- .serviceName(service.getLabel()).instanceName(instance.getLabel())
- );
-
- LOGGER.info("{}: {}", metricsName, instanceMetrics);
- final AtLeastOneOfMetricsMatcher instanceRespTimeMatcher = new AtLeastOneOfMetricsMatcher();
- final MetricsValueMatcher greaterThanZero = new MetricsValueMatcher();
- greaterThanZero.setValue("gt 0");
- instanceRespTimeMatcher.setValue(greaterThanZero);
- instanceRespTimeMatcher.verify(instanceMetrics.getValues());
- }
- for (String metricsName : ALL_SO11Y_LABELED_METRICS) {
- LOGGER.info("verifying service instance response time: {}", instance);
- final List<ReadMetrics> instanceMetrics = graphql.readLabeledMetrics(
- new ReadMetricsQuery().stepByMinute().metricsName(metricsName)
- .serviceName(service.getLabel()).instanceName(instance.getLabel())
- );
-
- LOGGER.info("{}: {}", metricsName, instanceMetrics);
- Metrics allValues = new Metrics();
- for (ReadMetrics readMetrics : instanceMetrics) {
- allValues.getValues().addAll(readMetrics.getValues().getValues());
- }
- final AtLeastOneOfMetricsMatcher instanceRespTimeMatcher = new AtLeastOneOfMetricsMatcher();
- final MetricsValueMatcher greaterThanZero = new MetricsValueMatcher();
- greaterThanZero.setValue("gt 0");
- instanceRespTimeMatcher.setValue(greaterThanZero);
- instanceRespTimeMatcher.verify(allValues);
- }
- }
- }
- }
-
private Instances verifyServiceInstances(final Service service) throws Exception {
final Instances instances = graphql.instances(
new InstancesQuery().serviceId(service.getKey()).start(startTime).end(now())