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/10/25 18:58:16 UTC

[skywalking] branch master updated: [test/plugin] to check agent register status (#3716)

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

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git


The following commit(s) were added to refs/heads/master by this push:
     new c81e8a0  [test/plugin] to check agent register status (#3716)
c81e8a0 is described below

commit c81e8a04b5e0b2b38d1a7ca90418eed687da3835
Author: Daming <zt...@foxmail.com>
AuthorDate: Sat Oct 26 02:58:08 2019 +0800

    [test/plugin] to check agent register status (#3716)
    
    * check agent register status
    
    * update
    
    * remove healtch-check segment
    
    * update
    
    * fix some expectedData.yml
    
    * remove netty-socketio-scenario from Jenkinsfile
    
    * fix
---
 Jenkinsfile-Agent-Test                               |  8 +-------
 test/plugin/containers/jvm-container/docker/run.sh   | 11 ++++++-----
 .../plugin/containers/tomcat-container/docker/run.sh | 11 +++++++----
 .../skywalking/plugin/test/mockcollector/Main.java   | 20 ++++++++++++++++++++
 .../test/mockcollector/entity/RegistryItem.java      |  9 +++++----
 .../service/MockCLRMetricReportService.java          |  8 ++++++++
 .../service/MockJVMMetricReportService.java          |  8 ++++++++
 .../dubbo-2.5.x-scenario/config/expectedData.yaml    |  2 +-
 .../dubbo-2.7.x-scenario/config/expectedData.yaml    |  2 +-
 .../ehcache-2.x-scenario/config/expectedData.yaml    | 20 +-------------------
 .../config/expectedData.yaml                         | 20 +-------------------
 .../spring-3.0.x-scenario/config/expectedData.yaml   |  2 +-
 .../spring-3.1.x-scenario/config/expectedData.yaml   |  2 +-
 .../spring-4.1.x-scenario/config/expectedData.yaml   |  2 +-
 .../spring-4.3.x-scenario/config/expectedData.yaml   |  2 +-
 .../spring-async-scenario/config/expectedData.yaml   |  2 +-
 16 files changed, 64 insertions(+), 65 deletions(-)

diff --git a/Jenkinsfile-Agent-Test b/Jenkinsfile-Agent-Test
index 69df4c4..cdaa3d5 100755
--- a/Jenkinsfile-Agent-Test
+++ b/Jenkinsfile-Agent-Test
@@ -104,12 +104,6 @@ pipeline {
                                 sh 'bash test/plugin/run.sh --build_id=wl1_${BUILD_ID} spring-async-scenario'
                             }
                         }
-
-                        stage('netty-socketio 1.x (4)') {
-                            steps {
-                                sh 'bash test/plugin/run.sh --build_id=wl1_${BUILD_ID} netty-socketio-scenario'
-                            }
-                        }
                     }
                 }
                 stage('Group2') {
@@ -131,4 +125,4 @@ pipeline {
             deleteDir()
         }
     }
