You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2019/04/15 13:43:20 UTC

[incubator-skywalking] branch envoy-access-log updated: Finish tests.

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch envoy-access-log
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git


The following commit(s) were added to refs/heads/envoy-access-log by this push:
     new 0166a61  Finish tests.
0166a61 is described below

commit 0166a610575a350dd24a393adf8a0738032c3b85
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Mon Apr 15 21:43:09 2019 +0800

    Finish tests.
---
 .../envoy/als/K8sALSServiceMeshHTTPAnalysis.java   |  2 +-
 .../receiver/envoy/als/K8sHTTPAnalysisTest.java    | 59 ++++++++++++++
 .../test/resources/envoy-mesh-client-sidecar.msg   | 92 ++++++++++++++++++++++
 3 files changed, 152 insertions(+), 1 deletion(-)

diff --git a/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/als/K8sALSServiceMeshHTTPAnalysis.java b/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/als/K8sALSServiceMeshHTTPAnalysis.java
index 0aff88c..44342e4 100644
--- a/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/als/K8sALSServiceMeshHTTPAnalysis.java
+++ b/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/envoy/als/K8sALSServiceMeshHTTPAnalysis.java
@@ -144,7 +144,7 @@ public class K8sALSServiceMeshHTTPAnalysis implements ALSHTTPAnalysis {
                         .setEndpoint(endpoint).setLatency((int)duration)
                         .setResponseCode(Math.toIntExact(responseCode))
                         .setStatus(status).setProtocol(protocol)
-                        .setDetectPoint(DetectPoint.server)
+                        .setDetectPoint(DetectPoint.client)
                         .build();
 
                     logger.debug("Transformed sidecar->sidecar(server side) inbound mesh metric {}", metric);
diff --git a/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/test/java/org/apache/skywalking/oap/server/receiver/envoy/als/K8sHTTPAnalysisTest.java b/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/test/java/org/apache/skywalking/oap/server/receiver/envoy/als/K8sHTTPAnalysisTest.java
index ff6e016..9df3134 100644
--- a/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/test/java/org/apache/skywalking/oap/server/receiver/envoy/als/K8sHTTPAnalysisTest.java
+++ b/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/test/java/org/apache/skywalking/oap/server/receiver/envoy/als/K8sHTTPAnalysisTest.java
@@ -22,6 +22,7 @@ import com.google.protobuf.util.JsonFormat;
 import io.envoyproxy.envoy.service.accesslog.v2.StreamAccessLogsMessage;
 import java.io.*;
 import java.util.*;
+import org.apache.skywalking.apm.network.common.DetectPoint;
 import org.apache.skywalking.apm.network.servicemesh.ServiceMeshMetric;
 import org.apache.skywalking.oap.server.receiver.envoy.MetricServiceGRPCHandlerTestMain;
 import org.junit.*;
@@ -65,10 +66,66 @@ public class K8sHTTPAnalysisTest {
             ServiceMeshMetric incoming = analysis.metrics.get(0);
             Assert.assertEquals("UNKNOWN", incoming.getSourceServiceName());
             Assert.assertEquals("ingress", incoming.getDestServiceName());
+            Assert.assertEquals(DetectPoint.server, incoming.getDetectPoint());
 
             ServiceMeshMetric outgoing = analysis.metrics.get(1);
             Assert.assertEquals("ingress", outgoing.getSourceServiceName());
             Assert.assertEquals("productpage", outgoing.getDestServiceName());
+            Assert.assertEquals(DetectPoint.client, outgoing.getDetectPoint());
+        }
+    }
+
+    @Test
+    public void testIngress2SidecarMetric() throws IOException {
+        MockK8sAnalysis analysis = new MockK8sAnalysis();
+        try (InputStreamReader isr = new InputStreamReader(getResourceAsStream("envoy-ingress2sidecar.msg"))) {
+            StreamAccessLogsMessage.Builder requestBuilder = StreamAccessLogsMessage.newBuilder();
+            JsonFormat.parser().merge(isr, requestBuilder);
+
+            analysis.analysis(requestBuilder.getIdentifier(), requestBuilder.getHttpLogs().getLogEntry(0), Role.SIDECAR);
+
+            Assert.assertEquals(1, analysis.metrics.size());
+
+            ServiceMeshMetric incoming = analysis.metrics.get(0);
+            Assert.assertEquals("", incoming.getSourceServiceName());
+            Assert.assertEquals("productpage", incoming.getDestServiceName());
+            Assert.assertEquals(DetectPoint.server, incoming.getDetectPoint());
+        }
+    }
+
+    @Test
+    public void testSidecar2SidecarServerMetric() throws IOException {
+        MockK8sAnalysis analysis = new MockK8sAnalysis();
+        try (InputStreamReader isr = new InputStreamReader(getResourceAsStream("envoy-mesh-server-sidecar.msg"))) {
+            StreamAccessLogsMessage.Builder requestBuilder = StreamAccessLogsMessage.newBuilder();
+            JsonFormat.parser().merge(isr, requestBuilder);
+
+            analysis.analysis(requestBuilder.getIdentifier(), requestBuilder.getHttpLogs().getLogEntry(0), Role.SIDECAR);
+
+            Assert.assertEquals(1, analysis.metrics.size());
+
+            ServiceMeshMetric incoming = analysis.metrics.get(0);
+            Assert.assertEquals("productpage", incoming.getSourceServiceName());
+            Assert.assertEquals("review", incoming.getDestServiceName());
+            Assert.assertEquals(DetectPoint.server, incoming.getDetectPoint());
+        }
+    }
+
+    @Test
+    public void testSidecar2SidecarClientMetric() throws IOException {
+        MockK8sAnalysis analysis = new MockK8sAnalysis();
+        try (InputStreamReader isr = new InputStreamReader(getResourceAsStream("envoy-mesh-client-sidecar.msg"))) {
+            StreamAccessLogsMessage.Builder requestBuilder = StreamAccessLogsMessage.newBuilder();
+            JsonFormat.parser().merge(isr, requestBuilder);
+
+            analysis.analysis(requestBuilder.getIdentifier(), requestBuilder.getHttpLogs().getLogEntry(0), Role.SIDECAR);
+
+            Assert.assertEquals(1, analysis.metrics.size());
+
+            ServiceMeshMetric incoming = analysis.metrics.get(0);
+            Assert.assertEquals("productpage", incoming.getSourceServiceName());
+            Assert.assertEquals("detail", incoming.getDestServiceName());
+            Assert.assertEquals(DetectPoint.client, incoming.getDetectPoint());
         }
     }
 
@@ -89,6 +146,8 @@ public class K8sHTTPAnalysisTest {
                     return new ServiceMetaInfo("productpage", "productpage-Inst");
                 case "10.44.6.66":
                     return new ServiceMetaInfo("detail", "detail-Inst");
+                case "10.44.2.55":
+                    return new ServiceMetaInfo("review", "detail-Inst");
             }
             return ServiceMetaInfo.UNKNOWN;
         }
diff --git a/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/test/resources/envoy-mesh-client-sidecar.msg b/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/test/resources/envoy-mesh-client-sidecar.msg
new file mode 100644
index 0000000..1049818
--- /dev/null
+++ b/oap-server/server-receiver-plugin/envoy-metrics-receiver-plugin/src/test/resources/envoy-mesh-client-sidecar.msg
@@ -0,0 +1,92 @@
+# 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.
+
+{
+    "identifier": {
+            "node": {
+                "id": "sidecar~10.44.2.55~productpage-v1-d66dcfdc5-kh6v7.default~default.svc.cluster.local",
+                "cluster": "productpage.default",
+                "metadata": {
+                    "CONFIG_NAMESPACE": "default",
+                    "INTERCEPTION_MODE": "REDIRECT",
+                    "ISTIO_META_INSTANCE_IPS": "10.44.2.55,10.44.2.55,fe80::d8e8:b6ff:fed6:f857",
+                    "ISTIO_PROXY_SHA": "istio-proxy:55c80965eab994e6bfa2227e3942fa89928d0d70",
+                    "ISTIO_PROXY_VERSION": "1.1.0",
+                    "ISTIO_VERSION": "1.0-dev",
+                    "POD_NAME": "productpage-v1-d66dcfdc5-kh6v7",
+                    "app": "productpage",
+                    "istio": "sidecar",
+                    "kubernetes.io/limit-ranger": "LimitRanger plugin set: cpu request for container istio-proxy; cpu request for container reviews",
+                    "pod-template-hash": "822879871",
+                    "version": "v1"
+                },
+                "locality": { },
+                "buildVersion": "55c80965eab994e6bfa2227e3942fa89928d0d70/1.10.0-dev/Clean/RELEASE/BoringSSL"
+            },
+            "logName": "als"
+        },
+        "httpLogs": {
+            "logEntry": [
+                {
+                    "commonProperties": {
+                        "downstreamRemoteAddress": {
+                            "socketAddress": {
+                                "address": "10.44.2.54",
+                                "portValue": 58996
+                            }
+                        },
+                        "downstreamLocalAddress": {
+                            "socketAddress": {
+                                "address": "10.47.247.180",
+                                "portValue": 9080
+                            }
+                        },
+                        "startTime": "2019-04-13T03:59:53.695750999Z",
+                        "timeToLastRxByte": "0.000082339s",
+                        "timeToFirstUpstreamTxByte": "0.002353100s",
+                        "timeToLastUpstreamTxByte": "0.002362295s",
+                        "timeToFirstUpstreamRxByte": "0.010500490s",
+                        "timeToLastUpstreamRxByte": "0.010735195s",
+                        "timeToFirstDownstreamTxByte": "0.010669993s",
+                        "timeToLastDownstreamTxByte": "0.010745496s",
+                        "upstreamRemoteAddress": {
+                            "socketAddress": {
+                                "address": "10.44.6.66",
+                                "portValue": 9080
+                            }
+                        },
+                        "upstreamCluster": "outbound|9080||details.default.svc.cluster.local"
+                    },
+                    "protocolVersion": "HTTP11",
+                    "request": {
+                        "requestMethod": "GET",
+                        "scheme": "http",
+                        "authority": "details:9080",
+                        "path": "/details/0",
+                        "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Safari/605.1.15",
+                        "requestId": "0ac1feff-84ae-4d3a-8b15-890da2b194c5",
+                        "requestHeadersBytes": "869"
+                    },
+                    "response": {
+                        "responseCode": 200,
+                        "responseHeadersBytes": "129",
+                        "responseBodyBytes": "178"
+                    }
+                }
+            ]
+        }
+    }
+}
\ No newline at end of file