提交 c81e8a04 编写于 作者: D Daming 提交者: wu-sheng

[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
上级 f8f31f40
......@@ -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
}
......@@ -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"
......
......@@ -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"
......
......@@ -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);
......
......@@ -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) {
......
......@@ -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();
}
}
......@@ -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();
}
}
......@@ -23,7 +23,7 @@ registryItems:
heartbeat: []
segmentItems:
- applicationCode: dubbo-2.5.x-scenario
segmentSize: 3
segmentSize: ge 3
segments:
- segmentId: not null
spans:
......
......@@ -25,7 +25,7 @@ registryItems:
heartbeat: []
segmentItems:
- applicationCode: dubbo-2.7.x-scenario
segmentSize: 3
segmentSize: ge 3
segments:
- segmentId: not null
spans:
......
......@@ -23,26 +23,8 @@ 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
......
......@@ -25,26 +25,8 @@ 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
......
......@@ -23,7 +23,7 @@ registryItems:
heartbeat: []
segmentItems:
- applicationCode: spring-3.0.x-scenario
segmentSize: 2
segmentSize: ge 2
segments:
- segmentId: not null
spans:
......
......@@ -26,7 +26,7 @@ registryItems:
heartbeat: []
segmentItems:
- applicationCode: spring-3.1.x-scenario
segmentSize: 7
segmentSize: ge 7
segments:
- segmentId: not null
spans:
......
......@@ -26,7 +26,7 @@ registryItems:
heartbeat: []
segmentItems:
- applicationCode: spring-4.1.x-scenario
segmentSize: 7
segmentSize: ge 7
segments:
- segmentId: not null
spans:
......
......@@ -27,7 +27,7 @@ registryItems:
heartbeat: []
segmentItems:
- applicationCode: spring-4.3.x-scenario
segmentSize: 8
segmentSize: ge 8
segments:
- segmentId: not null
spans:
......
......@@ -24,7 +24,7 @@ registryItems:
heartbeat: []
segmentItems:
- applicationCode: spring-async-scenario
segmentSize: 4
segmentSize: ge 4
segments:
- segmentId: not null
spans:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册