-}
\ No newline at end of file
+}
diff --git a/test/plugin/containers/jvm-container/docker/run.sh b/test/plugin/containers/jvm-container/docker/run.sh
index de7e5fd..d2d5cd9 100644
--- a/test/plugin/containers/jvm-container/docker/run.sh
+++ b/test/plugin/containers/jvm-container/docker/run.sh
@@ -31,10 +31,10 @@ function exitAndClean() {
 function healthCheck() {
     HEALTH_CHECK_URL=$1
     STATUS_CODE="-1"
-
-    for ((i=1; i<=150; i++));
+    TIMES=${TIMES:-150}
+    for ((i=1; i<=${TIMES}; i++));
     do
-        STATUS_CODE="$(curl -Is ${HEALTH_CHECK_URL} | head -n 1)"
+        STATUS_CODE="$(curl --max-time 3 -Is ${HEALTH_CHECK_URL} | head -n 1)"
         if [[ $STATUS_CODE == *"200"* ]]; then
           echo "${HEALTH_CHECK_URL}: ${STATUS_CODE}"
           return 0
@@ -72,14 +72,15 @@ export agent_opts="-javaagent:${SCENARIO_HOME}/agent/skywalking-agent.jar
     -Xms256m -Xmx256m ${agent_opts}"
 exec /var/run/${SCENARIO_NAME}/${SCENARIO_START_SCRIPT} 1>/dev/null &
 
+healthCheck http://localhost:12800/status
 healthCheck ${SCENARIO_HEALTH_CHECK_URL}
 
 echo "To visit entry service"
-curl -s ${SCENARIO_ENTRY_SERVICE}
+curl -s --max-time 3 ${SCENARIO_ENTRY_SERVICE}
 sleep 5
 
 echo "To receive actual data"
-curl -s http://localhost:12800/receiveData > ${SCENARIO_HOME}/data/actualData.yaml
+curl -s --max-time 3 http://localhost:12800/receiveData > ${SCENARIO_HOME}/data/actualData.yaml
 [[ ! -f ${SCENARIO_HOME}/data/actualData.yaml ]] && exitOnError "${SCENARIO_NAME}-${SCENARIO_VERSION}, 'actualData.yaml' Not Found!"
 
 echo "To validate"
diff --git a/test/plugin/containers/tomcat-container/docker/run.sh b/test/plugin/containers/tomcat-container/docker/run.sh
index f4d8b45..c864fc3 100644
--- a/test/plugin/containers/tomcat-container/docker/run.sh
+++ b/test/plugin/containers/tomcat-container/docker/run.sh
@@ -30,9 +30,10 @@ function exitAndClean() {
 function healthCheck() {
     HEALTH_CHECK_URL=$1
 
-    for ((i=1; i<=150; i++));
+    TIMES=${TIMES:-150}
+    for ((i=1; i<=${TIMES}; i++));
     do
-        STATUS_CODE="$(curl -Is ${HEALTH_CHECK_URL} | head -n 1)"
+        STATUS_CODE="$(curl --max-time 3 -Is ${HEALTH_CHECK_URL} | head -n 1)"
         if [[ $STATUS_CODE == *"200"* ]]; then
           echo "${HEALTH_CHECK_URL}: ${STATUS_CODE}"
           return 0
@@ -60,14 +61,16 @@ healthCheck http://localhost:12800/receiveData
 
 echo "To start tomcat"
 /usr/local/tomcat/bin/catalina.sh start 1>/dev/null &
+
+healthCheck http://localhost:12800/status 10
 healthCheck ${SCENARIO_HEALTH_CHECK_URL}
 
 echo "To visit entry service"
-curl -s ${SCENARIO_ENTRY_SERVICE}
+curl -s --max-time 3 ${SCENARIO_ENTRY_SERVICE}
 sleep 5
 
 echo "To receive actual data"
-curl -s http://localhost:12800/receiveData > ${SCENARIO_HOME}/data/actualData.yaml
+curl -s --max-time 3 http://localhost:12800/receiveData > ${SCENARIO_HOME}/data/actualData.yaml
 [[ ! -f ${SCENARIO_HOME}/data/actualData.yaml ]] && exitOnError "${SCENARIO_NAME}-${SCENARIO_VERSION}, 'actualData.yaml' Not Found!"
 
 echo "To validate"
diff --git a/test/plugin/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/Main.java b/test/plugin/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/Main.java
index 4193484..a49b547 100644
--- a/test/plugin/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/Main.java
+++ b/test/plugin/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/Main.java
@@ -19,11 +19,19 @@ package org.apache.skywalking.plugin.test.mockcollector;
 import io.grpc.netty.NettyServerBuilder;
 import io.netty.channel.local.LocalAddress;
 
+import java.io.IOException;
 import java.net.InetSocketAddress;
 
+import org.apache.skywalking.plugin.test.mockcollector.entity.ValidateData;
 import org.apache.skywalking.plugin.test.mockcollector.service.*;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 public class Main {
     public static void main(String[] args) throws Exception {
@@ -47,6 +55,18 @@ public class Main {
         String contextPath = "/";
         ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
         servletContextHandler.setContextPath(contextPath);
+        servletContextHandler.addServlet(new ServletHolder(new HttpServlet() {
+            @Override
+            protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+                if (ValidateData.INSTANCE.getRegistryItem().getApplications().isEmpty()) {
+                    resp.setStatus(500);
+                    return;
+                }
+                resp.setStatus(200);
+                resp.getWriter().write("Success");
+                resp.getWriter().flush();
+            }
+        }), "/status");
         servletContextHandler.addServlet(GrpcAddressHttpService.class, GrpcAddressHttpService.SERVLET_PATH);
         servletContextHandler.addServlet(ReceiveDataService.class, ReceiveDataService.SERVLET_PATH);
         servletContextHandler.addServlet(ClearReceiveDataService.class, ClearReceiveDataService.SERVLET_PATH);
diff --git a/test/plugin/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/RegistryItem.java b/test/plugin/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/RegistryItem.java
index 5dec618..18a0dba 100644
--- a/test/plugin/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/RegistryItem.java
+++ b/test/plugin/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/RegistryItem.java
@@ -22,6 +22,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.skywalking.apm.network.language.agent.SpanType;
 
@@ -44,10 +45,10 @@ public class RegistryItem {
     private final Map<String, Integer> heartBeats;
 
     public RegistryItem() {
-        applications = new HashMap<>();
-        operationNames = new HashMap<>();
-        instanceMapping = new HashMap<>();
-        heartBeats = new HashMap<>();
+        applications = new ConcurrentHashMap<>();
+        operationNames = new ConcurrentHashMap<>();
+        instanceMapping = new ConcurrentHashMap<>();
+        heartBeats = new ConcurrentHashMap<>();
     }
 
     public void registryApplication(Application application) {
diff --git a/test/plugin/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockCLRMetricReportService.java b/test/plugin/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockCLRMetricReportService.java
index 95b57c3..55f5649 100644
--- a/test/plugin/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockCLRMetricReportService.java
+++ b/test/plugin/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockCLRMetricReportService.java
@@ -16,6 +16,9 @@
  */
 package org.apache.skywalking.plugin.test.mockcollector.service;
 
+import io.grpc.stub.StreamObserver;
+import org.apache.skywalking.apm.network.common.Commands;
+import org.apache.skywalking.apm.network.language.agent.v2.CLRMetricCollection;
 import org.apache.skywalking.apm.network.language.agent.v2.CLRMetricReportServiceGrpc;
 
 /**
@@ -24,4 +27,9 @@ import org.apache.skywalking.apm.network.language.agent.v2.CLRMetricReportServic
  **/
 public class MockCLRMetricReportService extends CLRMetricReportServiceGrpc.CLRMetricReportServiceImplBase {
 
+    @Override
+    public void collect(CLRMetricCollection request, StreamObserver<Commands> responseObserver) {
+        responseObserver.onNext(Commands.newBuilder().build());
+        responseObserver.onCompleted();
+    }
 }
diff --git a/test/plugin/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockJVMMetricReportService.java b/test/plugin/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockJVMMetricReportService.java
index dbc8826..64f6545 100644
--- a/test/plugin/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockJVMMetricReportService.java
+++ b/test/plugin/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockJVMMetricReportService.java
@@ -16,6 +16,9 @@
  */
 package org.apache.skywalking.plugin.test.mockcollector.service;
 
+import io.grpc.stub.StreamObserver;
+import org.apache.skywalking.apm.network.common.Commands;
+import org.apache.skywalking.apm.network.language.agent.v2.JVMMetricCollection;
 import org.apache.skywalking.apm.network.language.agent.v2.JVMMetricReportServiceGrpc;
 
 /**
@@ -24,4 +27,9 @@ import org.apache.skywalking.apm.network.language.agent.v2.JVMMetricReportServic
  **/
 public class MockJVMMetricReportService extends JVMMetricReportServiceGrpc.JVMMetricReportServiceImplBase {
 
+    @Override
+    public void collect(JVMMetricCollection request, StreamObserver<Commands> responseObserver) {
+        responseObserver.onNext(Commands.newBuilder().build());
+        responseObserver.onCompleted();
+    }
 }
diff --git a/test/plugin/scenarios/dubbo-2.5.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/dubbo-2.5.x-scenario/config/expectedData.yaml
index 1969a58..763c772 100644
--- a/test/plugin/scenarios/dubbo-2.5.x-scenario/config/expectedData.yaml
+++ b/test/plugin/scenarios/dubbo-2.5.x-scenario/config/expectedData.yaml
@@ -23,7 +23,7 @@ registryItems:
   heartbeat: []
 segmentItems:
   - applicationCode: dubbo-2.5.x-scenario
-    segmentSize: 3
+    segmentSize: ge 3
     segments:
       - segmentId: not null
         spans:
diff --git a/test/plugin/scenarios/dubbo-2.7.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/dubbo-2.7.x-scenario/config/expectedData.yaml
index 747f027..bd29f26 100644
--- a/test/plugin/scenarios/dubbo-2.7.x-scenario/config/expectedData.yaml
+++ b/test/plugin/scenarios/dubbo-2.7.x-scenario/config/expectedData.yaml
@@ -25,7 +25,7 @@ registryItems:
   heartbeat: []
 segmentItems:
   - applicationCode: dubbo-2.7.x-scenario
-    segmentSize: 3
+    segmentSize: ge 3
     segments:
       - segmentId: not null
         spans:
diff --git a/test/plugin/scenarios/ehcache-2.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/ehcache-2.x-scenario/config/expectedData.yaml
index 0562b9a..489f1f9 100644
--- a/test/plugin/scenarios/ehcache-2.x-scenario/config/expectedData.yaml
+++ b/test/plugin/scenarios/ehcache-2.x-scenario/config/expectedData.yaml
@@ -23,28 +23,10 @@ registryItems:
   heartbeat: []
 segmentItems:
   - applicationCode: ehcache-2.x-scenario
-    segmentSize: 2
+    segmentSize: ge 2
     segments:
       - segmentId: not null
         spans:
-          - operationName: /ehcache-2.x-scenario/healthCheck
-            operationId: 0
-            parentSpanId: -1
-            spanId: 0
-            spanLayer: Http
-            startTime: nq 0
-            endTime: nq 0
-            componentId: 1
-            componentName: ''
-            isError: false
-            spanType: Entry
-            peer: ''
-            peerId: 0
-            tags:
-              - {key: url, value: 'http://localhost:8080/ehcache-2.x-scenario/healthCheck'}
-              - {key: http.method, value: HEAD}
-      - segmentId: not null
-        spans:
           - operationName: Ehcache/put/testCache
             operationId: 0
             parentSpanId: 0
diff --git a/test/plugin/scenarios/httpclient-4.3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/httpclient-4.3.x-scenario/config/expectedData.yaml
index 74d170e..6ffec1b 100644
--- a/test/plugin/scenarios/httpclient-4.3.x-scenario/config/expectedData.yaml
+++ b/test/plugin/scenarios/httpclient-4.3.x-scenario/config/expectedData.yaml
@@ -25,28 +25,10 @@ registryItems:
   heartbeat: []
 segmentItems:
   - applicationCode: httpclient-4.3.x-scenario
-    segmentSize: 3
+    segmentSize: ge 3
     segments:
       - segmentId: not null
         spans:
-          - operationName: /httpclient-4.3.x-scenario/healthCheck
-            operationId: 0
-            parentSpanId: -1
-            spanId: 0
-            spanLayer: Http
-            startTime: nq 0
-            endTime: nq 0
-            componentId: 1
-            componentName: ''
-            isError: false
-            spanType: Entry
-            peer: ''
-            peerId: 0
-            tags:
-              - {key: url, value: 'http://localhost:8080/httpclient-4.3.x-scenario/healthCheck'}
-              - {key: http.method, value: HEAD}
-      - segmentId: not null
-        spans:
           - operationName: /httpclient-4.3.x-scenario/case/context-propagate
             operationId: 0
             parentSpanId: -1
diff --git a/test/plugin/scenarios/spring-3.0.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-3.0.x-scenario/config/expectedData.yaml
index 22ed29b..6390235 100644
--- a/test/plugin/scenarios/spring-3.0.x-scenario/config/expectedData.yaml
+++ b/test/plugin/scenarios/spring-3.0.x-scenario/config/expectedData.yaml
@@ -23,7 +23,7 @@ registryItems:
   heartbeat: []
 segmentItems:
   - applicationCode: spring-3.0.x-scenario
-    segmentSize: 2
+    segmentSize: ge 2
     segments:
       - segmentId: not null
         spans:
diff --git a/test/plugin/scenarios/spring-3.1.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-3.1.x-scenario/config/expectedData.yaml
index fdba079..b944492 100644
--- a/test/plugin/scenarios/spring-3.1.x-scenario/config/expectedData.yaml
+++ b/test/plugin/scenarios/spring-3.1.x-scenario/config/expectedData.yaml
@@ -26,7 +26,7 @@ registryItems:
   heartbeat: []
 segmentItems:
   - applicationCode: spring-3.1.x-scenario
-    segmentSize: 7
+    segmentSize: ge 7
     segments:
       - segmentId: not null
         spans:
diff --git a/test/plugin/scenarios/spring-4.1.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-4.1.x-scenario/config/expectedData.yaml
index b73b99e..33757ee 100644
--- a/test/plugin/scenarios/spring-4.1.x-scenario/config/expectedData.yaml
+++ b/test/plugin/scenarios/spring-4.1.x-scenario/config/expectedData.yaml
@@ -26,7 +26,7 @@ registryItems:
   heartbeat: []
 segmentItems:
   - applicationCode: spring-4.1.x-scenario
-    segmentSize: 7
+    segmentSize: ge 7
     segments:
       - segmentId: not null
         spans:
diff --git a/test/plugin/scenarios/spring-4.3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-4.3.x-scenario/config/expectedData.yaml
index dfe78d4..73c8f7a 100644
--- a/test/plugin/scenarios/spring-4.3.x-scenario/config/expectedData.yaml
+++ b/test/plugin/scenarios/spring-4.3.x-scenario/config/expectedData.yaml
@@ -27,7 +27,7 @@ registryItems:
   heartbeat: []
 segmentItems:
   - applicationCode: spring-4.3.x-scenario
-    segmentSize: 8
+    segmentSize: ge 8
     segments:
       - segmentId: not null
         spans:
diff --git a/test/plugin/scenarios/spring-async-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-async-scenario/config/expectedData.yaml
index f546ea0..4bb71b0 100644
--- a/test/plugin/scenarios/spring-async-scenario/config/expectedData.yaml
+++ b/test/plugin/scenarios/spring-async-scenario/config/expectedData.yaml
@@ -24,7 +24,7 @@ registryItems:
   heartbeat: []
 segmentItems:
   - applicationCode: spring-async-scenario
-    segmentSize: 4
+    segmentSize: ge 4
     segments:
       - segmentId: not null
         spans: