You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by da...@apache.org on 2020/02/28 08:14:00 UTC
[skywalking-agent-test-tool] branch master created (now b976595)
This is an automated email from the ASF dual-hosted git repository.
daming pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-agent-test-tool.git.
at b976595 Initial commit
This branch includes the following new commits:
new b976595 Initial commit
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[skywalking-agent-test-tool] 01/01: Initial commit
Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
daming pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-agent-test-tool.git
commit b9765954cb8b6cda4e626b3ee8bf04926c3b0860
Author: daming <zt...@foxmail.com>
AuthorDate: Fri Feb 28 16:13:20 2020 +0800
Initial commit
---
.asf.yaml | 32 ++
.gitignore | 17 +
LICENSE | 210 +++++++++++
NOTICE | 5 +
README.md | 7 +
mock-collector/bin/collector-startup.sh | 35 ++
mock-collector/pom.xml | 152 ++++++++
mock-collector/src/main/assembly/assembly.xml | 57 +++
.../skywalking/plugin/test/mockcollector/Main.java | 80 ++++
.../test/mockcollector/entity/RegistryItem.java | 153 ++++++++
.../entity/RegistryItemSerializer.java | 65 ++++
.../plugin/test/mockcollector/entity/Segment.java | 52 +++
.../test/mockcollector/entity/SegmentItem.java | 43 +++
.../test/mockcollector/entity/SegmentItems.java | 44 +++
.../entity/SegmentItemsSerializer.java | 47 +++
.../plugin/test/mockcollector/entity/Span.java | 193 ++++++++++
.../test/mockcollector/entity/ValidateData.java | 43 +++
.../entity/ValidateDataSerializer.java | 40 ++
.../service/ClearReceiveDataService.java | 47 +++
.../service/GrpcAddressHttpService.java | 51 +++
.../service/MockCLRMetricReportService.java | 35 ++
.../service/MockInstanceDiscoveryService.java | 52 +++
.../service/MockInstancePingService.java | 36 ++
.../service/MockJVMMetricReportService.java | 35 ++
.../service/MockNetworkAddressRegisterService.java | 33 ++
.../mockcollector/service/MockRegisterService.java | 119 ++++++
.../service/MockTraceSegmentService.java | 102 +++++
.../mockcollector/service/ReceiveDataService.java | 53 +++
.../test/mockcollector/service/Sequences.java | 30 ++
.../test/mockcollector/util/ConfigReader.java | 44 +++
mock-collector/src/main/proto/README.md | 5 +
mock-collector/src/main/proto/common/CLR.proto | 46 +++
mock-collector/src/main/proto/common/JVM.proto | 69 ++++
mock-collector/src/main/proto/common/common.proto | 55 +++
.../src/main/proto/common/trace-common.proto | 52 +++
.../main/proto/language-agent-v2/CLRMetric.proto | 36 ++
.../main/proto/language-agent-v2/JVMMetric.proto | 36 ++
.../src/main/proto/language-agent-v2/trace.proto | 77 ++++
.../ApplicationRegisterService.proto | 39 ++
.../proto/language-agent/DiscoveryService.proto | 91 +++++
.../src/main/proto/language-agent/Downstream.proto | 27 ++
.../proto/language-agent/JVMMetricsService.proto | 36 ++
.../proto/language-agent/KeyWithIntegerValue.proto | 28 ++
.../proto/language-agent/KeyWithStringValue.proto | 28 ++
.../NetworkAddressRegisterService.proto | 38 ++
.../proto/language-agent/TraceSegmentService.proto | 78 ++++
.../src/main/proto/register/InstancePing.proto | 36 ++
.../src/main/proto/register/Register.proto | 124 ++++++
.../istio/skywalking.config.pb.html | 39 ++
.../proto/service-mesh-probe/service-mesh.proto | 56 +++
.../src/main/resources/config.properties | 16 +
mock-collector/src/main/resources/expect-data.yaml | 78 ++++
mock-collector/src/main/resources/log4j2.xml | 30 ++
mock-collector/src/main/resources/sample-data.yaml | 68 ++++
pom.xml | 179 +++++++++
validator/README.md | 36 ++
.../ActualRegistryOperationNameEmptyException.md | 12 +
.../exception/ActualSegmentItemEmptyException.md | 15 +
.../docs/exception/IllegalDataFileException.md | 11 +
.../exception/ParentSegmentNotFoundException.md | 24 ++
.../RegistryApplicationNotFoundException.md | 27 ++
.../RegistryApplicationSizeNotEqualsException.md | 13 +
...gistryInstanceOfApplicationNotFoundException.md | 25 ++
.../RegistryInstanceSizeNotEqualsException.md | 13 +
.../RegistryInstancesNotEqualsException.md | 12 +
.../RegistryOperationNameNotFoundException.md | 13 +
.../RegistryOperationNamesNotFoundException.md | 13 +
...OperationNamesOfApplicationNotFoundException.md | 12 +
.../docs/exception/SegmentItemNotFoundException.md | 15 +
.../docs/exception/SegmentNotFoundException.md | 31 ++
.../docs/exception/SegmentRefNotFoundException.md | 30 ++
.../exception/SegmentRefSizeNotEqualsException.md | 34 ++
.../exception/SegmentSizeNotEqualsException.md | 12 +
validator/pom.xml | 74 ++++
.../plugin/test/agent/tool/ConfigHelper.java | 32 ++
.../skywalking/plugin/test/agent/tool/Main.java | 63 ++++
.../tool/validator/assertor/ApplicationAssert.java | 53 +++
.../agent/tool/validator/assertor/DataAssert.java | 35 ++
.../tool/validator/assertor/ExpressParser.java | 63 ++++
.../tool/validator/assertor/InstanceAssert.java | 53 +++
.../validator/assertor/OperationNameAssert.java | 62 +++
.../assertor/ParentSegmentIdExpressParser.java | 47 +++
.../validator/assertor/RegistryItemsAssert.java | 35 ++
.../tool/validator/assertor/SegmentAssert.java | 224 +++++++++++
.../validator/assertor/SegmentItemsAssert.java | 102 +++++
.../assertor/SegmentPredictionFailedCause.java | 39 ++
.../tool/validator/assertor/SegmentRefAssert.java | 83 ++++
.../assertor/SegmentRefAssertFailedCause.java | 39 ++
.../assertor/element/ElementAssertor.java | 31 ++
.../validator/assertor/element/EqualsAssertor.java | 34 ++
.../assertor/element/GreatThanAssertor.java | 34 ++
.../assertor/element/GreetEqualAssertor.java | 34 ++
.../validator/assertor/element/NoopAssertor.java | 29 ++
.../assertor/element/NotEqualsAssertor.java | 34 ++
.../assertor/element/NotNullAssertor.java | 33 ++
.../validator/assertor/element/NullAssertor.java | 33 ++
.../ActualRegistryOperationNameEmptyException.java | 36 ++
.../exception/ActualSegmentItemEmptyException.java | 35 ++
.../ActualSegmentRefIsEmptyException.java | 33 ++
.../exception/KeyValueNotEqualsException.java | 21 ++
.../exception/LogEventKeyNotEqualsException.java | 35 ++
.../exception/LogEventSizeNotEqualsException.java | 35 ++
.../exception/LogEventValueNotEqualsException.java | 37 ++
.../exception/LogSizeNotEqualsException.java | 35 ++
.../exception/ParentSegmentNotFoundException.java | 34 ++
.../exception/RefSizeNotEqualsException.java | 36 ++
.../RegistryApplicationNotFoundException.java | 33 ++
.../RegistryApplicationSizeNotEqualsException.java | 36 ++
...stryInstanceOfApplicationNotFoundException.java | 34 ++
.../RegistryInstanceSizeNotEqualsException.java | 37 ++
.../RegistryOperationNameNotFoundException.java | 35 ++
...erationNamesOfApplicationNotFoundException.java | 35 ++
.../exception/SegmentItemNotFoundException.java | 33 ++
.../exception/SegmentNotFoundException.java | 56 +++
.../exception/SegmentRefAssertFailedException.java | 38 ++
.../exception/SegmentRefNotFoundException.java | 56 +++
.../SegmentRefSizeNotEqualsException.java | 35 ++
.../exception/SegmentSizeNotEqualsException.java | 37 ++
.../exception/SpanAssertFailedException.java | 46 +++
.../exception/SpanSizeNotEqualsException.java | 36 ++
.../exception/TagKeyNotEqualsException.java | 35 ++
.../exception/TagSizeNotEqualsException.java | 35 ++
.../exception/TagValueNotEqualsException.java | 37 ++
.../exception/ValueAssertFailedException.java | 49 +++
.../test/agent/tool/validator/entity/Data.java | 60 +++
.../agent/tool/validator/entity/DataForRead.java | 57 +++
.../agent/tool/validator/entity/KeyValuePair.java | 44 +++
.../test/agent/tool/validator/entity/LogEvent.java | 42 +++
.../tool/validator/entity/RegistryApplication.java | 44 +++
.../tool/validator/entity/RegistryInstance.java | 46 +++
.../agent/tool/validator/entity/RegistryItems.java | 28 ++
.../validator/entity/RegistryItemsForRead.java | 97 +++++
.../validator/entity/RegistryOperationName.java | 46 +++
.../test/agent/tool/validator/entity/Segment.java | 28 ++
.../tool/validator/entity/SegmentForRead.java | 420 +++++++++++++++++++++
.../agent/tool/validator/entity/SegmentItem.java | 28 ++
.../tool/validator/entity/SegmentItemForRead.java | 76 ++++
.../agent/tool/validator/entity/SegmentRef.java | 45 +++
.../test/agent/tool/validator/entity/Span.java | 58 +++
.../validator/exception/AssertFailedException.java | 29 ++
.../exception/IllegalDataFileException.java | 31 ++
validator/src/main/resources/log4j2.xml | 37 ++
.../tool/validator/assertor/DataAssertTest.java | 40 ++
validator/src/test/resources/actualData.yaml | 295 +++++++++++++++
validator/src/test/resources/expectedData.yaml | 292 ++++++++++++++
145 files changed, 7776 insertions(+)
diff --git a/.asf.yaml b/.asf.yaml
new file mode 100644
index 0000000..9f09a9f
--- /dev/null
+++ b/.asf.yaml
@@ -0,0 +1,32 @@
+#
+# 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.
+#
+
+github:
+ description: The Nginx Lua agent for Apache SkyWalking
+ homepage: https://skywalking.apache.org/
+ labels:
+ - skywalking
+ - observability
+ - apm
+ - distributed-tracing
+ - nginx
+ - lua
+ - dapper
+ enabled_merge_buttons:
+ squash: true
+ merge: false
+ rebase: false
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..0aac734
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,17 @@
+/build/
+target/
+.idea/
+**/tagert/**
+*.iml
+.classpath
+.project
+.settings/
+.DS_Store
+*~
+packages/
+**/dependency-reduced-pom.xml
+/dist/
+.factorypath
+.vscode
+.checkstyle
+.externalToolBuilders
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..a356a96
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,210 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright {yyyy} {name of copyright owner}
+
+ Licensed 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.
+
+========================================================================
+BSD licenses
+========================================================================
+
+The following components are provided under a BSD license. See project link for details.
+The text of each license is also included at licenses/LICENSE-[project].txt.
+
+ proto files from gogo: https://github.com/gogo/protobuf BSD-2
\ No newline at end of file
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..e646f51
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,5 @@
+Apache SkyWalking
+Copyright 2017-2020 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..48ca3cb
--- /dev/null
+++ b/README.md
@@ -0,0 +1,7 @@
+# Apache SkyWalking Agent Test Tool Suits
+
+
+## Apache SkyWalking Mock Collector
+
+
+## Apache SkyWalking Validator Tool
\ No newline at end of file
diff --git a/mock-collector/bin/collector-startup.sh b/mock-collector/bin/collector-startup.sh
new file mode 100644
index 0000000..419e345
--- /dev/null
+++ b/mock-collector/bin/collector-startup.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+
+# 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.
+
+PRG="$0"
+PRGDIR=`dirname "$PRG"`
+[ -z "$COLLECTOR_HOME" ] && COLLECTOR_HOME=`cd "$PRGDIR/.." >/dev/null; pwd`
+
+_RUNJAVA=${JAVA_HOME}/bin/java
+[ -z "$JAVA_HOME" ] && _RUNJAVA=`java`
+
+CLASSPATH="$COLLECTOR_HOME/config:$CLASSPATH"
+for i in "$COLLECTOR_HOME"/libs/*.jar
+do
+ CLASSPATH="$i:$CLASSPATH"
+done
+
+JAVA_OPTS="${JAVA_OPTS} -Xmx256m -Xms256m"
+JAVA_OPTS="${JAVA_OPTS} -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 "
+
+$_RUNJAVA ${JAVA_OPTS} -classpath $CLASSPATH org.apache.skywalking.plugin.test.mockcollector.Main
diff --git a/mock-collector/pom.xml b/mock-collector/pom.xml
new file mode 100644
index 0000000..d5e931d
--- /dev/null
+++ b/mock-collector/pom.xml
@@ -0,0 +1,152 @@
+<?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">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.skywalking.plugin</groupId>
+ <artifactId>agent-test-tools</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>mock-collector</artifactId>
+ <packaging>jar</packaging>
+
+ <name>SkyWalking-Mock-Collector</name>
+ <url>http://maven.apache.org</url>
+
+ <properties>
+ <repos.protocol>https://github.com/apache/skywalking-data-collect-protocol.git</repos.protocol>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-netty</artifactId>
+ <version>${grpc.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-codec-http2</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-handler-proxy</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>mock-collector</finalName>
+ <extensions>
+ <extension>
+ <groupId>kr.motd.maven</groupId>
+ <artifactId>os-maven-plugin</artifactId>
+ <version>1.4.1.Final</version>
+ </extension>
+ </extensions>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${maven-compiler-plugin.version}</version>
+ <configuration>
+ <source>${maven.compiler.source}</source>
+ <target>${maven.compiler.source}</target>
+ <encoding>${project.build.sourceEncoding}</encoding>
+ </configuration>
+ </plugin>
+<!-- <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>1.6.0</version>
+ <executions>
+ <execution>
+ <phase>initialize</phase>
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <executable>git</executable>
+ <arguments>
+ <argument>clone</argument>
+ <argument>-b</argument>
+ <argument>master</argument>
+ <argument>${repos.protocol}</argument>
+ <argument>${project.basedir}/target/proto</argument>
+ </arguments>
+ </configuration>
+ </plugin>-->
+ <plugin>
+ <groupId>org.xolstice.maven.plugins</groupId>
+ <artifactId>protobuf-maven-plugin</artifactId>
+ <version>0.5.0</version>
+ <configuration>
+ <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.4.0:exe:${os.detected.classifier}</pluginArtifact>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ <goal>compile-custom</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/assembly.xml</descriptor>
+ </descriptors>
+ <outputDirectory>${project.basedir}/../dist</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <excludes>
+ <exclude>*.properties</exclude>
+ <exclude>*.yaml</exclude>
+ <exclude>*.xml</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/mock-collector/src/main/assembly/assembly.xml b/mock-collector/src/main/assembly/assembly.xml
new file mode 100644
index 0000000..2ba07c1
--- /dev/null
+++ b/mock-collector/src/main/assembly/assembly.xml
@@ -0,0 +1,57 @@
+<!--
+ ~ 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.
+ ~
+ -->
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+ <id></id>
+ <formats>
+ <format>tar.gz</format>
+ </formats>
+ <dependencySets>
+ <dependencySet>
+ <outputDirectory>/libs</outputDirectory>
+ <scope>runtime</scope>
+ </dependencySet>
+ </dependencySets>
+ <fileSets>
+ <fileSet>
+ <directory>${project.basedir}/bin</directory>
+ <outputDirectory>/bin</outputDirectory>
+ <includes>
+ <include>*.sh</include>
+ </includes>
+ <fileMode>0755</fileMode>
+ </fileSet>
+ <fileSet>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>collector.properties</include>
+ <include>log4j2.xml</include>
+ </includes>
+ <outputDirectory>/config</outputDirectory>
+ </fileSet>
+ <fileSet>
+ <directory>${project.build.directory}</directory>
+ <outputDirectory>/libs</outputDirectory>
+ <includes>
+ <include>${build.finalName}.jar</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</assembly>
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/Main.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/Main.java
new file mode 100644
index 0000000..dead944
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/Main.java
@@ -0,0 +1,80 @@
+/*
+ * 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.plugin.test.mockcollector;
+
+import io.grpc.netty.NettyServerBuilder;
+import io.netty.channel.local.LocalAddress;
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.skywalking.plugin.test.mockcollector.entity.ValidateData;
+import org.apache.skywalking.plugin.test.mockcollector.service.ClearReceiveDataService;
+import org.apache.skywalking.plugin.test.mockcollector.service.GrpcAddressHttpService;
+import org.apache.skywalking.plugin.test.mockcollector.service.MockInstanceDiscoveryService;
+import org.apache.skywalking.plugin.test.mockcollector.service.MockInstancePingService;
+import org.apache.skywalking.plugin.test.mockcollector.service.MockJVMMetricReportService;
+import org.apache.skywalking.plugin.test.mockcollector.service.MockNetworkAddressRegisterService;
+import org.apache.skywalking.plugin.test.mockcollector.service.MockRegisterService;
+import org.apache.skywalking.plugin.test.mockcollector.service.MockTraceSegmentService;
+import org.apache.skywalking.plugin.test.mockcollector.service.ReceiveDataService;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+
+public class Main {
+ public static void main(String[] args) throws Exception {
+ NettyServerBuilder.forAddress(LocalAddress.ANY)
+ .forPort(19876)
+ .maxConcurrentCallsPerConnection(12)
+ .maxMessageSize(16777216)
+ .addService(new MockRegisterService())
+ .addService(new MockInstancePingService())
+ .addService(new MockInstanceDiscoveryService())
+ .addService(new MockNetworkAddressRegisterService())
+ .addService(new MockTraceSegmentService())
+ .addService(new MockJVMMetricReportService())
+ .build()
+ .start();
+
+ Server jettyServer = new Server(new InetSocketAddress("0.0.0.0", Integer.valueOf(12800)));
+ 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);
+ jettyServer.setHandler(servletContextHandler);
+ jettyServer.start();
+ }
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/RegistryItem.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/RegistryItem.java
new file mode 100644
index 0000000..668c00c
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/RegistryItem.java
@@ -0,0 +1,153 @@
+/*
+ * 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.plugin.test.mockcollector.entity;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class RegistryItem {
+ /**
+ * applicationCode, applicationId
+ */
+ private final Map<String, Integer> applications;
+ /**
+ * applicationCode, operationName
+ */
+ private final Map<String, Set<String>> operationNames;
+ /**
+ * applicationCode, instanceId
+ */
+ private final Map<String, List<Integer>> instanceMapping;
+ /**
+ * applicationCode, count
+ */
+ private final Map<String, Integer> heartBeats;
+
+ public RegistryItem() {
+ applications = new ConcurrentHashMap<>();
+ operationNames = new ConcurrentHashMap<>();
+ instanceMapping = new ConcurrentHashMap<>();
+ heartBeats = new ConcurrentHashMap<>();
+ }
+
+ public void registryApplication(Application application) {
+ applications.putIfAbsent(application.applicationCode, application.applicationId);
+ }
+
+ public void registryOperationName(OperationName operationName) {
+ String applicationCode = findApplicationCode(operationName.applicationId);
+ Set<String> operationNameList = operationNames.get(applicationCode);
+ if (operationNameList == null) {
+ operationNameList = new HashSet<>();
+ operationNames.put(applicationCode, operationNameList);
+ }
+ operationNameList.add(operationName.operationName);
+ }
+
+ public void registryInstance(Instance instance) {
+ String applicationCode = findApplicationCode(instance.applicationId);
+ List<Integer> instances = instanceMapping.get(applicationCode);
+ if (instances == null) {
+ instances = new ArrayList<>();
+ instanceMapping.put(applicationCode, instances);
+ }
+
+ if (!instances.contains(instance)) {
+ instances.add(instance.instanceId);
+ }
+ }
+
+ public String findApplicationCode(int id) {
+ for (Map.Entry<String, Integer> entry : applications.entrySet()) {
+ if (entry.getValue() == id) {
+ return entry.getKey();
+ }
+ }
+ throw new RuntimeException("Cannot found the code of applicationID[" + id + "].");
+ }
+
+ public void registryHeartBeat(HeartBeat heartBeat) {
+ for (Map.Entry<String, List<Integer>> entry : instanceMapping.entrySet()) {
+ if (entry.getValue().contains(heartBeat.instanceID)) {
+ Integer count = heartBeats.get(entry.getKey());
+ if (count != null) {
+ heartBeats.put(entry.getKey(), 0);
+ heartBeats.put(entry.getKey(), count++);
+ }
+ }
+ }
+ }
+
+ public static class OperationName {
+ int applicationId;
+ String operationName;
+
+ public OperationName(int applicationId, String operationName) {
+ this.applicationId = applicationId;
+ this.operationName = operationName;
+ }
+ }
+
+ public static class Application {
+ String applicationCode;
+ int applicationId;
+
+ public Application(String applicationCode, int applicationId) {
+ this.applicationCode = applicationCode;
+ this.applicationId = applicationId;
+ }
+ }
+
+ public static class Instance {
+ int applicationId;
+ int instanceId;
+
+ public Instance(int applicationId, int instanceId) {
+ this.applicationId = applicationId;
+ this.instanceId = instanceId;
+ }
+ }
+
+ public static class HeartBeat {
+ private int instanceID;
+
+ public HeartBeat(int instanceID) {
+ this.instanceID = instanceID;
+ }
+ }
+
+ public Map<String, Integer> getApplications() {
+ return applications;
+ }
+
+ public Map<String, Set<String>> getOperationNames() {
+ return operationNames;
+ }
+
+ public Map<String, List<Integer>> getInstanceMapping() {
+ return instanceMapping;
+ }
+
+ public Map<String, Integer> getHeartBeats() {
+ return heartBeats;
+ }
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/RegistryItemSerializer.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/RegistryItemSerializer.java
new file mode 100644
index 0000000..f022bbf
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/RegistryItemSerializer.java
@@ -0,0 +1,65 @@
+/*
+ * 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.plugin.test.mockcollector.entity;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+import java.lang.reflect.Type;
+
+public class RegistryItemSerializer implements JsonSerializer<RegistryItem> {
+ @Override
+ public JsonElement serialize(RegistryItem src, Type typeOfSrc, JsonSerializationContext context) {
+ JsonObject jsonObject = new JsonObject();
+ JsonArray applicationArrays = new JsonArray();
+ src.getApplications().forEach((applicationCode, applicationId) -> {
+ JsonObject applicationJson = new JsonObject();
+ applicationJson.addProperty(applicationCode, applicationId);
+ applicationArrays.add(applicationJson);
+ });
+ jsonObject.add("applications", applicationArrays);
+
+ JsonArray instanceArrays = new JsonArray();
+ src.getInstanceMapping().forEach((applicationCode, instanceIds) -> {
+ JsonObject instanceJson = new JsonObject();
+ instanceJson.addProperty(applicationCode, instanceIds.size());
+ instanceArrays.add(instanceJson);
+ });
+ jsonObject.add("instances", instanceArrays);
+
+ JsonArray operationNameArrays = new JsonArray();
+ src.getOperationNames().forEach((applicationCode, operationNames) -> {
+ JsonObject instanceJson = new JsonObject();
+ instanceJson.add(applicationCode, new Gson().toJsonTree(operationNames));
+ operationNameArrays.add(instanceJson);
+ });
+ jsonObject.add("operationNames", operationNameArrays);
+
+ JsonArray heartBeatArrays = new JsonArray();
+ src.getHeartBeats().forEach((applicationCode, count) -> {
+ JsonObject instanceJson = new JsonObject();
+ instanceJson.addProperty(applicationCode, count);
+ heartBeatArrays.add(instanceJson);
+ });
+ jsonObject.add("heartbeat", heartBeatArrays);
+ return jsonObject;
+ }
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/Segment.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/Segment.java
new file mode 100644
index 0000000..407f01e
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/Segment.java
@@ -0,0 +1,52 @@
+/*
+ * 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.plugin.test.mockcollector.entity;
+
+import java.util.ArrayList;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.ToString;
+import org.apache.skywalking.apm.network.language.agent.UniqueId;
+
+@ToString
+@Builder
+@AllArgsConstructor
+public class Segment {
+ private String segmentId;
+ private List<Span> spans;
+
+ public static class SegmentBuilder {
+
+ public SegmentBuilder addSpan(Span.SpanBuilder spanBuilder) {
+ if (spans == null) {
+ this.spans = new ArrayList<>();
+ }
+
+ spans.add(spanBuilder.build());
+ return this;
+ }
+
+ public SegmentBuilder segmentId(UniqueId segmentUniqueId) {
+ segmentId = String.join(".", Long.toString(segmentUniqueId.getIdParts(0)), Long.toString(segmentUniqueId.getIdParts(1)), Long
+ .toString(segmentUniqueId.getIdParts(2)));
+ return this;
+ }
+ }
+
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/SegmentItem.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/SegmentItem.java
new file mode 100644
index 0000000..8730b46
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/SegmentItem.java
@@ -0,0 +1,43 @@
+/*
+ * 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.plugin.test.mockcollector.entity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class SegmentItem {
+ private String applicationCode;
+ private List<Segment> segments;
+
+ public SegmentItem(String applicationCode) {
+ this.applicationCode = applicationCode;
+ segments = new ArrayList<>();
+ }
+
+ public void addSegments(Segment item) {
+ segments.add(item);
+ }
+
+ public String getApplicationCode() {
+ return applicationCode;
+ }
+
+ public List<Segment> getSegments() {
+ return segments;
+ }
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/SegmentItems.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/SegmentItems.java
new file mode 100644
index 0000000..60e07f1
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/SegmentItems.java
@@ -0,0 +1,44 @@
+/*
+ * 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.plugin.test.mockcollector.entity;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class SegmentItems {
+ private Map<String, SegmentItem> segmentItems;
+
+ public SegmentItems() {
+ this.segmentItems = new HashMap<>();
+ }
+
+ public SegmentItems addSegmentItem(int applicationId, Segment segment) {
+ String applicationCode = ValidateData.INSTANCE.getRegistryItem().findApplicationCode(applicationId);
+ SegmentItem segmentItem = segmentItems.get(applicationCode);
+ if (segmentItem == null) {
+ segmentItem = new SegmentItem(applicationCode);
+ segmentItems.put(applicationCode, segmentItem);
+ }
+ segmentItem.addSegments(segment);
+ return this;
+ }
+
+ public Map<String, SegmentItem> getSegmentItems() {
+ return segmentItems;
+ }
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/SegmentItemsSerializer.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/SegmentItemsSerializer.java
new file mode 100644
index 0000000..7dc66c9
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/SegmentItemsSerializer.java
@@ -0,0 +1,47 @@
+/*
+ * 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.plugin.test.mockcollector.entity;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+import java.lang.reflect.Type;
+
+public class SegmentItemsSerializer implements JsonSerializer<SegmentItems> {
+
+ @Override
+ public JsonElement serialize(SegmentItems src, Type typeOfSrc, JsonSerializationContext context) {
+ JsonArray applicationSegmentItems = new JsonArray();
+ src.getSegmentItems().forEach((applicationCode, segmentItem) -> {
+ JsonObject segmentJson = new JsonObject();
+ segmentJson.addProperty("applicationCode", applicationCode);
+ segmentJson.addProperty("segmentSize", segmentItem.getSegments().size());
+ JsonArray segments = new JsonArray();
+ segmentItem.getSegments().forEach(segment -> {
+ segments.add(new Gson().toJsonTree(segment));
+ });
+ segmentJson.add("segments", segments);
+ applicationSegmentItems.add(segmentJson);
+ });
+
+ return applicationSegmentItems;
+ }
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/Span.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/Span.java
new file mode 100644
index 0000000..b4fbb53
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/Span.java
@@ -0,0 +1,193 @@
+/*
+ * 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.
+ */
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed 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 repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.apache.skywalking.plugin.test.mockcollector.entity;
+
+import java.util.ArrayList;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+import lombok.ToString;
+import org.apache.skywalking.apm.network.common.KeyStringValuePair;
+import org.apache.skywalking.apm.network.language.agent.KeyWithStringValue;
+import org.apache.skywalking.apm.network.language.agent.TraceSegmentReference;
+import org.apache.skywalking.apm.network.language.agent.UniqueId;
+import org.apache.skywalking.apm.network.language.agent.v2.SegmentReference;
+
+@Builder
+@ToString
+@AllArgsConstructor
+public class Span {
+ private String operationName;
+ private int operationId;
+ private int parentSpanId;
+ private int spanId;
+ private String spanLayer;
+ private long startTime;
+ private long endTime;
+ private int componentId;
+ private String componentName;
+ private boolean isError;
+ private String spanType;
+ private String peer;
+ private int peerId;
+ private List<KeyValuePair> tags = new ArrayList<>();
+ private List<LogEvent> logs = new ArrayList<>();
+ private List<SegmentRef> refs = new ArrayList<>();
+
+ public static class LogEvent {
+ private List<KeyValuePair> logEvent;
+
+ public LogEvent() {
+ this.logEvent = new ArrayList<>();
+ }
+ }
+
+ public static class SpanBuilder {
+ public SpanBuilder logEvent(List<KeyStringValuePair> eventMessage) {
+ if (logs == null) {
+ logs = new ArrayList<>();
+ }
+
+ LogEvent event = new LogEvent();
+ for (KeyStringValuePair value : eventMessage) {
+ event.logEvent.add(new KeyValuePair(value.getKey(), value.getValue()));
+ }
+ logs.add(event);
+ return this;
+ }
+
+ public SpanBuilder tags(String key, String value) {
+ if (tags == null) {
+ tags = new ArrayList<>();
+ }
+
+ tags.add(new KeyValuePair(key, value));
+ return this;
+ }
+
+ public SpanBuilder ref(SegmentRef segmentRefBuilder) {
+ if (refs == null) {
+ refs = new ArrayList<>();
+ }
+
+ refs.add(segmentRefBuilder);
+ return this;
+ }
+
+ public SpanBuilder logEventV1(List<KeyWithStringValue> dataList) {
+ if (logs == null) {
+ logs = new ArrayList<>();
+ }
+
+ LogEvent event = new LogEvent();
+ for (KeyWithStringValue value : dataList) {
+ event.logEvent.add(new KeyValuePair(value.getKey(), value.getValue()));
+ }
+ logs.add(event);
+ return this;
+ }
+ }
+
+ public static class KeyValuePair {
+ @Getter
+ private String key;
+ @Getter
+ private String value;
+
+ public KeyValuePair(String key, String value) {
+ this.key = key;
+ this.value = value;
+ }
+ }
+
+ @ToString
+ public static class SegmentRef {
+ @Getter
+ private int parentEndpointId;
+ @Getter
+ private String parentEndpoint;
+ @Getter
+ private int networkAddressId;
+ @Getter
+ private int entryEndpointId;
+ @Getter
+ private String refType;
+ @Getter
+ private int parentSpanId;
+ @Getter
+ private String parentTraceSegmentId;
+ @Getter
+ private int parentServiceInstanceId;
+ @Getter
+ private String networkAddress;
+ @Getter
+ private String entryEndpoint;
+ @Getter
+ private int entryServiceInstanceId;
+
+ public SegmentRef(SegmentReference ref) {
+ UniqueId segmentUniqueId = ref.getParentTraceSegmentId();
+ this.parentTraceSegmentId = String.join(".", Long.toString(segmentUniqueId.getIdParts(0)), Long.toString(segmentUniqueId
+ .getIdParts(1)), Long.toString(segmentUniqueId.getIdParts(2)));
+ this.refType = ref.getRefType().toString();
+ this.parentSpanId = ref.getParentSpanId();
+ this.entryEndpointId = ref.getEntryEndpointId();
+ this.networkAddressId = ref.getNetworkAddressId();
+ this.parentServiceInstanceId = ref.getParentServiceInstanceId();
+ this.parentEndpointId = ref.getParentEndpointId();
+ this.parentEndpoint = ref.getParentEndpoint();
+ this.networkAddress = ref.getNetworkAddress();
+ this.entryEndpoint = ref.getEntryEndpoint();
+ this.entryServiceInstanceId = ref.getEntryServiceInstanceId();
+ }
+
+ public SegmentRef(TraceSegmentReference ref) {
+ UniqueId segmentUniqueId = ref.getParentTraceSegmentId();
+ this.parentTraceSegmentId = String.join(".", Long.toString(segmentUniqueId.getIdParts(0)), Long.toString(segmentUniqueId
+ .getIdParts(1)), Long.toString(segmentUniqueId.getIdParts(2)));
+ this.refType = ref.getRefType().toString();
+ this.parentSpanId = ref.getParentSpanId();
+ this.entryEndpointId = ref.getEntryServiceId();
+ this.networkAddressId = ref.getNetworkAddressId();
+ this.parentServiceInstanceId = ref.getParentApplicationInstanceId();
+ this.parentEndpointId = ref.getParentServiceId();
+ this.parentEndpoint = ref.getParentServiceName();
+ this.networkAddress = ref.getNetworkAddress();
+ this.entryEndpoint = ref.getEntryServiceName();
+ this.entryServiceInstanceId = ref.getEntryApplicationInstanceId();
+ }
+ }
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/ValidateData.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/ValidateData.java
new file mode 100644
index 0000000..28b78b7
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/ValidateData.java
@@ -0,0 +1,43 @@
+/*
+ * 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.plugin.test.mockcollector.entity;
+
+public class ValidateData {
+ public static ValidateData INSTANCE = new ValidateData();
+ private RegistryItem registryItem;
+ private SegmentItems segmentItem;
+
+ public ValidateData() {
+ registryItem = new RegistryItem();
+ segmentItem = new SegmentItems();
+ }
+
+ public RegistryItem getRegistryItem() {
+ return registryItem;
+ }
+
+ public SegmentItems getSegmentItem() {
+ return segmentItem;
+ }
+
+ public static void clearData() {
+ System.out.println("Clear Data");
+ INSTANCE.segmentItem = new SegmentItems();
+ INSTANCE.registryItem.getOperationNames().clear();
+ }
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/ValidateDataSerializer.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/ValidateDataSerializer.java
new file mode 100644
index 0000000..d6fabf5
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/entity/ValidateDataSerializer.java
@@ -0,0 +1,40 @@
+/*
+ * 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.plugin.test.mockcollector.entity;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+import java.lang.reflect.Type;
+
+public class ValidateDataSerializer implements JsonSerializer<ValidateData> {
+ @Override
+ public JsonElement serialize(ValidateData src, Type typeOfSrc, JsonSerializationContext context) {
+ Gson gson = new GsonBuilder().registerTypeAdapter(RegistryItem.class, new RegistryItemSerializer())
+ .registerTypeAdapter(SegmentItems.class, new SegmentItemsSerializer())
+ .create();
+
+ JsonObject jsonObject = new JsonObject();
+ jsonObject.add("registryItems", gson.toJsonTree(src.getRegistryItem()));
+ jsonObject.add("segmentItems", gson.toJsonTree(src.getSegmentItem()));
+ return jsonObject;
+ }
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/ClearReceiveDataService.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/ClearReceiveDataService.java
new file mode 100644
index 0000000..3c42984
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/ClearReceiveDataService.java
@@ -0,0 +1,47 @@
+/*
+ * 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.plugin.test.mockcollector.service;
+
+import java.io.IOException;
+import java.io.Writer;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.skywalking.plugin.test.mockcollector.entity.ValidateData;
+
+public class ClearReceiveDataService extends HttpServlet {
+
+ public static final String SERVLET_PATH = "/receiveData/clear";
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ resp.setContentType("text/json");
+ resp.setCharacterEncoding("utf-8");
+ resp.setStatus(200);
+ ValidateData.clearData();
+ Writer out = resp.getWriter();
+ out.flush();
+ out.close();
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ doGet(req, resp);
+ }
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/GrpcAddressHttpService.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/GrpcAddressHttpService.java
new file mode 100644
index 0000000..264e148
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/GrpcAddressHttpService.java
@@ -0,0 +1,51 @@
+/*
+ * 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.plugin.test.mockcollector.service;
+
+import com.google.gson.JsonArray;
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.skywalking.plugin.test.mockcollector.util.ConfigReader;
+
+public class GrpcAddressHttpService extends HttpServlet {
+
+ public static String SERVLET_PATH = "/agent/gRPC";
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ JsonArray jsonArray = new JsonArray();
+ jsonArray.add(ConfigReader.getGrpcBindHost() + ":" + ConfigReader.getGrpcBindPort());
+ resp.setContentType("text/json");
+ resp.setCharacterEncoding("utf-8");
+ resp.setStatus(200);
+
+ PrintWriter out = resp.getWriter();
+ out.print(jsonArray.toString());
+ out.flush();
+ out.close();
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ doPost(req, resp);
+ }
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockCLRMetricReportService.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockCLRMetricReportService.java
new file mode 100644
index 0000000..dc969b7
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockCLRMetricReportService.java
@@ -0,0 +1,35 @@
+/*
+ * 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.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;
+
+/**
+ * Author Daming Email zteny@foxmail.com
+ **/
+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/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockInstanceDiscoveryService.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockInstanceDiscoveryService.java
new file mode 100644
index 0000000..8ee0901
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockInstanceDiscoveryService.java
@@ -0,0 +1,52 @@
+/*
+ * 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.plugin.test.mockcollector.service;
+
+import io.grpc.stub.StreamObserver;
+import org.apache.skywalking.apm.network.language.agent.ApplicationInstance;
+import org.apache.skywalking.apm.network.language.agent.ApplicationInstanceHeartbeat;
+import org.apache.skywalking.apm.network.language.agent.ApplicationInstanceMapping;
+import org.apache.skywalking.apm.network.language.agent.Downstream;
+import org.apache.skywalking.apm.network.language.agent.InstanceDiscoveryServiceGrpc;
+import org.apache.skywalking.plugin.test.mockcollector.entity.RegistryItem;
+import org.apache.skywalking.plugin.test.mockcollector.entity.ValidateData;
+
+public class MockInstanceDiscoveryService extends InstanceDiscoveryServiceGrpc.InstanceDiscoveryServiceImplBase {
+
+ @Override
+ public void heartbeat(ApplicationInstanceHeartbeat request, StreamObserver<Downstream> responseObserver) {
+ ValidateData.INSTANCE.getRegistryItem()
+ .registryHeartBeat(new RegistryItem.HeartBeat(request.getApplicationInstanceId()));
+ responseObserver.onNext(Downstream.getDefaultInstance());
+ responseObserver.onCompleted();
+ }
+
+ @Override
+ public void registerInstance(ApplicationInstance request,
+ StreamObserver<ApplicationInstanceMapping> responseObserver) {
+ int instanceId = Sequences.INSTANCE_SEQUENCE.incrementAndGet();
+ ValidateData.INSTANCE.getRegistryItem()
+ .registryInstance(new RegistryItem.Instance(request.getApplicationId(), instanceId));
+
+ responseObserver.onNext(ApplicationInstanceMapping.newBuilder()
+ .setApplicationId(request.getApplicationId())
+ .setApplicationInstanceId(instanceId)
+ .build());
+ responseObserver.onCompleted();
+ }
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockInstancePingService.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockInstancePingService.java
new file mode 100644
index 0000000..a58a70a
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockInstancePingService.java
@@ -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.
+ */
+
+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.register.v2.ServiceInstancePingGrpc;
+import org.apache.skywalking.apm.network.register.v2.ServiceInstancePingPkg;
+import org.apache.skywalking.plugin.test.mockcollector.entity.RegistryItem;
+import org.apache.skywalking.plugin.test.mockcollector.entity.ValidateData;
+
+public class MockInstancePingService extends ServiceInstancePingGrpc.ServiceInstancePingImplBase {
+
+ @Override
+ public void doPing(ServiceInstancePingPkg request, StreamObserver<Commands> responseObserver) {
+ ValidateData.INSTANCE.getRegistryItem()
+ .registryHeartBeat(new RegistryItem.HeartBeat(request.getServiceInstanceId()));
+ responseObserver.onNext(Commands.getDefaultInstance());
+ responseObserver.onCompleted();
+ }
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockJVMMetricReportService.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockJVMMetricReportService.java
new file mode 100644
index 0000000..1b5d119
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockJVMMetricReportService.java
@@ -0,0 +1,35 @@
+/*
+ * 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.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;
+
+/**
+ * Author Daming Email zteny@foxmail.com
+ **/
+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/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockNetworkAddressRegisterService.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockNetworkAddressRegisterService.java
new file mode 100644
index 0000000..7e620d4
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockNetworkAddressRegisterService.java
@@ -0,0 +1,33 @@
+/*
+ * 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.plugin.test.mockcollector.service;
+
+import io.grpc.stub.StreamObserver;
+import org.apache.skywalking.apm.network.language.agent.NetworkAddressMappings;
+import org.apache.skywalking.apm.network.language.agent.NetworkAddressRegisterServiceGrpc;
+import org.apache.skywalking.apm.network.language.agent.NetworkAddresses;
+
+public class MockNetworkAddressRegisterService extends NetworkAddressRegisterServiceGrpc.NetworkAddressRegisterServiceImplBase {
+
+ @Override
+ public void batchRegister(NetworkAddresses request, StreamObserver<NetworkAddressMappings> responseObserver) {
+ responseObserver.onNext(NetworkAddressMappings.getDefaultInstance());
+ responseObserver.onCompleted();
+ }
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockRegisterService.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockRegisterService.java
new file mode 100644
index 0000000..33df6f8
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockRegisterService.java
@@ -0,0 +1,119 @@
+/*
+ * 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.plugin.test.mockcollector.service;
+
+import io.grpc.stub.StreamObserver;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.skywalking.apm.network.common.KeyIntValuePair;
+import org.apache.skywalking.apm.network.register.v2.Endpoint;
+import org.apache.skywalking.apm.network.register.v2.EndpointMapping;
+import org.apache.skywalking.apm.network.register.v2.Enpoints;
+import org.apache.skywalking.apm.network.register.v2.NetAddressMapping;
+import org.apache.skywalking.apm.network.register.v2.NetAddresses;
+import org.apache.skywalking.apm.network.register.v2.RegisterGrpc;
+import org.apache.skywalking.apm.network.register.v2.Service;
+import org.apache.skywalking.apm.network.register.v2.ServiceInstance;
+import org.apache.skywalking.apm.network.register.v2.ServiceInstanceRegisterMapping;
+import org.apache.skywalking.apm.network.register.v2.ServiceInstances;
+import org.apache.skywalking.apm.network.register.v2.ServiceRegisterMapping;
+import org.apache.skywalking.apm.network.register.v2.Services;
+import org.apache.skywalking.plugin.test.mockcollector.entity.RegistryItem;
+import org.apache.skywalking.plugin.test.mockcollector.entity.ValidateData;
+
+public class MockRegisterService extends RegisterGrpc.RegisterImplBase {
+
+ private Logger logger = LogManager.getLogger(MockTraceSegmentService.class);
+
+ @Override
+ public void doEndpointRegister(Enpoints request, StreamObserver<EndpointMapping> responseObserver) {
+ for (Endpoint endpoint : request.getEndpointsList()) {
+ ValidateData.INSTANCE.getRegistryItem()
+ .registryOperationName(new RegistryItem.OperationName(endpoint.getServiceId(), endpoint
+ .getEndpointName()));
+ }
+ responseObserver.onNext(EndpointMapping.getDefaultInstance());
+ responseObserver.onCompleted();
+ }
+
+ @Override
+ public void doNetworkAddressRegister(NetAddresses request, StreamObserver<NetAddressMapping> responseObserver) {
+ responseObserver.onNext(NetAddressMapping.getDefaultInstance());
+ responseObserver.onCompleted();
+ }
+
+ @Override
+ public void doServiceInstanceRegister(ServiceInstances request,
+ StreamObserver<ServiceInstanceRegisterMapping> responseObserver) {
+ if (request.getInstancesCount() <= 0) {
+ responseObserver.onNext(ServiceInstanceRegisterMapping.getDefaultInstance());
+ responseObserver.onCompleted();
+ return;
+ }
+
+ for (ServiceInstance serviceInstance : request.getInstancesList()) {
+ int instanceId = Sequences.INSTANCE_SEQUENCE.incrementAndGet();
+ ValidateData.INSTANCE.getRegistryItem()
+ .registryInstance(new RegistryItem.Instance(serviceInstance.getServiceId(), instanceId));
+
+ responseObserver.onNext(ServiceInstanceRegisterMapping.newBuilder()
+ .addServiceInstances(KeyIntValuePair.newBuilder()
+ .setKey(serviceInstance
+ .getInstanceUUID())
+ .setValue(instanceId)
+ .build())
+ .build());
+ responseObserver.onCompleted();
+ }
+ }
+
+ @Override
+ public void doServiceRegister(Services request, StreamObserver<ServiceRegisterMapping> responseObserver) {
+ logger.debug("receive application register.");
+ if (request.getServicesCount() <= 0) {
+ logger.warn("The service count is empty. return the default service register mapping");
+ responseObserver.onNext(ServiceRegisterMapping.getDefaultInstance());
+ responseObserver.onCompleted();
+ return;
+ }
+
+ for (Service service : request.getServicesList()) {
+ String applicationCode = service.getServiceName();
+ ServiceRegisterMapping.Builder builder = ServiceRegisterMapping.newBuilder();
+
+ if (applicationCode.startsWith("localhost") || applicationCode.startsWith("127.0.0.1") || applicationCode.contains(":") || applicationCode
+ .contains("/")) {
+ responseObserver.onNext(builder.build());
+ responseObserver.onCompleted();
+ return;
+ }
+
+ Integer applicationId = Sequences.SERVICE_MAPPING.get(applicationCode);
+ if (applicationId == null) {
+ applicationId = Sequences.ENDPOINT_SEQUENCE.incrementAndGet();
+ Sequences.SERVICE_MAPPING.put(applicationCode, applicationId);
+ ValidateData.INSTANCE.getRegistryItem()
+ .registryApplication(new RegistryItem.Application(applicationCode, applicationId));
+ }
+
+ builder.addServices(KeyIntValuePair.newBuilder().setKey(applicationCode).setValue(applicationId).build());
+ responseObserver.onNext(builder.build());
+ responseObserver.onCompleted();
+ }
+ }
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockTraceSegmentService.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockTraceSegmentService.java
new file mode 100644
index 0000000..fb5cbd7
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/MockTraceSegmentService.java
@@ -0,0 +1,102 @@
+/*
+ * 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.plugin.test.mockcollector.service;
+
+import com.google.protobuf.InvalidProtocolBufferException;
+import io.grpc.stub.StreamObserver;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.skywalking.apm.network.common.Commands;
+import org.apache.skywalking.apm.network.common.KeyStringValuePair;
+import org.apache.skywalking.apm.network.language.agent.UpstreamSegment;
+import org.apache.skywalking.apm.network.language.agent.v2.Log;
+import org.apache.skywalking.apm.network.language.agent.v2.SegmentObject;
+import org.apache.skywalking.apm.network.language.agent.v2.SegmentReference;
+import org.apache.skywalking.apm.network.language.agent.v2.SpanObjectV2;
+import org.apache.skywalking.apm.network.language.agent.v2.TraceSegmentReportServiceGrpc;
+import org.apache.skywalking.plugin.test.mockcollector.entity.Segment;
+import org.apache.skywalking.plugin.test.mockcollector.entity.Span;
+import org.apache.skywalking.plugin.test.mockcollector.entity.ValidateData;
+
+public class MockTraceSegmentService extends TraceSegmentReportServiceGrpc.TraceSegmentReportServiceImplBase {
+
+ private Logger logger = LogManager.getLogger(MockTraceSegmentService.class);
+
+ @Override
+ public StreamObserver<UpstreamSegment> collect(StreamObserver<Commands> responseObserver) {
+ return new StreamObserver<UpstreamSegment>() {
+ @Override
+ public void onNext(UpstreamSegment value) {
+ try {
+ SegmentObject traceSegmentObject = SegmentObject.parseFrom(value.getSegment());
+ Segment.SegmentBuilder segmentBuilder = Segment.builder()
+ .segmentId(traceSegmentObject.getTraceSegmentId());
+ logger.debug("Receive segment: ServiceID[{}], TraceSegmentId[{}]", traceSegmentObject.getServiceId(), traceSegmentObject
+ .getTraceSegmentId());
+
+ for (SpanObjectV2 spanObject : traceSegmentObject.getSpansList()) {
+ Span.SpanBuilder spanBuilder = Span.builder()
+ .operationName(spanObject.getOperationName())
+ .parentSpanId(spanObject.getParentSpanId())
+ .spanId(spanObject.getSpanId())
+ .componentId(spanObject.getComponentId())
+ .componentName(spanObject.getComponent())
+ .spanLayer(spanObject.getSpanLayer().toString())
+ .endTime(spanObject.getEndTime())
+ .isError(spanObject.getIsError())
+ .startTime(spanObject.getStartTime())
+ .spanType(spanObject.getSpanType().toString())
+ .peer(spanObject.getPeer())
+ .peerId(spanObject.getPeerId())
+ .operationId(spanObject.getOperationNameId());
+
+ for (Log logMessage : spanObject.getLogsList()) {
+ spanBuilder.logEvent(logMessage.getDataList());
+ }
+
+ for (KeyStringValuePair tags : spanObject.getTagsList()) {
+ spanBuilder.tags(tags.getKey(), tags.getValue());
+ }
+
+ for (SegmentReference ref : spanObject.getRefsList()) {
+ spanBuilder.ref(new Span.SegmentRef(ref));
+ }
+
+ segmentBuilder.addSpan(spanBuilder);
+ }
+
+ ValidateData.INSTANCE.getSegmentItem()
+ .addSegmentItem(traceSegmentObject.getServiceId(), segmentBuilder.build());
+ } catch (InvalidProtocolBufferException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onError(Throwable t) {
+
+ }
+
+ @Override
+ public void onCompleted() {
+ responseObserver.onNext(Commands.newBuilder().build());
+ responseObserver.onCompleted();
+ }
+ };
+ }
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/ReceiveDataService.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/ReceiveDataService.java
new file mode 100644
index 0000000..f9b0378
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/ReceiveDataService.java
@@ -0,0 +1,53 @@
+/*
+ * 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.plugin.test.mockcollector.service;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import java.io.IOException;
+import java.io.Writer;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.skywalking.plugin.test.mockcollector.entity.ValidateData;
+import org.apache.skywalking.plugin.test.mockcollector.entity.ValidateDataSerializer;
+import org.yaml.snakeyaml.Yaml;
+
+public class ReceiveDataService extends HttpServlet {
+ public static final String SERVLET_PATH = "/receiveData";
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ resp.setContentType("text/json");
+ resp.setCharacterEncoding("utf-8");
+ resp.setStatus(200);
+ Gson gson = new GsonBuilder().registerTypeAdapter(ValidateData.class, new ValidateDataSerializer()).create();
+ System.out.println();
+ Yaml yaml = new Yaml();
+ Writer out = resp.getWriter();
+ out.write(yaml.dump(yaml.load(gson.toJson(ValidateData.INSTANCE))));
+ out.flush();
+ out.close();
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ doGet(req, resp);
+ }
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/Sequences.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/Sequences.java
new file mode 100644
index 0000000..415a52d
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/service/Sequences.java
@@ -0,0 +1,30 @@
+/*
+ * 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.plugin.test.mockcollector.service;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class Sequences {
+
+ public static final AtomicInteger INSTANCE_SEQUENCE = new AtomicInteger();
+
+ public static final AtomicInteger ENDPOINT_SEQUENCE = new AtomicInteger(1);
+
+ public static final ConcurrentHashMap<String, Integer> SERVICE_MAPPING = new ConcurrentHashMap<String, Integer>();
+}
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/util/ConfigReader.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/util/ConfigReader.java
new file mode 100644
index 0000000..89cef75
--- /dev/null
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/util/ConfigReader.java
@@ -0,0 +1,44 @@
+/*
+ * 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.plugin.test.mockcollector.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+public class ConfigReader {
+ private static Properties config = new Properties();
+
+ static {
+ InputStream inputStream = ConfigReader.class.getClassLoader().getResourceAsStream("config.properties");
+ try {
+ config.load(inputStream);
+ } catch (IOException e) {
+ System.err.println("Failed to load config.");
+ System.exit(-1);
+ }
+ }
+
+ public static String getGrpcBindHost() {
+ return config.getProperty("grpc_bind_host", "127.0.0.1");
+ }
+
+ public static int getGrpcBindPort() {
+ return Integer.parseInt(config.getProperty("grpc_bind_port", "19876"));
+ }
+}
diff --git a/mock-collector/src/main/proto/README.md b/mock-collector/src/main/proto/README.md
new file mode 100644
index 0000000..536bc1f
--- /dev/null
+++ b/mock-collector/src/main/proto/README.md
@@ -0,0 +1,5 @@
+# Apache SkyWalking data collect protocol
+Apache SkyWalking can collect data from different sources. Each kind of source should follow the protocols in this repo.
+
+## License
+Apache 2.0
diff --git a/mock-collector/src/main/proto/common/CLR.proto b/mock-collector/src/main/proto/common/CLR.proto
new file mode 100644
index 0000000..57bc860
--- /dev/null
+++ b/mock-collector/src/main/proto/common/CLR.proto
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ *
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.skywalking.apm.network.language.agent";
+option csharp_namespace = "SkyWalking.NetworkProtocol";
+
+import "common/common.proto";
+
+message CLRMetric {
+ int64 time = 1;
+ CPU cpu = 2;
+ ClrGC gc = 3;
+ ClrThread thread = 4;
+}
+
+message ClrGC {
+ int64 Gen0CollectCount = 1;
+ int64 Gen1CollectCount = 2;
+ int64 Gen2CollectCount = 3;
+ int64 HeapMemory = 4;
+}
+
+message ClrThread {
+ int32 AvailableCompletionPortThreads = 1;
+ int32 AvailableWorkerThreads = 2;
+ int32 MaxCompletionPortThreads = 3;
+ int32 MaxWorkerThreads = 4;
+}
\ No newline at end of file
diff --git a/mock-collector/src/main/proto/common/JVM.proto b/mock-collector/src/main/proto/common/JVM.proto
new file mode 100644
index 0000000..543c640
--- /dev/null
+++ b/mock-collector/src/main/proto/common/JVM.proto
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ *
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.skywalking.apm.network.language.agent";
+option csharp_namespace = "SkyWalking.NetworkProtocol";
+
+import "common/common.proto";
+
+message JVMMetric {
+ int64 time = 1;
+ CPU cpu = 2;
+ repeated Memory memory = 3;
+ repeated MemoryPool memoryPool = 4;
+ repeated GC gc = 5;
+}
+
+message Memory {
+ bool isHeap = 1;
+ int64 init = 2;
+ int64 max = 3;
+ int64 used = 4;
+ int64 committed = 5;
+}
+
+message MemoryPool {
+ PoolType type = 1;
+ int64 init = 2;
+ int64 max = 3;
+ int64 used = 4;
+ int64 commited = 5;
+}
+
+enum PoolType {
+ CODE_CACHE_USAGE = 0;
+ NEWGEN_USAGE = 1;
+ OLDGEN_USAGE = 2;
+ SURVIVOR_USAGE = 3;
+ PERMGEN_USAGE = 4;
+ METASPACE_USAGE = 5;
+}
+
+message GC {
+ GCPhrase phrase = 1;
+ int64 count = 2;
+ int64 time = 3;
+}
+
+enum GCPhrase {
+ NEW = 0;
+ OLD = 1;
+}
diff --git a/mock-collector/src/main/proto/common/common.proto b/mock-collector/src/main/proto/common/common.proto
new file mode 100644
index 0000000..ce50c76
--- /dev/null
+++ b/mock-collector/src/main/proto/common/common.proto
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ *
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.skywalking.apm.network.common";
+option csharp_namespace = "SkyWalking.NetworkProtocol";
+
+message KeyStringValuePair {
+ string key = 1;
+ string value = 2;
+}
+
+message KeyIntValuePair {
+ string key = 1;
+ int32 value = 2;
+}
+
+message CPU {
+ double usagePercent = 2;
+}
+
+// In most cases, detect point should be `server` or `client`.
+// Even in service mesh, this means `server`/`client` side sidecar
+// `proxy` is reserved only.
+enum DetectPoint {
+ client = 0;
+ server = 1;
+ proxy = 2;
+}
+
+message Commands {
+ repeated Command commands = 1;
+}
+
+message Command {
+ string command = 1;
+ repeated KeyStringValuePair args = 2;
+}
diff --git a/mock-collector/src/main/proto/common/trace-common.proto b/mock-collector/src/main/proto/common/trace-common.proto
new file mode 100644
index 0000000..dcbe03d
--- /dev/null
+++ b/mock-collector/src/main/proto/common/trace-common.proto
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ *
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.skywalking.apm.network.language.agent";
+option csharp_namespace = "SkyWalking.NetworkProtocol";
+
+message UpstreamSegment {
+ repeated UniqueId globalTraceIds = 1;
+ bytes segment = 2; // the byte array of TraceSegmentObject
+}
+
+enum SpanType {
+ Entry = 0;
+ Exit = 1;
+ Local = 2;
+}
+
+message UniqueId {
+ repeated int64 idParts = 1;
+}
+
+enum RefType {
+ CrossProcess = 0;
+ CrossThread = 1;
+}
+
+enum SpanLayer {
+ Unknown = 0;
+ Database = 1;
+ RPCFramework = 2;
+ Http = 3;
+ MQ = 4;
+ Cache = 5;
+}
diff --git a/mock-collector/src/main/proto/language-agent-v2/CLRMetric.proto b/mock-collector/src/main/proto/language-agent-v2/CLRMetric.proto
new file mode 100644
index 0000000..da023b6
--- /dev/null
+++ b/mock-collector/src/main/proto/language-agent-v2/CLRMetric.proto
@@ -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.
+ *
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.skywalking.apm.network.language.agent.v2";
+option csharp_namespace = "SkyWalking.NetworkProtocol";
+
+import "common/common.proto";
+import "common/CLR.proto";
+
+service CLRMetricReportService {
+ rpc collect (CLRMetricCollection) returns (Commands) {
+ }
+}
+
+message CLRMetricCollection {
+ repeated CLRMetric metrics = 1;
+ int32 serviceInstanceId = 2;
+}
\ No newline at end of file
diff --git a/mock-collector/src/main/proto/language-agent-v2/JVMMetric.proto b/mock-collector/src/main/proto/language-agent-v2/JVMMetric.proto
new file mode 100644
index 0000000..845624c
--- /dev/null
+++ b/mock-collector/src/main/proto/language-agent-v2/JVMMetric.proto
@@ -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.
+ *
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.skywalking.apm.network.language.agent.v2";
+option csharp_namespace = "SkyWalking.NetworkProtocol";
+
+import "common/common.proto";
+import "common/JVM.proto";
+
+service JVMMetricReportService {
+ rpc collect (JVMMetricCollection) returns (Commands) {
+ }
+}
+
+message JVMMetricCollection {
+ repeated JVMMetric metrics = 1;
+ int32 serviceInstanceId = 2;
+}
diff --git a/mock-collector/src/main/proto/language-agent-v2/trace.proto b/mock-collector/src/main/proto/language-agent-v2/trace.proto
new file mode 100644
index 0000000..c6120c5
--- /dev/null
+++ b/mock-collector/src/main/proto/language-agent-v2/trace.proto
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ *
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.skywalking.apm.network.language.agent.v2";
+option csharp_namespace = "SkyWalking.NetworkProtocol";
+
+import "common/common.proto";
+import "common/trace-common.proto";
+
+service TraceSegmentReportService {
+ rpc collect (stream UpstreamSegment) returns (Commands) {
+ }
+}
+
+message SegmentObject {
+ UniqueId traceSegmentId = 1;
+ repeated SpanObjectV2 spans = 2;
+ int32 serviceId = 3;
+ int32 serviceInstanceId = 4;
+ bool isSizeLimited = 5;
+}
+
+message SegmentReference {
+ RefType refType = 1;
+ UniqueId parentTraceSegmentId = 2;
+ int32 parentSpanId = 3;
+ int32 parentServiceInstanceId = 4;
+ string networkAddress = 5;
+ int32 networkAddressId = 6;
+ int32 entryServiceInstanceId = 7;
+ string entryEndpoint = 8;
+ int32 entryEndpointId = 9;
+ string parentEndpoint = 10;
+ int32 parentEndpointId = 11;
+}
+
+message SpanObjectV2 {
+ int32 spanId = 1;
+ int32 parentSpanId = 2;
+ int64 startTime = 3;
+ int64 endTime = 4;
+ repeated SegmentReference refs = 5;
+ int32 operationNameId = 6;
+ string operationName = 7;
+ int32 peerId = 8;
+ string peer = 9;
+ SpanType spanType = 10;
+ SpanLayer spanLayer = 11;
+ int32 componentId = 12;
+ string component = 13;
+ bool isError = 14;
+ repeated KeyStringValuePair tags = 15;
+ repeated Log logs = 16;
+}
+
+message Log {
+ int64 time = 1;
+ repeated KeyStringValuePair data = 2;
+}
diff --git a/mock-collector/src/main/proto/language-agent/ApplicationRegisterService.proto b/mock-collector/src/main/proto/language-agent/ApplicationRegisterService.proto
new file mode 100644
index 0000000..fd8ee0d
--- /dev/null
+++ b/mock-collector/src/main/proto/language-agent/ApplicationRegisterService.proto
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ *
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.skywalking.apm.network.language.agent";
+option csharp_namespace = "SkyWalking.NetworkProtocol";
+
+import "language-agent/KeyWithIntegerValue.proto";
+
+//register service for ApplicationCode, this service is called when service starts.
+service ApplicationRegisterService {
+ rpc applicationCodeRegister (Application) returns (ApplicationMapping) {
+ }
+}
+
+message Application {
+ string applicationCode = 1;
+}
+
+message ApplicationMapping {
+ KeyWithIntegerValue application = 1;
+}
diff --git a/mock-collector/src/main/proto/language-agent/DiscoveryService.proto b/mock-collector/src/main/proto/language-agent/DiscoveryService.proto
new file mode 100644
index 0000000..bc392a7
--- /dev/null
+++ b/mock-collector/src/main/proto/language-agent/DiscoveryService.proto
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ *
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.skywalking.apm.network.language.agent";
+option csharp_namespace = "SkyWalking.NetworkProtocol";
+
+import "language-agent/Downstream.proto";
+import "common/trace-common.proto";
+
+service InstanceDiscoveryService {
+ rpc registerInstance (ApplicationInstance) returns (ApplicationInstanceMapping) {
+ }
+
+ rpc heartbeat (ApplicationInstanceHeartbeat) returns (Downstream) {
+ }
+
+}
+
+message ApplicationInstance {
+ int32 applicationId = 1;
+ string agentUUID = 2;
+ int64 registerTime = 3;
+ OSInfo osinfo = 4;
+}
+
+message ApplicationInstanceMapping {
+ int32 applicationId = 1;
+ int32 applicationInstanceId = 2;
+}
+
+message ApplicationInstanceRecover {
+ int32 applicationId = 1;
+ int32 applicationInstanceId = 2;
+ int64 registerTime = 3;
+ OSInfo osinfo = 4;
+}
+
+message ApplicationInstanceHeartbeat {
+ int32 applicationInstanceId = 1;
+ int64 heartbeatTime = 2;
+}
+
+message OSInfo {
+ string osName = 1;
+ string hostname = 2;
+ int32 processNo = 3;
+ repeated string ipv4s = 4;
+}
+
+//discovery service for ServiceName by Network address or application code
+service ServiceNameDiscoveryService {
+ rpc discovery (ServiceNameCollection) returns (ServiceNameMappingCollection) {
+ }
+}
+
+message ServiceNameCollection {
+ repeated ServiceNameElement elements = 1;
+}
+
+message ServiceNameMappingCollection {
+ repeated ServiceNameMappingElement elements = 1;
+}
+
+message ServiceNameMappingElement {
+ int32 serviceId = 1;
+ ServiceNameElement element = 2;
+}
+
+message ServiceNameElement {
+ string serviceName = 1;
+ int32 applicationId = 2;
+ SpanType srcSpanType = 3;
+}
diff --git a/mock-collector/src/main/proto/language-agent/Downstream.proto b/mock-collector/src/main/proto/language-agent/Downstream.proto
new file mode 100644
index 0000000..e7bbb39
--- /dev/null
+++ b/mock-collector/src/main/proto/language-agent/Downstream.proto
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ *
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.skywalking.apm.network.language.agent";
+option csharp_namespace = "SkyWalking.NetworkProtocol";
+
+// nothing down stream from collector yet.
+message Downstream {
+}
diff --git a/mock-collector/src/main/proto/language-agent/JVMMetricsService.proto b/mock-collector/src/main/proto/language-agent/JVMMetricsService.proto
new file mode 100644
index 0000000..229f41a
--- /dev/null
+++ b/mock-collector/src/main/proto/language-agent/JVMMetricsService.proto
@@ -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.
+ *
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.skywalking.apm.network.language.agent";
+option csharp_namespace = "SkyWalking.NetworkProtocol";
+
+import "language-agent/Downstream.proto";
+import "common/JVM.proto";
+
+service JVMMetricsService {
+ rpc collect (JVMMetrics) returns (Downstream) {
+ }
+}
+
+message JVMMetrics {
+ repeated JVMMetric metrics = 1;
+ int32 applicationInstanceId = 2;
+}
diff --git a/mock-collector/src/main/proto/language-agent/KeyWithIntegerValue.proto b/mock-collector/src/main/proto/language-agent/KeyWithIntegerValue.proto
new file mode 100644
index 0000000..ed48a54
--- /dev/null
+++ b/mock-collector/src/main/proto/language-agent/KeyWithIntegerValue.proto
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ *
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.skywalking.apm.network.language.agent";
+option csharp_namespace = "SkyWalking.NetworkProtocol";
+
+message KeyWithIntegerValue {
+ string key = 1;
+ int32 value = 2;
+}
diff --git a/mock-collector/src/main/proto/language-agent/KeyWithStringValue.proto b/mock-collector/src/main/proto/language-agent/KeyWithStringValue.proto
new file mode 100644
index 0000000..1114267
--- /dev/null
+++ b/mock-collector/src/main/proto/language-agent/KeyWithStringValue.proto
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ *
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.skywalking.apm.network.language.agent";
+option csharp_namespace = "SkyWalking.NetworkProtocol";
+
+message KeyWithStringValue {
+ string key = 1;
+ string value = 2;
+}
diff --git a/mock-collector/src/main/proto/language-agent/NetworkAddressRegisterService.proto b/mock-collector/src/main/proto/language-agent/NetworkAddressRegisterService.proto
new file mode 100644
index 0000000..a299edc
--- /dev/null
+++ b/mock-collector/src/main/proto/language-agent/NetworkAddressRegisterService.proto
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ *
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.skywalking.apm.network.language.agent";
+option csharp_namespace = "SkyWalking.NetworkProtocol";
+
+import "language-agent/KeyWithIntegerValue.proto";
+
+service NetworkAddressRegisterService {
+ rpc batchRegister (NetworkAddresses) returns (NetworkAddressMappings) {
+ }
+}
+
+message NetworkAddresses {
+ repeated string addresses = 1;
+}
+
+message NetworkAddressMappings {
+ repeated KeyWithIntegerValue addressIds = 1;
+}
diff --git a/mock-collector/src/main/proto/language-agent/TraceSegmentService.proto b/mock-collector/src/main/proto/language-agent/TraceSegmentService.proto
new file mode 100644
index 0000000..f8566b2
--- /dev/null
+++ b/mock-collector/src/main/proto/language-agent/TraceSegmentService.proto
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ *
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.skywalking.apm.network.language.agent";
+option csharp_namespace = "SkyWalking.NetworkProtocol";
+
+import "language-agent/Downstream.proto";
+import "language-agent/KeyWithStringValue.proto";
+import "common/trace-common.proto";
+
+service TraceSegmentService {
+ rpc collect (stream UpstreamSegment) returns (Downstream) {
+ }
+}
+
+message TraceSegmentObject {
+ UniqueId traceSegmentId = 1;
+ repeated SpanObject spans = 2;
+ int32 applicationId = 3;
+ int32 applicationInstanceId = 4;
+ bool isSizeLimited = 5;
+}
+
+message TraceSegmentReference {
+ RefType refType = 1;
+ UniqueId parentTraceSegmentId = 2;
+ int32 parentSpanId = 3;
+ int32 parentApplicationInstanceId = 4;
+ string networkAddress = 5;
+ int32 networkAddressId = 6;
+ int32 entryApplicationInstanceId = 7;
+ string entryServiceName = 8;
+ int32 entryServiceId = 9;
+ string parentServiceName = 10;
+ int32 parentServiceId = 11;
+}
+
+message SpanObject {
+ int32 spanId = 1;
+ int32 parentSpanId = 2;
+ int64 startTime = 3;
+ int64 endTime = 4;
+ repeated TraceSegmentReference refs = 5;
+ int32 operationNameId = 6;
+ string operationName = 7;
+ int32 peerId = 8;
+ string peer = 9;
+ SpanType spanType = 10;
+ SpanLayer spanLayer = 11;
+ int32 componentId = 12;
+ string component = 13;
+ bool isError = 14;
+ repeated KeyWithStringValue tags = 15;
+ repeated LogMessage logs = 16;
+}
+
+message LogMessage {
+ int64 time = 1;
+ repeated KeyWithStringValue data = 2;
+}
diff --git a/mock-collector/src/main/proto/register/InstancePing.proto b/mock-collector/src/main/proto/register/InstancePing.proto
new file mode 100644
index 0000000..3a8ffe1
--- /dev/null
+++ b/mock-collector/src/main/proto/register/InstancePing.proto
@@ -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.
+ *
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.skywalking.apm.network.register.v2";
+option csharp_namespace = "SkyWalking.NetworkProtocol";
+
+import "common/common.proto";
+
+service ServiceInstancePing {
+ rpc doPing (ServiceInstancePingPkg) returns (Commands) {
+ }
+}
+
+message ServiceInstancePingPkg {
+ int32 serviceInstanceId = 1;
+ int64 time = 2;
+ string serviceInstanceUUID = 3;
+}
diff --git a/mock-collector/src/main/proto/register/Register.proto b/mock-collector/src/main/proto/register/Register.proto
new file mode 100644
index 0000000..aff9ea5
--- /dev/null
+++ b/mock-collector/src/main/proto/register/Register.proto
@@ -0,0 +1,124 @@
+/*
+ * 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.
+ *
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.skywalking.apm.network.register.v2";
+option csharp_namespace = "SkyWalking.NetworkProtocol";
+
+import "common/common.proto";
+
+//register service for ApplicationCode, this service is called when service starts.
+service Register {
+ rpc doServiceRegister (Services) returns (ServiceRegisterMapping) {
+ }
+
+ rpc doServiceInstanceRegister (ServiceInstances) returns (ServiceInstanceRegisterMapping) {
+ }
+
+ rpc doEndpointRegister (Enpoints) returns (EndpointMapping) {
+ }
+
+ rpc doNetworkAddressRegister (NetAddresses) returns (NetAddressMapping) {
+ }
+
+ rpc doServiceAndNetworkAddressMappingRegister (ServiceAndNetworkAddressMappings) returns(Commands) {
+ }
+}
+
+// Service register
+message Services {
+ repeated Service services = 1;
+}
+
+message Service {
+ string serviceName = 1;
+ repeated KeyStringValuePair tags = 3;
+ repeated KeyStringValuePair properties = 4;
+}
+
+message ServiceRegisterMapping {
+ repeated KeyIntValuePair services = 1;
+}
+
+// Service Instance register
+message ServiceInstances {
+ repeated ServiceInstance instances = 1;
+}
+
+message ServiceInstance {
+ int32 serviceId = 1;
+ string instanceUUID = 2;
+ int64 time = 3;
+ repeated KeyStringValuePair tags = 4;
+ repeated KeyStringValuePair properties = 5;
+}
+
+message ServiceInstanceRegisterMapping {
+ repeated KeyIntValuePair serviceInstances = 1;
+}
+
+// Network address register
+
+// Only known use case is the language agent.
+// Network address represents the ip/hostname:port, which is usually used at client side of RPC.
+message NetAddresses {
+ repeated string addresses = 1;
+}
+
+message NetAddressMapping {
+ repeated KeyIntValuePair addressIds = 1;
+}
+
+// Endpint register
+message Enpoints {
+ repeated Endpoint endpoints = 1;
+}
+
+message Endpoint {
+ int32 serviceId = 1;
+ string endpointName = 2;
+ repeated KeyStringValuePair tags = 3;
+ repeated KeyStringValuePair properties = 4;
+ // For endpoint
+ // from DetectPoint is either `client` or `server`. No chance to be `proxy`.
+ DetectPoint from = 5;
+}
+
+message EndpointMapping {
+ repeated EndpointMappingElement elements = 1;
+}
+
+message EndpointMappingElement {
+ int32 serviceId = 1;
+ string endpointName = 2;
+ int32 endpointId = 3;
+ DetectPoint from = 4;
+}
+
+message ServiceAndNetworkAddressMappings {
+ repeated ServiceAndNetworkAddressMapping mappings = 1;
+}
+
+message ServiceAndNetworkAddressMapping {
+ int32 serviceId = 1;
+ int32 serviceInstanceId = 2;
+ string networkAddress = 3;
+ int32 networkAddressId = 4;
+}
diff --git a/mock-collector/src/main/proto/service-mesh-probe/istio/skywalking.config.pb.html b/mock-collector/src/main/proto/service-mesh-probe/istio/skywalking.config.pb.html
new file mode 100644
index 0000000..a92c804
--- /dev/null
+++ b/mock-collector/src/main/proto/service-mesh-probe/istio/skywalking.config.pb.html
@@ -0,0 +1,39 @@
+---
+title: Apache SkyWalking
+description: Adapter to deliver metrics to Apache SkyWalking.
+location: https://istio.io/docs/reference/config/policy-and-telemetry/adapters/apache-skywalking.html
+layout: protoc-gen-docs
+generator: protoc-gen-docs
+provider: Apache SkyWalking
+contact_email: dev@skywalking.apache.org
+support_link:
+source_link: https://github.com/apache/skywalking
+latest_release_link: https://skywalking.apache.org/downloads/
+helm_chart_link:
+istio_versions: "1.0.3, 1.0.4, 1.1.0, 1.1.1"
+supported_templates: metric
+logo_link: https://github.com/apache/skywalking-website/raw/master/docs/.vuepress/public/assets/logo.svg
+number_of_entries: 1
+---
+
+<!-- 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. -->
+
+<p>The SkyWalking adapter uses the <code>Istio bypass</code> adapter to collect metrics and make them available to
+<a href="https://skywalking.apache.org/">Apache SkyWalking</a>. SkyWalking provides a topology map and metrics graph
+to visualize the whole mesh.</p>
+
+<p>This adapter supports the <a href="https://istio.io/docs/reference/config/policy-and-telemetry/templates/metric/">metric template</a>.</p>
+
+<p>Follow the <a href="https://github.com/apache/skywalking/blob/master/docs/README.md">official Apache SkyWalking documentation</a>
+and <a href="https://github.com/apache/skywalking-kubernetes">SkyWalking k8s documentation</a> for details on configuring SkyWalking and the Istio bypass adapter.</p>
diff --git a/mock-collector/src/main/proto/service-mesh-probe/service-mesh.proto b/mock-collector/src/main/proto/service-mesh-probe/service-mesh.proto
new file mode 100644
index 0000000..87e0b70
--- /dev/null
+++ b/mock-collector/src/main/proto/service-mesh-probe/service-mesh.proto
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ *
+ */
+
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.skywalking.apm.network.servicemesh";
+
+import "common/common.proto";
+
+service ServiceMeshMetricService {
+ rpc collect(stream ServiceMeshMetric) returns (MeshProbeDownstream) {
+ }
+}
+
+message ServiceMeshMetric {
+ int64 startTime = 1;
+ int64 endTime = 2;
+ string sourceServiceName = 3;
+ int32 sourceServiceId = 4;
+ string sourceServiceInstance = 5;
+ int32 sourceServiceInstanceId = 6;
+ string destServiceName = 7;
+ int32 destServiceId = 8;
+ string destServiceInstance = 9;
+ int32 destServiceInstanceId = 10;
+ string endpoint = 11;
+ int32 latency = 12;
+ int32 responseCode = 13;
+ bool status = 14;
+ Protocol protocol = 15;
+ DetectPoint detectPoint = 16;
+}
+
+enum Protocol {
+ HTTP = 0;
+ gRPC = 1;
+}
+
+message MeshProbeDownstream {
+}
diff --git a/mock-collector/src/main/resources/config.properties b/mock-collector/src/main/resources/config.properties
new file mode 100644
index 0000000..4f290ca
--- /dev/null
+++ b/mock-collector/src/main/resources/config.properties
@@ -0,0 +1,16 @@
+# 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.
+grpc_bind_host=127.0.0.1
+grpc_bind_port=19876
diff --git a/mock-collector/src/main/resources/expect-data.yaml b/mock-collector/src/main/resources/expect-data.yaml
new file mode 100644
index 0000000..ed70818
--- /dev/null
+++ b/mock-collector/src/main/resources/expect-data.yaml
@@ -0,0 +1,78 @@
+# 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.
+expectData:
+ - registryItem:
+ - applications:
+ - test-applicationCode1: nq 0 // the application id of test-applicationCode is 3
+ - test-applicationCode2: nq 0
+ - operationNames:
+ - test-applicationCode1: {testOperationName, testOperationName1} // there are three operation names in test-applicationCode1 has been registery
+ - instances:
+ - test-applicationCode1: eq 3 // test-applicationCode1 has 3 instances
+ - test-applicationCode2: 1 // test-applicationCode2 has 1 instance
+ - heartbeat:
+ - test-applicationCode1: gt 2 // there are 3 instance of test-applicationCode has been send heartbeat
+
+ - segmentsItems:
+ -
+ test-applicationCode: 1 // test-applicationCode has seend 1 segment.
+ segments:
+ -
+ segmentId: not null
+ refs:
+ - parentSpanId: 1
+ - parentTraceSegmentId: ${test-applicationCode2[0]}
+ - networkAddress: xxx
+ - parentServiceId: 1
+ - parentServiceName: not null
+ - networkAddressId: 1
+ - entryServiceId: 1
+ - refType: xx
+ - parentApplicationInstanceId: 1
+ - entryServiceName: xx
+ spans:
+ -
+ operationName: testOperationName
+ parentSpanId: 0
+ spanId: 1
+ spanLayer: HTTP
+ logs:
+ - xx: xx
+ - bb: bb
+ tags:
+ - xx: xx
+ - aa: aa
+ stattime: not empty
+ endtime: not empty
+ componentId: 1
+ componentName:
+ spanType: Entry
+ isError: false
+ -
+ test-applicationCode2: 2
+ segments:
+ -
+ segmentId: not null
+ spans:
+ -
+ operationName: testOperationName
+ parentSpanId: 0
+ spanId: 1
+ spanLayer: HTTP
+ logs:
+ - xx: xx
+ - bb: bb
+ globalSegmentId:
diff --git a/mock-collector/src/main/resources/log4j2.xml b/mock-collector/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..2d11918
--- /dev/null
+++ b/mock-collector/src/main/resources/log4j2.xml
@@ -0,0 +1,30 @@
+<?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.
+ ~
+ -->
+<Configuration status="ERROR">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_ERR">
+ <PatternLayout charset="UTF-8" pattern="[%d{yyyy-MM-dd HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Root level="ERROR">
+ <AppenderRef ref="Console"/>
+ </Root>
+ </Loggers>
+</Configuration>
diff --git a/mock-collector/src/main/resources/sample-data.yaml b/mock-collector/src/main/resources/sample-data.yaml
new file mode 100644
index 0000000..a648290
--- /dev/null
+++ b/mock-collector/src/main/resources/sample-data.yaml
@@ -0,0 +1,68 @@
+# 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.
+#
+validateData:
+ - registryItem:
+ - applications:
+ - test-applicationCode1: 3 // the application id of test-applicationCode is 3
+ - test-applicationCode2: 1
+ - operationNames:
+ - test-applicationCode1: {testOperationName, testOperationName1} // there are three operation names in test-applicationCode1 has been registery
+ - instances:
+ - test-applicationCode1: 3 // test-applicationCode1 has 3 instances
+ - test-applicationCode2: 1 // test-applicationCode2 has 1 instance
+ - heartbeat:
+ - test-applicationCode1: 3 // there are 3 instance of test-applicationCode has been send heartbeat
+
+ - segmentsItems:
+ -
+ test-applicationCode: 1 // test-applicationCode has seend 1 segment.
+ segments:
+ -
+ segmentId: xxxx
+ refs:
+ - parentSpanId: 1
+ - parentTraceSegmentId: ${test-applicationCode2[0]}
+ - networkAddress: xxx
+ - parentServiceId: 1
+ - parentServiceName: not null
+ - networkAddressId: 1
+ - entryServiceId: 1
+ - refType: xx
+ - parentApplicationInstanceId: 1
+ - entryServiceName: xx
+ spans:
+ -
+ operationName: testOperationName
+ parentSpanId: 0
+ spanId: 1
+ spanLayer: HTTP
+ logs:
+ - xx: xx
+ - bb: bb
+ tags:
+ - xx: xx
+ - aa: aa
+ stattime: 141
+ endtime: 141
+ componentId: 1
+ componentName:
+ spanType: Entry
+ isError: false
+ -
+ test-applicationCode2: 2
+ segments:
+ //.....
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..c5abb75
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,179 @@
+<?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">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.skywalking.plugin</groupId>
+ <artifactId>agent-test-tools</artifactId>
+ <version>1.0.0</version>
+
+ <name>SkyWalking Agent Test Tools</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>mock-collector</module>
+ <module>validator</module>
+ </modules>
+
+ <properties>
+ <java.version>1.8</java.version>
+ <maven.compiler.source>${java.version}</maven.compiler.source>
+ <maven.compiler.target>${java.version}</maven.compiler.target>
+
+ <maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+
+ <junit.version>4.11</junit.version>
+ <guava.version>20.0</guava.version>
+ <gson.version>2.8.5</gson.version>
+ <lombok.version>1.18.10</lombok.version>
+ <snakeyaml.version>1.24</snakeyaml.version>
+ <log4j-core.version>2.8.1</log4j-core.version>
+ <grpc.version>1.4.0</grpc.version>
+ <netty.version>4.1.12.Final</netty.version>
+ <jetty.version>9.4.2.v20170220</jetty.version>
+
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>${guava.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <version>${log4j-core.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <version>${log4j-core.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>${lombok.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>${gson.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>${guava.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.yaml</groupId>
+ <artifactId>snakeyaml</artifactId>
+ <version>${snakeyaml.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <version>${log4j-core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <version>${log4j-core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>${lombok.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>${gson.version}</version>
+ </dependency>
+ <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.netty</groupId>
+ <artifactId>netty-codec-http2</artifactId>
+ <version>${netty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-servlet</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${maven-compiler-plugin.version}</version>
+ <configuration>
+ <source>${maven.compiler.source}</source>
+ <target>${maven.compiler.source}</target>
+ <encoding>${project.build.sourceEncoding}</encoding>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/validator/README.md b/validator/README.md
new file mode 100644
index 0000000..c40707b
--- /dev/null
+++ b/validator/README.md
@@ -0,0 +1,36 @@
+# agent-integration-testtool
+The agent-integration-testtool project is used that to validate the different of Skywalking Java Agent generate
+data item between you expect and the actual generate.
+
+## Assert Exceptions
+The following are the exceptions that may occur in the validate tools.
+### Data file
+* [IllegalDataFileException](./docs/exception/IllegalDataFileException.md)
+
+### Registry Item
+#### Application
+* [RegistryInstanceOfApplicationNotFoundException](./docs/exception/RegistryInstanceOfApplicationNotFoundException.md)
+* [RegistryApplicationNotFoundException](./docs/exception/RegistryApplicationNotFoundException.md)
+* [RegistryApplicationSizeNotEqualsException](./docs/exception/RegistryApplicationSizeNotEqualsException.md)
+
+#### Instance
+* [RegistryInstanceOfApplicationNotFoundException](./docs/exception/RegistryInstanceOfApplicationNotFoundException.md)
+* [RegistryInstanceSizeNotEqualsException](./docs/exception/RegistryInstanceSizeNotEqualsException.md)
+* [RegistryInstancesNotEqualsException](./docs/exception/RegistryInstancesNotEqualsException.md)
+
+#### Operation name
+* [ActualRegistryOperationNameEmptyException](./docs/exception/ActualRegistryOperationNameEmptyException.md)
+* [RegistryOperationNameNotFoundException](./docs/exception/RegistryOperationNameNotFoundException.md)
+* [RegistryOperationNamesNotFoundException](./docs/exception/RegistryOperationNamesNotFoundException.md)
+* [RegistryOperationNamesOfApplicationNotFoundException](./docs/exception/RegistryOperationNamesOfApplicationNotFoundException.md)
+
+### Segment
+* [ActualSegmentItemEmptyException](./docs/exception/ActualSegmentItemEmptyException.md)
+* [SegmentItemNotFoundException](./docs/exception/SegmentItemNotFoundException.md)
+* [SegmentNotFoundException](./docs/exception/SegmentNotFoundException.md)
+
+### Segment Ref
+* [SegmentRefNotFoundException](./docs/exception/SegmentRefNotFoundException.md)
+* [ParentSegmentNotFoundException](./docs/exception/ParentSegmentNotFoundException.md)
+* [SegmentRefSizeNotEqualsException](./docs/exception/SegmentRefSizeNotEqualsException.md)
+* [SegmentSizeNotEqualsException](./docs/exception/SegmentSizeNotEqualsException.md)
diff --git a/validator/docs/exception/ActualRegistryOperationNameEmptyException.md b/validator/docs/exception/ActualRegistryOperationNameEmptyException.md
new file mode 100644
index 0000000..5f4c884
--- /dev/null
+++ b/validator/docs/exception/ActualRegistryOperationNameEmptyException.md
@@ -0,0 +1,12 @@
+# ActualRegistryOperationNameEmptyException
+
+## Format
+ActualRegistryOperationNameEmptyException APPLICATION<br/>
+expected: [ OPERATION_NAME_A, OPERATION_NAME_B, ... ]<br/>
+actual: Empty
+
+## Cause
+The `ActualRegistryOperationNameEmptyException` caused by there is any registry operation name in the actual data file
+
+## Check Points
+1. Check if the execute time of entry service of test case more than 40 seconds, Please make it less than 40 seconds.
\ No newline at end of file
diff --git a/validator/docs/exception/ActualSegmentItemEmptyException.md b/validator/docs/exception/ActualSegmentItemEmptyException.md
new file mode 100644
index 0000000..bf3b186
--- /dev/null
+++ b/validator/docs/exception/ActualSegmentItemEmptyException.md
@@ -0,0 +1,15 @@
+# ActualSegmentItemEmptyException
+
+## Format
+ActualSegmentItemEmptyException<br/>
+expected:<br/>
+Segment Item[APPLICATION]<br/>
+ - segment size: EXPECTED_SIZE<br/>
+
+actual: Empty<br/>
+
+## Cause
+The `ActualSegmentItemEmptyException` caused by the segment item is empty in the actual data file
+
+## Check Points
+1. Check if the execute time of entry service of test case more than 40 seconds, Please make it less than 40 seconds.
\ No newline at end of file
diff --git a/validator/docs/exception/IllegalDataFileException.md b/validator/docs/exception/IllegalDataFileException.md
new file mode 100644
index 0000000..1a30dc2
--- /dev/null
+++ b/validator/docs/exception/IllegalDataFileException.md
@@ -0,0 +1,11 @@
+# IllegalDataFileException
+
+## Format
+IllegalDataFileException <FILE_NAME>
+
+## Cause by
+The IllegalDataFileException cause by the data file is an illegal format.
+
+## Check Points
+1. Check the format of data file if the file name is `expectedData.yaml`.
+2. Check the build status of the test case if the file name is `actualData.yaml`. You can get it from the `testcase-build.log` file
diff --git a/validator/docs/exception/ParentSegmentNotFoundException.md b/validator/docs/exception/ParentSegmentNotFoundException.md
new file mode 100644
index 0000000..fcf7559
--- /dev/null
+++ b/validator/docs/exception/ParentSegmentNotFoundException.md
@@ -0,0 +1,24 @@
+# ParentSegmentNotFoundException
+
+## Format
+ParentSegmentNotFoundException<br/>
+expected: PARENT_SEGMENT_EXPRESS<br/>
+actual: NOT FOUND
+
+## Cause
+The `ParentSegmentNotFoundException` caused by the parent segment express cannot found in the actual data file.<br/>
+e.g.,
+expected:
+```
+"refs": [
+ {
+ "parentTraceSegmentId": "${other_application[10]}",
+ ...
+ }
+]
+```
+actual:
+The segment size of `other_application` less than 10
+
+## Check Points
+1. Check if the parent segment express is correct
\ No newline at end of file
diff --git a/validator/docs/exception/RegistryApplicationNotFoundException.md b/validator/docs/exception/RegistryApplicationNotFoundException.md
new file mode 100644
index 0000000..07e57b2
--- /dev/null
+++ b/validator/docs/exception/RegistryApplicationNotFoundException.md
@@ -0,0 +1,27 @@
+# RegistryApplicationNotFoundException
+
+## Format
+RegistryApplicationNotFoundException<br/>
+expected: EXPECTED_SERVICE<br/>
+actual: NOT FOUND
+
+## Cause by
+The `RegistryApplicationNotFoundException` caused by one of application code that you write in the expected data file
+cannot found in the actual data file.
+
+
+## Check points
+1. Check the application code is the value of `agent.service_name` that you configured.
+
+e.g.,
+the application that you write in the expected data file:
+```
+registryItems: {
+ "test_application": {
+ }
+}
+```
+the application of `agent.service_name` that you configured:
+`-Dskywalking.agent.service_name=another_application`
+
+2. Check the agent of someone project in the test case if it works.
\ No newline at end of file
diff --git a/validator/docs/exception/RegistryApplicationSizeNotEqualsException.md b/validator/docs/exception/RegistryApplicationSizeNotEqualsException.md
new file mode 100644
index 0000000..56f0099
--- /dev/null
+++ b/validator/docs/exception/RegistryApplicationSizeNotEqualsException.md
@@ -0,0 +1,13 @@
+# RegistryApplicationSizeNotEqualsException
+
+## Format
+RegistryApplicationSizeNotEqualsException APPLICATION<br/>
+expected: EXPECTED_SIZE<br/>
+actual: ACTUAL_SIZE
+
+## Cause
+The `RegistryApplicationSizeNotEqualsException` caused by the size of the registry application is different between expected and actual.
+
+## Check Points
+1. Check if the size of the registry application that you expected
+2. Check if the `agent.service_name` is duplicated in the test case project
\ No newline at end of file
diff --git a/validator/docs/exception/RegistryInstanceOfApplicationNotFoundException.md b/validator/docs/exception/RegistryInstanceOfApplicationNotFoundException.md
new file mode 100644
index 0000000..23f3d5f
--- /dev/null
+++ b/validator/docs/exception/RegistryInstanceOfApplicationNotFoundException.md
@@ -0,0 +1,25 @@
+# RegistryInstanceOfApplicationNotFoundException
+
+## Format
+RegistryInstanceOfApplicationNotFoundException<br/>
+expected: Instances of Service(APPLICATION)<br/>
+actual: NOT FOUND
+
+## Cause
+The `RegistryApplicationNotFoundException` caused by one of application code that you write in the expected data file
+cannot found in the actual data file.
+
+
+## Check Points
+1. Check the application code is the value of `agent.service_name` that you configured.<br/>
+e.g.,
+the application that you write in the expected data file:
+```
+registryItems: {
+ "test_application": {
+ }
+}
+```
+the application of `agent.service_name` that you configured: `-Dskywalking.agent.service_name=another_application`
+
+2. Check the agent of someone project in the test case if it works.
\ No newline at end of file
diff --git a/validator/docs/exception/RegistryInstanceSizeNotEqualsException.md b/validator/docs/exception/RegistryInstanceSizeNotEqualsException.md
new file mode 100644
index 0000000..19739a9
--- /dev/null
+++ b/validator/docs/exception/RegistryInstanceSizeNotEqualsException.md
@@ -0,0 +1,13 @@
+# RegistryInstanceSizeNotEqualsException
+
+## Format
+RegistryInstanceSizeNotEqualsException APPLICATION<br/>
+expected: EXPECTED_SIZE<br/>
+actual: ACTUAL_SIZE
+
+## Cause
+The `RegistryInstanceSizeNotEqualsException` caused by the size of the registry instance of one application is different between you expected and the actual
+
+## Check Points
+1. Check the size of the registry instance that you expected
+
diff --git a/validator/docs/exception/RegistryInstancesNotEqualsException.md b/validator/docs/exception/RegistryInstancesNotEqualsException.md
new file mode 100644
index 0000000..b52ecb5
--- /dev/null
+++ b/validator/docs/exception/RegistryInstancesNotEqualsException.md
@@ -0,0 +1,12 @@
+# RegistryInstancesNotEqualsException
+
+## Format
+RegistryInstancesNotEqualsException<br/>
+expected: EXPECTED_INSTANCE_SIZE<br/>
+actual: ACTUAL_INSTANCE_SIZE
+
+## Cause by
+The RegistryInstancesNotEqualsException cause by the instance size is different between expected and actual
+
+## Check Points
+1. Check the instance size that your write if it is your expected.
\ No newline at end of file
diff --git a/validator/docs/exception/RegistryOperationNameNotFoundException.md b/validator/docs/exception/RegistryOperationNameNotFoundException.md
new file mode 100644
index 0000000..39ecbfc
--- /dev/null
+++ b/validator/docs/exception/RegistryOperationNameNotFoundException.md
@@ -0,0 +1,13 @@
+# RegistryOperationNameNotFoundException
+
+## Format
+RegistryOperationNameNotFoundException APPLICATION<br/>
+expected: OPERATION_NAME<br/>
+actual: NOT FOUND
+
+## Cause
+The `RegistryOperationNameNotFoundException` caused by the registry operation name that you expected cannot found in the actual data file
+
+## Check Points
+1. Check if the registry operation name that you expected is correct
+2. Check if the instrumentation that it generates the operation name works
\ No newline at end of file
diff --git a/validator/docs/exception/RegistryOperationNamesNotFoundException.md b/validator/docs/exception/RegistryOperationNamesNotFoundException.md
new file mode 100644
index 0000000..13c5764
--- /dev/null
+++ b/validator/docs/exception/RegistryOperationNamesNotFoundException.md
@@ -0,0 +1,13 @@
+# RegistryOperationNamesNotFoundException
+
+## Format
+RegistryOperationNamesNotFoundException <APPLICATION><br/>
+expected: <OPERATION_NAME_1, OPERATION_NAME_2, ....><br/>
+actual: Not Found<br/>
+
+## Cause by
+The RegistryOperationNamesNotFoundException cause by the registry operation names of someone application cannot found
+ in the actual data file.
+
+## Check Points
+1. Check all the instrumentations about test case if it works.
\ No newline at end of file
diff --git a/validator/docs/exception/RegistryOperationNamesOfApplicationNotFoundException.md b/validator/docs/exception/RegistryOperationNamesOfApplicationNotFoundException.md
new file mode 100644
index 0000000..45136e6
--- /dev/null
+++ b/validator/docs/exception/RegistryOperationNamesOfApplicationNotFoundException.md
@@ -0,0 +1,12 @@
+# RegistryOperationNamesOfApplicationNotFoundException
+
+## Format
+RegistryOperationNamesOfApplicationNotFoundException<br/>
+expected: [ OPERATION_NAME_A, OPERATION_NAME_B, ...]<br/>
+actual: NOT FOUND
+
+## Cause
+The `RegistryOperationNamesOfApplicationNotFoundException` caused by the registry operation name of someone application does not exist in the actual data file.
+
+## Check Points
+1. Check if the execute time of entry service of test case more than 40 seconds, Please make it less than 40 seconds.
\ No newline at end of file
diff --git a/validator/docs/exception/SegmentItemNotFoundException.md b/validator/docs/exception/SegmentItemNotFoundException.md
new file mode 100644
index 0000000..2f08dcc
--- /dev/null
+++ b/validator/docs/exception/SegmentItemNotFoundException.md
@@ -0,0 +1,15 @@
+# SegmentItemNotFoundException
+
+## Format
+SegmentItemNotFoundException<br/>
+expected:<br/>
+Segment Item[APPLICATION]<br/>
+ - segment size: EXPECTED_SIZE<br/>
+
+actual: NOT FOUND
+
+## Cause
+The `SegmentItemNotFoundException` caused by the segment item of you expected cannot found in the actual data file
+
+## Check Points
+1. Check if the execute time of entry service of test case more than 40 seconds, Please make it less than 40 seconds.
\ No newline at end of file
diff --git a/validator/docs/exception/SegmentNotFoundException.md b/validator/docs/exception/SegmentNotFoundException.md
new file mode 100644
index 0000000..c3c3e74
--- /dev/null
+++ b/validator/docs/exception/SegmentNotFoundException.md
@@ -0,0 +1,31 @@
+# SegmentNotFoundException
+
+## Format
+SegmentNotFoundException<br/>
+expected<br/>
+Segment:<br/>
+ - span[PARENT_SPAN_ID, SPAN_ID] OPERATION_NAME_A<br/>
+ - span[PARENT_SPAN_ID, SPAN_ID] OPERATION_NAME_B<br/>
+ - ......<br/>
+
+actual:<br/>
+Segment[SEGMENT_ID_A] validate failed:<br/>
+expected: span[PARENT_SPAN_ID, SPAN_ID] OPERATION_NAME<br/>
+actual: span[PARENT_SPAN_ID, SPAN_ID] OPERATION_NAME<br/>
+reason: [SPAN_FIELD] expected=>{EXPECTED_VALUE}, actual=>{ACTUAL_VALUE}<br/>
+
+Segment[SEGMENT_ID_B] validate failed:<br/>
+expected: span[PARENT_SPAN_ID, SPAN_ID] OPERATION_NAME<br/>
+actual: span[PARENT_SPAN_ID, SPAN_ID] OPERATION_NAME<br/>
+reason: [SPAN_FIELD] expected=>{EXPECTED_VALUE}, actual=>{ACTUAL_VALUE}<br/>
+
+......<br/>
+
+**NOTE**: The validate tool validates all similar segment similar to what you expect in the actual data file. The rule that the validate tool to check if the segment similar to what you expect is the span size equals.
+
+## Cause
+The `SegmentNotFoundException` caused by the segment what you expect cannot found in the actual data file.
+
+## Check Points
+1. Check if the span sequence of a segment is right
+2. Check if the field value of the span is right
\ No newline at end of file
diff --git a/validator/docs/exception/SegmentRefNotFoundException.md b/validator/docs/exception/SegmentRefNotFoundException.md
new file mode 100644
index 0000000..cd8e22f
--- /dev/null
+++ b/validator/docs/exception/SegmentRefNotFoundException.md
@@ -0,0 +1,30 @@
+# SegmentRefNotFoundException
+
+## Format
+SegmentRefNotFoundException<br/>
+expected:<br/>
+SegmentRef:<br/>
+ - entryServiceName: ENTRY_SERVICE_NAME<br/>
+ - networkAddress: NETWORK_ADDRESS<br/>
+ - parentServiceName: PARENT_SERVICE_NAME<br/>
+ - parentSpanId: PARENT_SPAN_ID<br/>
+ - parentTraceSegmentId: PARENT_TRACE_SEGMENT_ID<br/>
+ - refType: REF_TYPE<br/>
+
+actual:<br/>
+SegmentRef: [SEGMENT_REF_FIELD] expected=>{EXPECTED_SIZE}, actual=>{ACTUAL_SIZE}<br/>
+ - entryServiceName: ENTRY_SERVICE_NAME<br/>
+ - networkAddress: NETWORK_ADDRESS<br/>
+ - parentServiceName: PARENT_SERVICE_NAME<br/>
+ - parentSpanId: PARENT_SPAN_ID<br/>
+ - parentTraceSegmentId: PARENT_TRACE_SEGMENT_ID<br/>
+ - refType: REF_TYPE<br/>
+......
+
+**NOTE**: The validate tool check all the segment ref of the span.
+
+## Cause
+The `SegmentRefNotFoundException` caused by the segment ref cannot found in the actual data file
+
+## Check Points
+1. Check if the field value of segment ref what you expect is correct
\ No newline at end of file
diff --git a/validator/docs/exception/SegmentRefSizeNotEqualsException.md b/validator/docs/exception/SegmentRefSizeNotEqualsException.md
new file mode 100644
index 0000000..7005df4
--- /dev/null
+++ b/validator/docs/exception/SegmentRefSizeNotEqualsException.md
@@ -0,0 +1,34 @@
+# SegmentRefSizeNotEqualsException
+## Format
+SegmentRefSizeNotEqualsException<br/>
+expected: EXPECTED_SIZE<br/>
+actual: ACUTAL_SIZE
+
+## Cause
+The `SegmentRefSizeNotEqualsException` caused by the size of `refs` is different between you expect and actual.
+
+e.g.,
+expected:
+```
+"refs": [
+ {
+ "parentTraceSegmentId": "${other_application[1]}",
+ ...
+ }
+]
+```
+actual:
+```
+"refs": [
+ {
+ "parentTraceSegmentId": "${other_application[1]}",
+ ...
+ },
+ {
+ "parentTraceSegmentId": "${other_application[2]}",
+ ...
+ }
+]
+```
+## Check Points
+1. Check if the size of segment ref is correct
\ No newline at end of file
diff --git a/validator/docs/exception/SegmentSizeNotEqualsException.md b/validator/docs/exception/SegmentSizeNotEqualsException.md
new file mode 100644
index 0000000..a03868e
--- /dev/null
+++ b/validator/docs/exception/SegmentSizeNotEqualsException.md
@@ -0,0 +1,12 @@
+# SegmentSizeNotEqualsException
+
+## Format
+SegmentSizeNotEqualsException APPLICATION<br/>
+expected: EXPECTED_SIZE<br/>
+actual: ACTUAL_SIZE<br/>
+
+## Cause
+The `SegmentSizeNotEqualsException` caused by the size is different between the size that you expected and the actual's
+
+## Check Points
+1. Check if the size that you expected is right
\ No newline at end of file
diff --git a/validator/pom.xml b/validator/pom.xml
new file mode 100644
index 0000000..9899ac0
--- /dev/null
+++ b/validator/pom.xml
@@ -0,0 +1,74 @@
+<?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">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.skywalking.plugin</groupId>
+ <artifactId>agent-test-tools</artifactId>
+ <version>1.0.0</version>
+ </parent>
+
+ <artifactId>validator</artifactId>
+ <packaging>jar</packaging>
+
+ <name>SkyWalking-Validator</name>
+ <url>http://maven.apache.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.yaml</groupId>
+ <artifactId>snakeyaml</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>validator</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>3.0.0</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <transformers>
+ <transformer
+ implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <mainClass>org.apache.skywalking.plugin.test.agent.tool.Main</mainClass>
+ </transformer>
+ </transformers>
+ <outputFile>../dist/${project.build.finalName}.jar</outputFile>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/ConfigHelper.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/ConfigHelper.java
new file mode 100644
index 0000000..fbe6425
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/ConfigHelper.java
@@ -0,0 +1,32 @@
+/*
+ * 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.plugin.test.agent.tool;
+
+public class ConfigHelper {
+
+ private ConfigHelper() {
+ }
+
+ public static String caseName() {
+ return System.getProperty("caseName", "");
+ }
+
+ public static String testCaseBaseDir() {
+ return System.getProperty("testCasePath", "");
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/Main.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/Main.java
new file mode 100644
index 0000000..2f31015
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/Main.java
@@ -0,0 +1,63 @@
+/*
+ * 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.plugin.test.agent.tool;
+
+import java.io.File;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.DataAssert;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.Data;
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class Main {
+ private static Logger logger = LogManager.getLogger(Main.class);
+
+ public static void main(String[] args) {
+ System.exit(verify() ? 0 : 1);
+ }
+
+ static boolean verify() {
+ File casePath = new File(ConfigHelper.testCaseBaseDir());
+ try {
+ if (!casePath.exists()) {
+ logger.error("test case dir is not exists or is not directory");
+ return false;
+ }
+
+ logger.info("start to assert data of test case[{}]", ConfigHelper.caseName());
+ File actualData = new File(casePath, "actualData.yaml");
+ File expectedData = new File(casePath, "expectedData.yaml");
+
+ if (actualData.exists() && expectedData.exists()) {
+ try {
+ DataAssert.assertEquals(Data.Loader.loadData("expectedData.yaml", expectedData), Data.Loader.loadData("actualData.yaml", actualData));
+ return true;
+ } catch (AssertFailedException e) {
+ logger.error("\nassert failed.\n{}\n", e.getCauseMessage());
+ }
+ } else {
+ logger.error("assert failed. because actual data {} and expected data {}", actualData.exists() ? "founded" : "not founded", expectedData
+ .exists() ? "founded" : "not founded");
+ }
+ } catch (Exception e) {
+ logger.error("assert test case {} failed.", ConfigHelper.caseName(), e);
+ }
+ return false;
+ }
+
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/ApplicationAssert.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/ApplicationAssert.java
new file mode 100644
index 0000000..c59bd6c
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/ApplicationAssert.java
@@ -0,0 +1,53 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor;
+
+import java.util.List;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.RegistryApplicationNotFoundException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.RegistryApplicationSizeNotEqualsException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.ValueAssertFailedException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.RegistryApplication;
+
+public class ApplicationAssert {
+ public static void assertEquals(List<RegistryApplication> expected, List<RegistryApplication> actual) {
+
+ if (expected == null) {
+ return;
+ }
+
+ for (RegistryApplication application : expected) {
+ RegistryApplication actualApplication = getMatchApplication(actual, application);
+ try {
+ ExpressParser.parse(application.expressValue())
+ .assertValue("registry application", actualApplication.expressValue());
+ } catch (ValueAssertFailedException e) {
+ throw new RegistryApplicationSizeNotEqualsException(application.applicationCode(), e);
+ }
+ }
+ }
+
+ private static RegistryApplication getMatchApplication(List<RegistryApplication> actual,
+ RegistryApplication application) {
+ for (RegistryApplication registryApplication : actual) {
+ if (registryApplication.applicationCode().equals(application.applicationCode())) {
+ return registryApplication;
+ }
+ }
+ throw new RegistryApplicationNotFoundException(application.applicationCode());
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/DataAssert.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/DataAssert.java
new file mode 100644
index 0000000..59a4124
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/DataAssert.java
@@ -0,0 +1,35 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor;
+
+import com.google.gson.GsonBuilder;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.Data;
+
+public class DataAssert {
+ private static Logger logger = LogManager.getLogger(DataAssert.class);
+
+ public static void assertEquals(Data excepted, Data actual) {
+ logger.info("excepted data:\n{}", new GsonBuilder().setPrettyPrinting().create().toJson(excepted));
+ logger.info("actual data:\n{}", new GsonBuilder().setPrettyPrinting().create().toJson(actual));
+ RegistryItemsAssert.assertEquals(excepted.registryItems(), actual.registryItems());
+ SegmentItemsAssert.assertEquals(excepted.segmentItems(), actual.segmentItems());
+ logger.info("{} assert successful.", "segment items");
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/ExpressParser.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/ExpressParser.java
new file mode 100644
index 0000000..84ff2d0
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/ExpressParser.java
@@ -0,0 +1,63 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.ElementAssertor;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.EqualsAssertor;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.GreatThanAssertor;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.GreetEqualAssertor;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.NoopAssertor;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.NotEqualsAssertor;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.NotNullAssertor;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.element.NullAssertor;
+
+public class ExpressParser {
+ public static ElementAssertor parse(String express) {
+ if (express == null) {
+ return new NoopAssertor();
+ }
+
+ String expressTrim = express.trim();
+ if (expressTrim.equals("not null")) {
+ return new NotNullAssertor();
+ }
+
+ if (expressTrim.equals("null")) {
+ return new NullAssertor();
+ }
+
+ String[] expressSegment = expressTrim.split(" ");
+ if (expressSegment.length == 1) {
+ return new EqualsAssertor(expressSegment[0]);
+ } else if (expressSegment.length == 2) {
+ String exceptedValue = expressSegment[1];
+ switch (expressSegment[0].trim()) {
+ case "nq":
+ return new NotEqualsAssertor(exceptedValue);
+ case "eq":
+ return new EqualsAssertor(exceptedValue);
+ case "gt":
+ return new GreatThanAssertor(exceptedValue);
+ case "ge":
+ return new GreetEqualAssertor(exceptedValue);
+ }
+ }
+
+ return new EqualsAssertor(express);
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/InstanceAssert.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/InstanceAssert.java
new file mode 100644
index 0000000..c4af5e6
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/InstanceAssert.java
@@ -0,0 +1,53 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor;
+
+import java.util.List;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.RegistryInstanceOfApplicationNotFoundException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.RegistryInstanceSizeNotEqualsException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.ValueAssertFailedException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.RegistryInstance;
+
+public class InstanceAssert {
+ public static void assertEquals(List<RegistryInstance> expected, List<RegistryInstance> actual) {
+
+ if (expected == null) {
+ return;
+ }
+
+ for (RegistryInstance instance : expected) {
+ RegistryInstance actualInstance = getMatchApplication(actual, instance);
+ try {
+ ExpressParser.parse(actualInstance.expressValue())
+ .assertValue(String.format("The registry instance of %s", instance.applicationCode()), actualInstance
+ .expressValue());
+ } catch (ValueAssertFailedException e) {
+ throw new RegistryInstanceSizeNotEqualsException(instance.applicationCode(), e);
+ }
+ }
+ }
+
+ private static RegistryInstance getMatchApplication(List<RegistryInstance> actual, RegistryInstance application) {
+ for (RegistryInstance registryApplication : actual) {
+ if (registryApplication.applicationCode().equals(application.applicationCode())) {
+ return registryApplication;
+ }
+ }
+ throw new RegistryInstanceOfApplicationNotFoundException(application.applicationCode());
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/OperationNameAssert.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/OperationNameAssert.java
new file mode 100644
index 0000000..cb21391
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/OperationNameAssert.java
@@ -0,0 +1,62 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor;
+
+import java.util.List;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.ActualRegistryOperationNameEmptyException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.RegistryOperationNameNotFoundException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.RegistryOperationNamesOfApplicationNotFoundException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.RegistryOperationName;
+
+public class OperationNameAssert {
+ public static void assertEquals(List<RegistryOperationName> expected, List<RegistryOperationName> actual) {
+ if (expected == null) {
+ return;
+ }
+
+ for (RegistryOperationName operationName : expected) {
+ RegistryOperationName actualOperationName = findActualRegistryOperationName(actual, operationName);
+ assertOperationEquals(actualOperationName.applicationCode(), operationName.operationName(), actualOperationName
+ .operationName());
+ }
+ }
+
+ private static void assertOperationEquals(String applicationCode, List<String> expectedOperationName,
+ List<String> actualOperationName) {
+ for (String operationName : expectedOperationName) {
+ if (!actualOperationName.contains(operationName)) {
+ throw new RegistryOperationNameNotFoundException(applicationCode, operationName);
+ }
+ }
+ }
+
+ private static RegistryOperationName findActualRegistryOperationName(List<RegistryOperationName> actual,
+ RegistryOperationName registryOperationName) {
+ if (actual == null) {
+ throw new ActualRegistryOperationNameEmptyException(registryOperationName);
+ }
+
+ for (RegistryOperationName operationName : actual) {
+ if (operationName.applicationCode().equals(registryOperationName.applicationCode())) {
+ return operationName;
+ }
+ }
+
+ throw new RegistryOperationNamesOfApplicationNotFoundException(registryOperationName);
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/ParentSegmentIdExpressParser.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/ParentSegmentIdExpressParser.java
new file mode 100644
index 0000000..d6a71cb
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/ParentSegmentIdExpressParser.java
@@ -0,0 +1,47 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor;
+
+import java.util.List;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.ParentSegmentNotFoundException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.SegmentItem;
+
+public class ParentSegmentIdExpressParser {
+ public static String parse(String express, List<SegmentItem> actual) {
+ if (!express.trim().startsWith("${") && !express.trim().endsWith("}")) {
+ return express;
+ }
+
+ String parentSegmentExpress = express.trim().substring(2, express.trim().length() - 1);
+
+ int startIndexOfIndex = parentSegmentExpress.indexOf("[");
+ String applicationCode = parentSegmentExpress.substring(0, startIndexOfIndex);
+ int endIndexOfIndex = parentSegmentExpress.indexOf("]", startIndexOfIndex);
+ int expectedSize = Integer.parseInt(parentSegmentExpress.substring(startIndexOfIndex + 1, endIndexOfIndex));
+ for (SegmentItem segmentItem : actual) {
+ if (segmentItem.applicationCode().equals(applicationCode)) {
+ if (segmentItem.segments().size() <= expectedSize) {
+ throw new ParentSegmentNotFoundException(parentSegmentExpress);
+ }
+
+ return segmentItem.segments().get(expectedSize).segmentId();
+ }
+ }
+ return express;
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/RegistryItemsAssert.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/RegistryItemsAssert.java
new file mode 100644
index 0000000..5c5e791
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/RegistryItemsAssert.java
@@ -0,0 +1,35 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.RegistryItems;
+
+public class RegistryItemsAssert {
+ private static Logger logger = LogManager.getLogger(RegistryItemsAssert.class);
+
+ public static void assertEquals(RegistryItems excepted, RegistryItems actual) {
+ ApplicationAssert.assertEquals(excepted.applications(), actual.applications());
+ logger.info("{} assert successful.", "registry applications");
+ InstanceAssert.assertEquals(excepted.instances(), actual.instances());
+ logger.info("{} assert successful.", "registry instances");
+ OperationNameAssert.assertEquals(excepted.operationNames(), actual.operationNames());
+ logger.info("{} assert successful.", "registry operation name");
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/SegmentAssert.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/SegmentAssert.java
new file mode 100644
index 0000000..1c50b58
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/SegmentAssert.java
@@ -0,0 +1,224 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.ActualSegmentRefIsEmptyException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.KeyValueNotEqualsException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.LogEventKeyNotEqualsException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.LogEventSizeNotEqualsException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.LogEventValueNotEqualsException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.LogSizeNotEqualsException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.RefSizeNotEqualsException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.SegmentNotFoundException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.SegmentRefAssertFailedException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.SegmentRefNotFoundException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.SpanAssertFailedException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.SpanSizeNotEqualsException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.TagKeyNotEqualsException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.TagSizeNotEqualsException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.TagValueNotEqualsException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.ValueAssertFailedException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.KeyValuePair;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.LogEvent;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.Segment;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.SegmentItem;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.SegmentRef;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.Span;
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class SegmentAssert {
+ public static void assertEquals(SegmentItem expected, SegmentItem actual) {
+ if (expected.segments() == null) {
+ return;
+ }
+
+ for (Segment segment : expected.segments()) {
+ Segment actualSegment = findSegment(actual, segment);
+ segment.setSegmentId(actualSegment.segmentId());
+ }
+ }
+
+ private static Segment findSegment(SegmentItem actual, Segment expectedSegment) {
+ List<SegmentPredictionFailedCause> exceptions = new ArrayList<>();
+ for (Segment actualSegment : actual.segments()) {
+ try {
+ if (spansEquals(expectedSegment.spans(), actualSegment.spans())) {
+ return actualSegment;
+ }
+ } catch (SpanSizeNotEqualsException e) {
+ } catch (SpanAssertFailedException e) {
+ exceptions.add(new SegmentPredictionFailedCause(e, actualSegment));
+ }
+ }
+
+ throw new SegmentNotFoundException(expectedSegment, exceptions);
+ }
+
+ private static boolean spansEquals(List<Span> excepted, List<Span> actual) {
+ if (excepted == null) {
+ return true;
+ }
+
+ if (actual == null || excepted.size() != actual.size()) {
+ throw new SpanSizeNotEqualsException(excepted.size(), (actual != null) ? actual.size() : 0);
+ }
+
+ int equalSpans = 0;
+ for (int index = 0; index < excepted.size(); index++, equalSpans++) {
+ Span exceptedSpan = excepted.get(index);
+ Span actualSpan = actual.get(index);
+ try {
+ spanEquals(exceptedSpan, actualSpan);
+ } catch (AssertFailedException e) {
+ throw new SpanAssertFailedException(e, exceptedSpan, actualSpan);
+ }
+ }
+
+ return true;
+ }
+
+ private static void spanEquals(Span excepted, Span actualSpan) {
+ ExpressParser.parse(excepted.operationName()).assertValue("operation name", actualSpan.operationName());
+ ExpressParser.parse(excepted.componentId()).assertValue("component id", actualSpan.componentId());
+ ExpressParser.parse(excepted.componentName()).assertValue("component name", actualSpan.componentName());
+ ExpressParser.parse(excepted.startTime()).assertValue("start time", actualSpan.startTime());
+ ExpressParser.parse(excepted.endTime()).assertValue("end time", actualSpan.endTime());
+ ExpressParser.parse(excepted.parentSpanId()).assertValue("parent span id", actualSpan.parentSpanId());
+ ExpressParser.parse(excepted.spanId()).assertValue("span id", actualSpan.spanId());
+ ExpressParser.parse(excepted.operationId()).assertValue("operation id", actualSpan.operationId());
+ ExpressParser.parse(excepted.peer()).assertValue("peer", actualSpan.peer());
+ ExpressParser.parse(excepted.spanLayer()).assertValue("span layer", actualSpan.spanLayer());
+ ExpressParser.parse(excepted.peerId()).assertValue("peer id", actualSpan.peerId());
+ ExpressParser.parse(excepted.error()).assertValue("is error", actualSpan.error());
+ ExpressParser.parse(excepted.spanType()).assertValue("span type", actualSpan.spanType());
+ tagsEquals(excepted.tags(), actualSpan.tags());
+ logsEquals(excepted.logs(), actualSpan.logs());
+ refEquals(excepted.refs(), actualSpan.refs());
+ excepted.setActualRefs(actualSpan.refs());
+
+ }
+
+ private static void refEquals(List<SegmentRef> excepted, List<SegmentRef> actual) {
+ if (excepted == null) {
+ return;
+ }
+
+ if (actual == null) {
+ throw new ActualSegmentRefIsEmptyException(excepted.size());
+ }
+
+ if (excepted.size() != actual.size()) {
+ throw new RefSizeNotEqualsException(excepted.size(), actual.size());
+ }
+
+ for (SegmentRef ref : excepted) {
+ findSegmentRef(actual, ref);
+ }
+ }
+
+ private static void tagsEquals(List<KeyValuePair> excepted, List<KeyValuePair> actual) {
+ if (excepted.size() != actual.size()) {
+ throw new TagSizeNotEqualsException(excepted.size(), actual.size());
+ }
+
+ for (int index = 0; index < excepted.size(); index++) {
+ tagEquals(excepted.get(index), actual.get(index));
+ }
+ }
+
+ private static void logsEquals(List<LogEvent> excepted, List<LogEvent> actual) {
+ if (excepted.size() != actual.size()) {
+ throw new LogSizeNotEqualsException(excepted.size(), actual.size());
+ }
+
+ for (int index = 0; index < excepted.size(); index++) {
+ logEventEquals(excepted.get(index), actual.get(index));
+ }
+
+ }
+
+ private static void logEventEquals(LogEvent exceptedEvent, LogEvent actualEvent) {
+ List<KeyValuePair> exceptedKey = exceptedEvent.events();
+ List<KeyValuePair> actualKey = actualEvent.events();
+
+ if (exceptedKey.size() != actualKey.size()) {
+ throw new LogEventSizeNotEqualsException(exceptedKey.size(), actualKey.size());
+ }
+
+ for (int index = 0; index < exceptedKey.size(); index++) {
+ logEventPairEquals(exceptedKey.get(index), actualKey.get(index));
+ }
+ }
+
+ private static void keyValuePairEquals(KeyValuePair excepted, KeyValuePair actual) {
+ if (!excepted.key().equals(actual.key())) {
+ throw new KeyValueNotEqualsException();
+ }
+
+ ExpressParser.parse(excepted.value()).assertValue("", actual.value());
+ }
+
+ private static void logEventPairEquals(KeyValuePair excepted, KeyValuePair actual) {
+ try {
+ keyValuePairEquals(excepted, actual);
+ } catch (KeyValueNotEqualsException e) {
+ throw new LogEventKeyNotEqualsException(excepted.key(), actual.key());
+ } catch (ValueAssertFailedException e) {
+ throw new LogEventValueNotEqualsException(excepted.key(), excepted.value(), actual.value());
+ }
+ }
+
+ private static void tagEquals(KeyValuePair excepted, KeyValuePair actual) {
+ try {
+ keyValuePairEquals(excepted, actual);
+ } catch (KeyValueNotEqualsException e) {
+ throw new TagKeyNotEqualsException(excepted.key(), actual.key());
+ } catch (ValueAssertFailedException e) {
+ throw new TagValueNotEqualsException(excepted.key(), excepted.value(), actual.value());
+ }
+ }
+
+ private static SegmentRef findSegmentRef(List<SegmentRef> actual, SegmentRef expected) {
+ List<SegmentRefAssertFailedCause> causes = new ArrayList<>();
+ for (SegmentRef segmentRef : actual) {
+ try {
+ if (simpleSegmentRefEquals(expected, segmentRef)) {
+ return segmentRef;
+ }
+ } catch (SegmentRefAssertFailedException e) {
+ causes.add(new SegmentRefAssertFailedCause(e, segmentRef));
+ }
+ }
+ throw new SegmentRefNotFoundException(expected, causes);
+ }
+
+ private static boolean simpleSegmentRefEquals(SegmentRef expected, SegmentRef actual) {
+ try {
+ ExpressParser.parse(expected.entryEndpointName())
+ .assertValue("entry service name", actual.entryEndpointName());
+ ExpressParser.parse(expected.parentEndpointName())
+ .assertValue("parent service name", actual.parentEndpointName());
+ ExpressParser.parse(expected.refType()).assertValue("ref type", actual.refType());
+ return true;
+ } catch (ValueAssertFailedException e) {
+ throw new SegmentRefAssertFailedException(e, expected, actual);
+ }
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/SegmentItemsAssert.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/SegmentItemsAssert.java
new file mode 100644
index 0000000..2a32b3e
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/SegmentItemsAssert.java
@@ -0,0 +1,102 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor;
+
+import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.ActualSegmentItemEmptyException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.SegmentItemNotFoundException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.SegmentSizeNotEqualsException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.ValueAssertFailedException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.Segment;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.SegmentItem;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.SegmentRef;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.Span;
+
+public class SegmentItemsAssert {
+ private static Logger logger = LogManager.getLogger(SegmentItemsAssert.class);
+
+ public static void assertEquals(List<SegmentItem> expected, List<SegmentItem> actual) {
+ if (expected == null) {
+ logger.info("ignore segment items. because expected segment item is null.");
+ return;
+ }
+
+ for (SegmentItem item : expected) {
+ SegmentItem actualSegmentItem = findSegmentItem(actual, item);
+ try {
+ assertSegmentSize(item.segmentSize(), actualSegmentItem.segmentSize());
+ } catch (ValueAssertFailedException e) {
+ throw new SegmentSizeNotEqualsException(item.applicationCode(), item.segmentSize(), actualSegmentItem.segmentSize());
+ }
+ SegmentAssert.assertEquals(item, actualSegmentItem);
+ }
+
+ for (SegmentItem item : expected) {
+ if (item.segments() == null) {
+ continue;
+ }
+
+ for (Segment segment : item.segments()) {
+ convertParentSegmentId(segment, expected);
+
+ for (Span span : segment.spans()) {
+ if (span.refs() == null || span.refs().size() == 0) {
+ continue;
+ }
+ SegmentRefAssert.assertEquals(span.refs(), span.actualRefs());
+ }
+ }
+ }
+ }
+
+ private static void convertParentSegmentId(Segment segment, List<SegmentItem> actual) {
+ for (Span span : segment.spans()) {
+ if (span.refs() == null || span.refs().size() == 0) {
+ continue;
+ }
+
+ for (SegmentRef ref : span.refs()) {
+ String actualParentSegmentId = ParentSegmentIdExpressParser.parse(ref.parentTraceSegmentId(), actual);
+ ref.parentTraceSegmentId(actualParentSegmentId);
+ }
+ }
+ }
+
+ private static void assertSegmentSize(String expected, String actual) {
+ if (expected == null) {
+ return;
+ }
+ ExpressParser.parse(expected).assertValue("segment size", actual);
+ }
+
+ private static SegmentItem findSegmentItem(List<SegmentItem> actual, SegmentItem expected) {
+ if (actual == null) {
+ throw new ActualSegmentItemEmptyException(expected);
+ }
+
+ for (SegmentItem segmentItem : actual) {
+ if (expected.applicationCode().equals(segmentItem.applicationCode())) {
+ return segmentItem;
+ }
+ }
+
+ throw new SegmentItemNotFoundException(expected.applicationCode());
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/SegmentPredictionFailedCause.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/SegmentPredictionFailedCause.java
new file mode 100644
index 0000000..9fa3efd
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/SegmentPredictionFailedCause.java
@@ -0,0 +1,39 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.SpanAssertFailedException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.Segment;
+
+public class SegmentPredictionFailedCause {
+ private final Segment actualSegment;
+ private final SpanAssertFailedException spanAssertFailedCause;
+
+ public SegmentPredictionFailedCause(SpanAssertFailedException spanAssertFailedCause, Segment actualSegment) {
+ this.spanAssertFailedCause = spanAssertFailedCause;
+ this.actualSegment = actualSegment;
+ }
+
+ public Segment getActualSegment() {
+ return actualSegment;
+ }
+
+ public SpanAssertFailedException getSpanAssertFailedCause() {
+ return spanAssertFailedCause;
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/SegmentRefAssert.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/SegmentRefAssert.java
new file mode 100644
index 0000000..7e6b2d6
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/SegmentRefAssert.java
@@ -0,0 +1,83 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.SegmentRefAssertFailedException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.SegmentRefNotFoundException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.SegmentRefSizeNotEqualsException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.ValueAssertFailedException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.SegmentRef;
+
+public class SegmentRefAssert {
+
+ public static void assertEquals(List<SegmentRef> excepted, List<SegmentRef> actual) {
+ if (excepted == null) {
+ return;
+ }
+
+ if (actual == null || excepted.size() != actual.size()) {
+ throw new SegmentRefSizeNotEqualsException(excepted.size(), actual.size());
+ }
+
+ for (SegmentRef ref : excepted) {
+ findSegmentRef(actual, ref);
+ }
+ }
+
+ private static SegmentRef findSegmentRef(List<SegmentRef> actual, SegmentRef expected) {
+ List<SegmentRefAssertFailedCause> causes = new ArrayList<>();
+ for (SegmentRef segmentRef : actual) {
+ try {
+ if (segmentRefEquals(expected, segmentRef)) {
+ return segmentRef;
+ }
+ } catch (SegmentRefAssertFailedException e) {
+ causes.add(new SegmentRefAssertFailedCause(e, segmentRef));
+ }
+ }
+ throw new SegmentRefNotFoundException(expected, causes);
+ }
+
+ private static boolean segmentRefEquals(SegmentRef expected, SegmentRef actual) {
+ try {
+ ExpressParser.parse(expected.entryEndpointName())
+ .assertValue("entry endpoint name", actual.entryEndpointName());
+ ExpressParser.parse(expected.networkAddress()).assertValue("network address", actual.networkAddress());
+ ExpressParser.parse(expected.parentTraceSegmentId())
+ .assertValue("parent segment id", actual.parentTraceSegmentId());
+ ExpressParser.parse(expected.parentSpanId()).assertValue("span id", actual.parentSpanId());
+ ExpressParser.parse(expected.entryEndpointId()).assertValue("entry endpoint id", actual.entryEndpointId());
+ ExpressParser.parse(expected.networkAddressId())
+ .assertValue("network address id", actual.networkAddressId());
+ ExpressParser.parse(expected.parentServiceInstanceId())
+ .assertValue("parent application instance id", actual.parentServiceInstanceId());
+ ExpressParser.parse(expected.parentEndpointId())
+ .assertValue("parent endpoint id", actual.parentEndpointId());
+ ExpressParser.parse(expected.parentEndpointName())
+ .assertValue("parent endpoint name", actual.parentEndpointName());
+ ExpressParser.parse(expected.refType()).assertValue("ref type", actual.refType());
+ ExpressParser.parse(expected.entryServiceInstanceId())
+ .assertValue("entry application instance id", actual.entryServiceInstanceId());
+ return true;
+ } catch (ValueAssertFailedException e) {
+ throw new SegmentRefAssertFailedException(e, expected, actual);
+ }
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/SegmentRefAssertFailedCause.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/SegmentRefAssertFailedCause.java
new file mode 100644
index 0000000..571a4c8
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/SegmentRefAssertFailedCause.java
@@ -0,0 +1,39 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.SegmentRefAssertFailedException;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.SegmentRef;
+
+public class SegmentRefAssertFailedCause {
+ private final SegmentRefAssertFailedException failedCause;
+ private final SegmentRef actual;
+
+ public SegmentRefAssertFailedCause(SegmentRefAssertFailedException failedCause, SegmentRef actual) {
+ this.failedCause = failedCause;
+ this.actual = actual;
+ }
+
+ public SegmentRefAssertFailedException getFailedCause() {
+ return failedCause;
+ }
+
+ public SegmentRef getActual() {
+ return actual;
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/ElementAssertor.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/ElementAssertor.java
new file mode 100644
index 0000000..452fe8f
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/ElementAssertor.java
@@ -0,0 +1,31 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.element;
+
+public abstract class ElementAssertor {
+
+ public ElementAssertor(String exceptedValue) {
+ if (exceptedValue != null) {
+ this.exceptedValue = exceptedValue.trim();
+ }
+ }
+
+ protected String exceptedValue;
+
+ public abstract void assertValue(String desc, String actualValue);
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/EqualsAssertor.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/EqualsAssertor.java
new file mode 100644
index 0000000..c7cd568
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/EqualsAssertor.java
@@ -0,0 +1,34 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.element;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.ValueAssertFailedException;
+
+public class EqualsAssertor extends ElementAssertor {
+
+ public EqualsAssertor(String exceptedValue) {
+ super(exceptedValue);
+ }
+
+ @Override
+ public void assertValue(String desc, String actualValue) {
+ if (!exceptedValue.equals(actualValue)) {
+ throw new ValueAssertFailedException(desc, exceptedValue, actualValue);
+ }
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/GreatThanAssertor.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/GreatThanAssertor.java
new file mode 100644
index 0000000..ca2fecd
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/GreatThanAssertor.java
@@ -0,0 +1,34 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.element;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.ValueAssertFailedException;
+
+public class GreatThanAssertor extends ElementAssertor {
+
+ public GreatThanAssertor(String exceptedValue) {
+ super(exceptedValue);
+ }
+
+ @Override
+ public void assertValue(String desc, String actualValue) {
+ if (Long.parseLong(actualValue) <= Long.parseLong(exceptedValue)) {
+ throw new ValueAssertFailedException(desc, " gt " + exceptedValue, actualValue);
+ }
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/GreetEqualAssertor.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/GreetEqualAssertor.java
new file mode 100644
index 0000000..8c97fd6
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/GreetEqualAssertor.java
@@ -0,0 +1,34 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.element;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.ValueAssertFailedException;
+
+public class GreetEqualAssertor extends ElementAssertor {
+ public GreetEqualAssertor(String exceptedValue) {
+ super(exceptedValue);
+ }
+
+ @Override
+ public void assertValue(String desc, String actualValue) {
+ if (Long.parseLong(actualValue) < Long.parseLong(exceptedValue)) {
+ throw new ValueAssertFailedException(desc, " ge " + exceptedValue, actualValue);
+ }
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/NoopAssertor.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/NoopAssertor.java
new file mode 100644
index 0000000..bcec8f6
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/NoopAssertor.java
@@ -0,0 +1,29 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.element;
+
+public class NoopAssertor extends ElementAssertor {
+ public NoopAssertor() {
+ super(null);
+ }
+
+ @Override
+ public void assertValue(String desc, String actualValue) {
+
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/NotEqualsAssertor.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/NotEqualsAssertor.java
new file mode 100644
index 0000000..9f85d76
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/NotEqualsAssertor.java
@@ -0,0 +1,34 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.element;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.ValueAssertFailedException;
+
+public class NotEqualsAssertor extends ElementAssertor {
+
+ public NotEqualsAssertor(String exceptedValue) {
+ super(exceptedValue);
+ }
+
+ @Override
+ public void assertValue(String desc, String actualValue) {
+ if (exceptedValue.equals(actualValue.trim())) {
+ throw new ValueAssertFailedException(desc, " not eq " + exceptedValue, actualValue);
+ }
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/NotNullAssertor.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/NotNullAssertor.java
new file mode 100644
index 0000000..dcc5f2d
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/NotNullAssertor.java
@@ -0,0 +1,33 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.element;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.ValueAssertFailedException;
+
+public class NotNullAssertor extends ElementAssertor {
+ public NotNullAssertor() {
+ super(null);
+ }
+
+ @Override
+ public void assertValue(String desc, String actualValue) {
+ if (actualValue == null) {
+ throw new ValueAssertFailedException(desc, "not null", actualValue);
+ }
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/NullAssertor.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/NullAssertor.java
new file mode 100644
index 0000000..b30c3fa
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/element/NullAssertor.java
@@ -0,0 +1,33 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.element;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.ValueAssertFailedException;
+
+public class NullAssertor extends ElementAssertor {
+ public NullAssertor() {
+ super(null);
+ }
+
+ @Override
+ public void assertValue(String desc, String actualValue) {
+ if (actualValue != null && actualValue.length() > 0) {
+ throw new ValueAssertFailedException(desc, "null", actualValue);
+ }
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/ActualRegistryOperationNameEmptyException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/ActualRegistryOperationNameEmptyException.java
new file mode 100644
index 0000000..6600b63
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/ActualRegistryOperationNameEmptyException.java
@@ -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.
+ */
+
+package org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.RegistryOperationName;
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class ActualRegistryOperationNameEmptyException extends AssertFailedException {
+
+ private final RegistryOperationName registryOperationName;
+
+ public ActualRegistryOperationNameEmptyException(RegistryOperationName registryOperationName) {
+ this.registryOperationName = registryOperationName;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("ActualRegistryOperationNameEmptyException\nexpected:%s\nactual:%s\n", registryOperationName
+ .operationName(), "Empty");
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/ActualSegmentItemEmptyException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/ActualSegmentItemEmptyException.java
new file mode 100644
index 0000000..4ce4c53
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/ActualSegmentItemEmptyException.java
@@ -0,0 +1,35 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.SegmentItem;
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class ActualSegmentItemEmptyException extends AssertFailedException {
+
+ private final SegmentItem expected;
+
+ public ActualSegmentItemEmptyException(SegmentItem expected) {
+ this.expected = expected;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("ActualSegmentItemEmptyException\nexpected: %s\nactual: %s", expected, "Empty");
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/ActualSegmentRefIsEmptyException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/ActualSegmentRefIsEmptyException.java
new file mode 100644
index 0000000..23a5566
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/ActualSegmentRefIsEmptyException.java
@@ -0,0 +1,33 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class ActualSegmentRefIsEmptyException extends AssertFailedException {
+ private final int expectedSize;
+
+ public ActualSegmentRefIsEmptyException(int expectedSize) {
+ this.expectedSize = expectedSize;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("ActualSegmentRefIsEmptyException\nexpected: %d\nactual: %s\n", expectedSize, "Not found");
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/KeyValueNotEqualsException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/KeyValueNotEqualsException.java
new file mode 100644
index 0000000..e3eb65f
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/KeyValueNotEqualsException.java
@@ -0,0 +1,21 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+public class KeyValueNotEqualsException extends RuntimeException {
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/LogEventKeyNotEqualsException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/LogEventKeyNotEqualsException.java
new file mode 100644
index 0000000..c649c96
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/LogEventKeyNotEqualsException.java
@@ -0,0 +1,35 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class LogEventKeyNotEqualsException extends AssertFailedException {
+ private final String expected;
+ private final String actual;
+
+ public LogEventKeyNotEqualsException(String expected, String actual) {
+ this.expected = expected;
+ this.actual = actual;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("[log event key]: expected=>{%s}, actual=>{%s}\n", expected, actual);
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/LogEventSizeNotEqualsException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/LogEventSizeNotEqualsException.java
new file mode 100644
index 0000000..e79bb89
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/LogEventSizeNotEqualsException.java
@@ -0,0 +1,35 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class LogEventSizeNotEqualsException extends AssertFailedException {
+ private final int expected;
+ private final int actual;
+
+ public LogEventSizeNotEqualsException(int expected, int actual) {
+ this.expected = expected;
+ this.actual = actual;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("[log event size]: expected=>{%d}, actual=>{%d}\n", expected, actual);
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/LogEventValueNotEqualsException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/LogEventValueNotEqualsException.java
new file mode 100644
index 0000000..407b27c
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/LogEventValueNotEqualsException.java
@@ -0,0 +1,37 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class LogEventValueNotEqualsException extends AssertFailedException {
+ private final String eventKey;
+ private final String expected;
+ private final String actual;
+
+ public LogEventValueNotEqualsException(String eventKey, String expected, String actual) {
+ this.eventKey = eventKey;
+ this.expected = expected;
+ this.actual = actual;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("[log(%s} value]: expected=>{%s}, actual=>{%s}\n", eventKey, expected, actual);
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/LogSizeNotEqualsException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/LogSizeNotEqualsException.java
new file mode 100644
index 0000000..73f1573
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/LogSizeNotEqualsException.java
@@ -0,0 +1,35 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class LogSizeNotEqualsException extends AssertFailedException {
+ private final int expected;
+ private final int actual;
+
+ public LogSizeNotEqualsException(int expected, int actual) {
+ this.expected = expected;
+ this.actual = actual;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("[log size]: expected=>{%d}, actual=>{%d}", expected, actual);
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/ParentSegmentNotFoundException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/ParentSegmentNotFoundException.java
new file mode 100644
index 0000000..dc59c13
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/ParentSegmentNotFoundException.java
@@ -0,0 +1,34 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class ParentSegmentNotFoundException extends AssertFailedException {
+
+ private final String express;
+
+ public ParentSegmentNotFoundException(String express) {
+ this.express = express;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("ParentSegmentNotFoundException\nexpected: %s\nactual: %s\n", express, "NOT FOUND");
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/RefSizeNotEqualsException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/RefSizeNotEqualsException.java
new file mode 100644
index 0000000..c7a2c7b
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/RefSizeNotEqualsException.java
@@ -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.
+ */
+
+package org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class RefSizeNotEqualsException extends AssertFailedException {
+
+ private final int expected;
+ private final int actual;
+
+ public RefSizeNotEqualsException(int expected, int actual) {
+ this.expected = expected;
+ this.actual = actual;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("[segment ref size]: expected=>{%s}, actual=>{%s}", expected, actual);
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/RegistryApplicationNotFoundException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/RegistryApplicationNotFoundException.java
new file mode 100644
index 0000000..449207c
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/RegistryApplicationNotFoundException.java
@@ -0,0 +1,33 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class RegistryApplicationNotFoundException extends AssertFailedException {
+ private final String applicationCode;
+
+ public RegistryApplicationNotFoundException(String applicationCode) {
+ this.applicationCode = applicationCode;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("RegistryApplicationNotFoundException\nexpected: %s\nactual: %s\n", applicationCode, "Not Found");
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/RegistryApplicationSizeNotEqualsException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/RegistryApplicationSizeNotEqualsException.java
new file mode 100644
index 0000000..b6e17ee
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/RegistryApplicationSizeNotEqualsException.java
@@ -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.
+ */
+
+package org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class RegistryApplicationSizeNotEqualsException extends AssertFailedException {
+ private final String applicationCode;
+ private final ValueAssertFailedException cause;
+
+ public RegistryApplicationSizeNotEqualsException(String applicationCode, ValueAssertFailedException cause) {
+ this.applicationCode = applicationCode;
+ this.cause = cause;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("RegistryApplicationSizeNotEqualsException: %s\nexpected: %s\nactual: %s\n", applicationCode, cause
+ .getExpected(), cause.getActual());
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/RegistryInstanceOfApplicationNotFoundException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/RegistryInstanceOfApplicationNotFoundException.java
new file mode 100644
index 0000000..ba41bd1
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/RegistryInstanceOfApplicationNotFoundException.java
@@ -0,0 +1,34 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class RegistryInstanceOfApplicationNotFoundException extends AssertFailedException {
+
+ private final String applicationCode;
+
+ public RegistryInstanceOfApplicationNotFoundException(String applicationCode) {
+ this.applicationCode = applicationCode;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("RegistryInstanceOfApplicationNotFoundException\nexpected: Instances of Service(%s)" + "\nactual: %s\n", applicationCode, "NOT FOUND");
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/RegistryInstanceSizeNotEqualsException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/RegistryInstanceSizeNotEqualsException.java
new file mode 100644
index 0000000..283e72a
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/RegistryInstanceSizeNotEqualsException.java
@@ -0,0 +1,37 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class RegistryInstanceSizeNotEqualsException extends AssertFailedException {
+
+ private final String applicationCode;
+ private final ValueAssertFailedException cause;
+
+ public RegistryInstanceSizeNotEqualsException(String applicationCode, ValueAssertFailedException cause) {
+ this.applicationCode = applicationCode;
+ this.cause = cause;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("RegistryInstanceSizeNotEqualsException %s\nexpected: %s\nactual: %s\n", applicationCode, cause
+ .getExpected(), cause.getActual());
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/RegistryOperationNameNotFoundException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/RegistryOperationNameNotFoundException.java
new file mode 100644
index 0000000..1cf2ec7
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/RegistryOperationNameNotFoundException.java
@@ -0,0 +1,35 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class RegistryOperationNameNotFoundException extends AssertFailedException {
+ private final String applicationCode;
+ private final String operationName;
+
+ public RegistryOperationNameNotFoundException(String applicationCode, String operationName) {
+ this.applicationCode = applicationCode;
+ this.operationName = operationName;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("RegistryOperationNameNotFoundException %s\nexpected: %s\nactual: %s\n", applicationCode, operationName, "NOT FOUND");
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/RegistryOperationNamesOfApplicationNotFoundException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/RegistryOperationNamesOfApplicationNotFoundException.java
new file mode 100644
index 0000000..98f6c82
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/RegistryOperationNamesOfApplicationNotFoundException.java
@@ -0,0 +1,35 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.RegistryOperationName;
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class RegistryOperationNamesOfApplicationNotFoundException extends AssertFailedException {
+ private final RegistryOperationName applicationCode;
+
+ public RegistryOperationNamesOfApplicationNotFoundException(RegistryOperationName applicationCode) {
+ this.applicationCode = applicationCode;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("RegistryOperationNamesOfApplicationNotFoundException %s\nexpected: %s\nactual: %s\n", applicationCode
+ .applicationCode(), applicationCode.operationName(), "NOT FOUND");
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SegmentItemNotFoundException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SegmentItemNotFoundException.java
new file mode 100644
index 0000000..038fd41
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SegmentItemNotFoundException.java
@@ -0,0 +1,33 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class SegmentItemNotFoundException extends AssertFailedException {
+ private final String applicationCode;
+
+ public SegmentItemNotFoundException(String applicationCode) {
+ this.applicationCode = applicationCode;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("SegmentItemNotFoundException\nexpected: %s\nactual: %s", applicationCode, "Not Found");
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SegmentNotFoundException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SegmentNotFoundException.java
new file mode 100644
index 0000000..28ba9db
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SegmentNotFoundException.java
@@ -0,0 +1,56 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import java.util.List;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.SegmentPredictionFailedCause;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.Segment;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.Span;
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class SegmentNotFoundException extends AssertFailedException {
+ private final Segment expectedSegment;
+ private final List<SegmentPredictionFailedCause> failedCauses;
+
+ public SegmentNotFoundException(Segment expectedSegment, List<SegmentPredictionFailedCause> failedCauses) {
+ this.expectedSegment = expectedSegment;
+ this.failedCauses = failedCauses;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ StringBuilder expectedMessage = new StringBuilder("\n Segment:\n");
+ for (Span span : expectedSegment.spans()) {
+ expectedMessage.append(String.format(" - span[%s, %s] %s\n", span.parentSpanId(), span.spanId(), span.operationName()));
+ }
+
+ StringBuilder causeMessage = new StringBuilder();
+ for (SegmentPredictionFailedCause cause : failedCauses) {
+ Segment actualSegment = cause.getActualSegment();
+ Span actualSpan = cause.getSpanAssertFailedCause().getActualSpan();
+ Span expectedSpan = cause.getSpanAssertFailedCause().getExceptedSpan();
+
+ causeMessage.append(String.format("\n Segment[%s] e\n expected:\tSpan[%s, %s] %s\n " + "actual:" + "\tspan[%s, %s] %s\n reason:\t%s\n", actualSegment
+ .segmentId(), expectedSpan.parentSpanId(), expectedSpan.spanId(), expectedSpan.operationName(), actualSpan
+ .parentSpanId(), actualSpan.spanId(), actualSpan.operationName(), cause.getSpanAssertFailedCause()
+ .getCauseMessage()));
+ }
+
+ return String.format("SegmentNotFoundException:\nexpected: %s\nactual: %s\n", expectedMessage, causeMessage);
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SegmentRefAssertFailedException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SegmentRefAssertFailedException.java
new file mode 100644
index 0000000..f616190
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SegmentRefAssertFailedException.java
@@ -0,0 +1,38 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.SegmentRef;
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class SegmentRefAssertFailedException extends AssertFailedException {
+ private final ValueAssertFailedException e;
+ private final SegmentRef expected;
+ private final SegmentRef actual;
+
+ public SegmentRefAssertFailedException(ValueAssertFailedException e, SegmentRef expected, SegmentRef actual) {
+ this.e = e;
+ this.expected = expected;
+ this.actual = actual;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return e.getCauseMessage();
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SegmentRefNotFoundException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SegmentRefNotFoundException.java
new file mode 100644
index 0000000..49f4e1f
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SegmentRefNotFoundException.java
@@ -0,0 +1,56 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import java.util.List;
+import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.SegmentRefAssertFailedCause;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.SegmentRef;
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class SegmentRefNotFoundException extends AssertFailedException {
+ private final SegmentRef expected;
+ private final List<SegmentRefAssertFailedCause> causes;
+
+ public SegmentRefNotFoundException(SegmentRef expected, List<SegmentRefAssertFailedCause> causes) {
+ this.expected = expected;
+ this.causes = causes;
+ }
+
+ @Override
+ public String getCauseMessage() {
+
+ StringBuilder actualMessage = new StringBuilder();
+ for (SegmentRefAssertFailedCause cause : causes) {
+ SegmentRef actual = cause.getActual();
+ String reason = cause.getFailedCause().getCauseMessage();
+
+ StringBuilder actualSegmentRef = new StringBuilder(String.format("\nSegmentRef:\t%s\n", reason));
+ actualSegmentRef.append(String.format(" - entryServiceName:\t\t%s\n", actual.entryEndpointName()))
+ .append(String.format(" - networkAddress:\t\t\t%s\n", actual.networkAddress()))
+ .append(String.format(" - parentServiceName:\t\t%s\n", actual.parentEndpointName()))
+ .append(String.format(" - parentSpanId:\t\t\t%s\n", actual.parentSpanId()))
+ .append(String.format(" - parentTraceSegmentId:\t%s\n", actual.parentTraceSegmentId()))
+ .append(String.format(" - refType:\t\t\t\t\t%s", actual.refType()))
+ .toString();
+
+ actualMessage.append(String.format("%s\n", actualSegmentRef));
+ }
+
+ return String.format("SegmentRefNotFoundException\nexpected: %s\nactual: %s\n", expected, actualMessage);
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SegmentRefSizeNotEqualsException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SegmentRefSizeNotEqualsException.java
new file mode 100644
index 0000000..fa57496
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SegmentRefSizeNotEqualsException.java
@@ -0,0 +1,35 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class SegmentRefSizeNotEqualsException extends AssertFailedException {
+ private final int expected;
+ private final int actual;
+
+ public SegmentRefSizeNotEqualsException(int expected, int actual) {
+ this.expected = expected;
+ this.actual = actual;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("SegmentRefSizeNotEqualsException\nexpected:\t%s\nactual:\t%s\n", expected, actual);
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SegmentSizeNotEqualsException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SegmentSizeNotEqualsException.java
new file mode 100644
index 0000000..6ec8e56
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SegmentSizeNotEqualsException.java
@@ -0,0 +1,37 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class SegmentSizeNotEqualsException extends AssertFailedException {
+ private final String applicationCode;
+ private final String expected;
+ private final String actual;
+
+ public SegmentSizeNotEqualsException(String applicationCode, String expected, String actual) {
+ this.applicationCode = applicationCode;
+ this.expected = expected;
+ this.actual = actual;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("SegmentSizeNotEqualsException:\t%s\nexpected:\t%s\nactual:\t\t%s\n", applicationCode, expected, actual);
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SpanAssertFailedException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SpanAssertFailedException.java
new file mode 100644
index 0000000..e5ae437
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SpanAssertFailedException.java
@@ -0,0 +1,46 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.Span;
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class SpanAssertFailedException extends AssertFailedException {
+ private final AssertFailedException failedCause;
+ private final Span exceptedSpan;
+ private final Span actualSpan;
+
+ public SpanAssertFailedException(AssertFailedException failedCause, Span exceptedSpan, Span actualSpan) {
+ this.failedCause = failedCause;
+ this.exceptedSpan = exceptedSpan;
+ this.actualSpan = actualSpan;
+ }
+
+ public Span getExceptedSpan() {
+ return exceptedSpan;
+ }
+
+ public Span getActualSpan() {
+ return actualSpan;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return failedCause.getCauseMessage();
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SpanSizeNotEqualsException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SpanSizeNotEqualsException.java
new file mode 100644
index 0000000..702ab45
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/SpanSizeNotEqualsException.java
@@ -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.
+ */
+
+package org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class SpanSizeNotEqualsException extends AssertFailedException {
+
+ private final int expected;
+ private final int actual;
+
+ public SpanSizeNotEqualsException(int expected, int actual) {
+ this.expected = expected;
+ this.actual = actual;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("[span size]: expected=>{%s}, actual=>{%s}\n", expected, actual);
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/TagKeyNotEqualsException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/TagKeyNotEqualsException.java
new file mode 100644
index 0000000..8eef92d
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/TagKeyNotEqualsException.java
@@ -0,0 +1,35 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class TagKeyNotEqualsException extends AssertFailedException {
+ private final String expected;
+ private final String actual;
+
+ public TagKeyNotEqualsException(String expected, String actual) {
+ this.expected = expected;
+ this.actual = actual;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("[tag key]: expected=>{%s}, actual=>{%s}\n", expected, actual);
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/TagSizeNotEqualsException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/TagSizeNotEqualsException.java
new file mode 100644
index 0000000..b09e6bf
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/TagSizeNotEqualsException.java
@@ -0,0 +1,35 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class TagSizeNotEqualsException extends AssertFailedException {
+ private final int expected;
+ private final int actual;
+
+ public TagSizeNotEqualsException(int expected, int actual) {
+ this.expected = expected;
+ this.actual = actual;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("[tag size]: expected=>{%s}, actual=>{%s}\n", expected, actual);
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/TagValueNotEqualsException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/TagValueNotEqualsException.java
new file mode 100644
index 0000000..6c8d41f
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/TagValueNotEqualsException.java
@@ -0,0 +1,37 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class TagValueNotEqualsException extends AssertFailedException {
+ private final String tagKey;
+ private final String expected;
+ private final String actual;
+
+ public TagValueNotEqualsException(String tagKey, String expected, String actual) {
+ this.tagKey = tagKey;
+ this.expected = expected;
+ this.actual = actual;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("[tag(%s) value]: expected=>{}, actual=>{%s}\n", tagKey, expected, actual);
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/ValueAssertFailedException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/ValueAssertFailedException.java
new file mode 100644
index 0000000..7f7d120
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/exception/ValueAssertFailedException.java
@@ -0,0 +1,49 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor.exception;
+
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+
+public class ValueAssertFailedException extends AssertFailedException {
+ private final String desc;
+ private final String expected;
+ private final String actual;
+
+ public ValueAssertFailedException(String desc, String expected, String actual) {
+ this.desc = desc;
+ this.expected = expected;
+ this.actual = actual;
+ }
+
+ public String getDesc() {
+ return desc;
+ }
+
+ public String getExpected() {
+ return expected;
+ }
+
+ public String getActual() {
+ return actual;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("[%s]: expected=>{%s}, actual=>{%s}", desc, expected, actual);
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/Data.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/Data.java
new file mode 100644
index 0000000..c43f71a
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/Data.java
@@ -0,0 +1,60 @@
+/*
+ * 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.plugin.test.agent.tool.validator.entity;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.List;
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.IllegalDataFileException;
+import org.yaml.snakeyaml.TypeDescription;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.representer.Representer;
+
+public interface Data {
+ RegistryItems registryItems();
+
+ List<SegmentItem> segmentItems();
+
+ class Loader {
+ public static Data loadData(String fileName, File file) {
+ try {
+ return loadData(new FileInputStream(file));
+ } catch (Exception e) {
+ throw new IllegalDataFileException(fileName);
+ }
+ }
+
+ public static Data loadData(InputStream inputStream) {
+ Constructor constructor = new Constructor(DataForRead.class);
+ TypeDescription configDescription = new TypeDescription(DataForRead.class);
+ configDescription.putListPropertyType("data", DataForRead.class);
+
+ Representer representer = new Representer();
+ representer.getPropertyUtils().setSkipMissingProperties(true);
+ Yaml yaml = new Yaml(constructor, representer);
+ Data result = yaml.loadAs(inputStream, DataForRead.class);
+ if (result == null) {
+ throw new RuntimeException();
+ } else {
+ return result;
+ }
+ }
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/DataForRead.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/DataForRead.java
new file mode 100644
index 0000000..b235279
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/DataForRead.java
@@ -0,0 +1,57 @@
+/*
+ * 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.plugin.test.agent.tool.validator.entity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class DataForRead implements Data {
+ private RegistryItemsForRead registryItems;
+ private List<SegmentItemForRead> segmentItems;
+
+ public void setRegistryItems(RegistryItemsForRead registryItems) {
+ this.registryItems = registryItems;
+ }
+
+ public RegistryItemsForRead getRegistryItems() {
+ return registryItems;
+ }
+
+ public List<SegmentItemForRead> getSegmentItems() {
+ return segmentItems;
+ }
+
+ public void setSegmentItems(List<SegmentItemForRead> segmentItems) {
+ this.segmentItems = segmentItems;
+ }
+
+ @Override
+ public RegistryItemsForRead registryItems() {
+ return registryItems;
+ }
+
+ @Override
+ public List<SegmentItem> segmentItems() {
+ if (this.segmentItems == null) {
+ return null;
+ }
+
+ return new ArrayList<>(this.segmentItems);
+ }
+
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/KeyValuePair.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/KeyValuePair.java
new file mode 100644
index 0000000..8032baa
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/KeyValuePair.java
@@ -0,0 +1,44 @@
+/*
+ * 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.plugin.test.agent.tool.validator.entity;
+
+public interface KeyValuePair {
+ String key();
+
+ String value();
+
+ class Impl implements KeyValuePair {
+ private String key;
+ private String value;
+
+ public Impl(String key, String value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ @Override
+ public String key() {
+ return key;
+ }
+
+ @Override
+ public String value() {
+ return value;
+ }
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/LogEvent.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/LogEvent.java
new file mode 100644
index 0000000..f4158f7
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/LogEvent.java
@@ -0,0 +1,42 @@
+/*
+ * 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.plugin.test.agent.tool.validator.entity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public interface LogEvent {
+ List<KeyValuePair> events();
+
+ class Impl implements LogEvent {
+ private List<KeyValuePair> keyValuePairs;
+
+ Impl() {
+ keyValuePairs = new ArrayList<>();
+ }
+
+ void add(String key, String value) {
+ keyValuePairs.add(new KeyValuePair.Impl(key, value));
+ }
+
+ @Override
+ public List<KeyValuePair> events() {
+ return keyValuePairs;
+ }
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/RegistryApplication.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/RegistryApplication.java
new file mode 100644
index 0000000..760fa70
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/RegistryApplication.java
@@ -0,0 +1,44 @@
+/*
+ * 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.plugin.test.agent.tool.validator.entity;
+
+public interface RegistryApplication {
+ String applicationCode();
+
+ String expressValue();
+
+ class Impl implements RegistryApplication {
+ private String applicationCode;
+ private String express;
+
+ Impl(String code, String express) {
+ this.applicationCode = code;
+ this.express = express;
+ }
+
+ @Override
+ public String applicationCode() {
+ return applicationCode;
+ }
+
+ @Override
+ public String expressValue() {
+ return express;
+ }
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/RegistryInstance.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/RegistryInstance.java
new file mode 100644
index 0000000..766fdf0
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/RegistryInstance.java
@@ -0,0 +1,46 @@
+/*
+ * 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.plugin.test.agent.tool.validator.entity;
+
+public interface RegistryInstance {
+
+ String applicationCode();
+
+ String expressValue();
+
+ class Impl implements RegistryInstance {
+
+ private final String code;
+ private final String express;
+
+ Impl(String code, String express) {
+ this.code = code;
+ this.express = express;
+ }
+
+ @Override
+ public String applicationCode() {
+ return code;
+ }
+
+ @Override
+ public String expressValue() {
+ return express;
+ }
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/RegistryItems.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/RegistryItems.java
new file mode 100644
index 0000000..279f41a
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/RegistryItems.java
@@ -0,0 +1,28 @@
+/*
+ * 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.plugin.test.agent.tool.validator.entity;
+
+import java.util.List;
+
+public interface RegistryItems {
+ List<RegistryApplication> applications();
+
+ List<RegistryInstance> instances();
+
+ List<RegistryOperationName> operationNames();
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/RegistryItemsForRead.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/RegistryItemsForRead.java
new file mode 100644
index 0000000..ccc906d
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/RegistryItemsForRead.java
@@ -0,0 +1,97 @@
+/*
+ * 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.plugin.test.agent.tool.validator.entity;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class RegistryItemsForRead implements RegistryItems {
+ private List<Map<String, String>> applications;
+ private List<Map<String, String>> instances;
+ private List<Map<String, List<String>>> operationNames;
+
+ public List<Map<String, String>> getApplications() {
+ return applications;
+ }
+
+ public void setApplications(List<Map<String, String>> applications) {
+ this.applications = applications;
+ }
+
+ public List<Map<String, String>> getInstances() {
+ return instances;
+ }
+
+ public void setInstances(List<Map<String, String>> instances) {
+ this.instances = instances;
+ }
+
+ public List<Map<String, List<String>>> getOperationNames() {
+ return operationNames;
+ }
+
+ public void setOperationNames(List<Map<String, List<String>>> operationNames) {
+ this.operationNames = operationNames;
+ }
+
+ @Override
+ public List<RegistryApplication> applications() {
+ if (this.applications == null) {
+ return null;
+ }
+
+ List<RegistryApplication> registryApplications = new ArrayList<>();
+ for (Map<String, String> registryApplication : applications) {
+ String applicationCode = new ArrayList<String>(registryApplication.keySet()).get(0);
+ String express = String.valueOf(registryApplication.get(applicationCode));
+ registryApplications.add(new RegistryApplication.Impl(applicationCode, express));
+ }
+ return registryApplications;
+ }
+
+ @Override
+ public List<RegistryInstance> instances() {
+ if (this.instances == null) {
+ return null;
+ }
+
+ List<RegistryInstance> registryInstances = new ArrayList<>();
+ instances.forEach((registryInstance) -> {
+ String applicationCode = new ArrayList<String>(registryInstance.keySet()).get(0);
+ String express = String.valueOf(registryInstance.get(applicationCode));
+ registryInstances.add(new RegistryInstance.Impl(applicationCode, express));
+ });
+ return registryInstances;
+ }
+
+ @Override
+ public List<RegistryOperationName> operationNames() {
+ if (this.operationNames == null) {
+ return null;
+ }
+
+ List<RegistryOperationName> registryOperationNames = new ArrayList<>();
+ operationNames.forEach((registryInstance) -> {
+ String applicationCode = new ArrayList<String>(registryInstance.keySet()).get(0);
+ List<String> express = registryInstance.get(applicationCode);
+ registryOperationNames.add(new RegistryOperationName.Impl(applicationCode, express));
+ });
+ return registryOperationNames;
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/RegistryOperationName.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/RegistryOperationName.java
new file mode 100644
index 0000000..3f09557
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/RegistryOperationName.java
@@ -0,0 +1,46 @@
+/*
+ * 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.plugin.test.agent.tool.validator.entity;
+
+import java.util.List;
+
+public interface RegistryOperationName {
+ String applicationCode();
+
+ List<String> operationName();
+
+ class Impl implements RegistryOperationName {
+ private final String code;
+ private final List<String> express;
+
+ Impl(String code, List<String> express) {
+ this.code = code;
+ this.express = express;
+ }
+
+ @Override
+ public String applicationCode() {
+ return code;
+ }
+
+ @Override
+ public List<String> operationName() {
+ return express;
+ }
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/Segment.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/Segment.java
new file mode 100644
index 0000000..6f42e22
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/Segment.java
@@ -0,0 +1,28 @@
+/*
+ * 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.plugin.test.agent.tool.validator.entity;
+
+import java.util.List;
+
+public interface Segment {
+ String segmentId();
+
+ List<Span> spans();
+
+ void setSegmentId(String segmentId);
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/SegmentForRead.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/SegmentForRead.java
new file mode 100644
index 0000000..3fb7681
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/SegmentForRead.java
@@ -0,0 +1,420 @@
+/*
+ * 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.plugin.test.agent.tool.validator.entity;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class SegmentForRead implements Segment {
+ private String segmentId;
+ private List<SpanForRead> spans;
+
+ @Override
+ public String segmentId() {
+ return segmentId;
+ }
+
+ @Override
+ public List<Span> spans() {
+ if (spans == null) {
+ return null;
+ }
+ return new ArrayList<>(spans);
+ }
+
+ public static class SegmentRefForRead implements SegmentRef {
+ private String parentEndpointId;
+ private String parentEndpoint;
+ private String networkAddressId;
+ private String entryEndpointId;
+ private String refType;
+ private String parentSpanId;
+ private String parentTraceSegmentId;
+ private String parentServiceInstanceId;
+ private String networkAddress;
+ private String entryEndpoint;
+ private String entryServiceInstanceId;
+
+ public SegmentRefForRead() {
+ }
+
+ public SegmentRefForRead(Map<String, Object> ref) {
+ this.networkAddress = ref.get("networkAddress").toString();
+ this.entryEndpoint = ref.get("entryEndpoint").toString();
+ this.parentEndpoint = ref.get("parentEndpoint").toString();
+ this.parentTraceSegmentId = ref.get("parentTraceSegmentId").toString();
+ this.entryServiceInstanceId = ref.get("entryServiceInstanceId").toString();
+ this.refType = ref.get("refType") == null ? null : ref.get("refType").toString();
+ this.parentSpanId = ref.get("parentSpanId") == null ? null : ref.get("parentSpanId").toString();
+ this.entryEndpointId = ref.get("entryEndpointId") == null ? null : ref.get("entryEndpointId").toString();
+ this.parentEndpointId = ref.get("parentEndpointId") == null ? null : ref.get("parentEndpointId").toString();
+ this.networkAddressId = ref.get("networkAddressId") == null ? null : ref.get("networkAddressId").toString();
+ this.parentServiceInstanceId = ref.get("parentServiceInstanceId") == null ? null : ref.get("parentServiceInstanceId")
+ .toString();
+ }
+
+ public void setParentEndpointId(String parentEndpointId) {
+ this.parentEndpointId = parentEndpointId;
+ }
+
+ public void setParentEndpoint(String parentEndpoint) {
+ this.parentEndpoint = parentEndpoint;
+ }
+
+ public void setNetworkAddressId(String networkAddressId) {
+ this.networkAddressId = networkAddressId;
+ }
+
+ public void setEntryEndpointId(String entryEndpointId) {
+ this.entryEndpointId = entryEndpointId;
+ }
+
+ public void setRefType(String refType) {
+ this.refType = refType;
+ }
+
+ public void setParentSpanId(String parentSpanId) {
+ this.parentSpanId = parentSpanId;
+ }
+
+ public void setParentTraceSegmentId(String parentTraceSegmentId) {
+ this.parentTraceSegmentId = parentTraceSegmentId;
+ }
+
+ public void setParentServiceInstanceId(String parentServiceInstanceId) {
+ this.parentServiceInstanceId = parentServiceInstanceId;
+ }
+
+ public void setNetworkAddress(String networkAddress) {
+ this.networkAddress = networkAddress;
+ }
+
+ public void setEntryEndpoint(String entryEndpoint) {
+ this.entryEndpoint = entryEndpoint;
+ }
+
+ public void setEntryServiceInstanceId(String entryServiceInstanceId) {
+ this.entryServiceInstanceId = entryServiceInstanceId;
+ }
+
+ @Override
+ public String parentEndpointId() {
+ return parentEndpointId;
+ }
+
+ @Override
+ public String parentEndpointName() {
+ return parentEndpoint;
+ }
+
+ @Override
+ public String networkAddressId() {
+ return networkAddressId;
+ }
+
+ @Override
+ public String entryEndpointId() {
+ return entryEndpointId;
+ }
+
+ @Override
+ public String refType() {
+ return refType;
+ }
+
+ @Override
+ public String parentSpanId() {
+ return parentSpanId;
+ }
+
+ @Override
+ public String parentTraceSegmentId() {
+ return parentTraceSegmentId;
+ }
+
+ @Override
+ public String parentServiceInstanceId() {
+ return parentServiceInstanceId;
+ }
+
+ @Override
+ public String networkAddress() {
+ return networkAddress;
+ }
+
+ @Override
+ public String entryEndpointName() {
+ return entryEndpoint;
+ }
+
+ @Override
+ public void parentTraceSegmentId(String parentTraceSegmentId) {
+ this.parentTraceSegmentId = parentTraceSegmentId;
+ }
+
+ @Override
+ public String entryServiceInstanceId() {
+ return entryServiceInstanceId;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder actualSegmentRef = new StringBuilder("\nSegmentRef:\n");
+ return actualSegmentRef.append(String.format(" - entryServiceName:\t\t%s\n", entryEndpointName()))
+ .append(String.format(" - networkAddress:\t\t\t%s\n", networkAddress()))
+ .append(String.format(" - parentServiceName:\t\t%s\n", parentEndpointName()))
+ .append(String.format(" - parentSpanId:\t\t\t%s\n", parentSpanId()))
+ .append(String.format(" - parentTraceSegmentId:\t%s\n", parentTraceSegmentId()))
+ .append(String.format(" - refType:\t\t\t\t\t%s", refType()))
+ .toString();
+ }
+ }
+
+ public static class SpanForRead implements Span {
+ private String operationName;
+ private String operationId;
+ private String parentSpanId;
+ private String spanId;
+ private String spanLayer;
+ private List<Map<String, String>> tags;
+ private List<Map<String, List<Map<String, String>>>> logs;
+ private List<Map<String, Object>> refs;
+ private List<SegmentRef> formatedRefs;
+ private List<SegmentRef> actualRefs;
+ private String startTime;
+ private String endTime;
+ private String componentId;
+ private String componentName;
+ private String isError;
+ private String spanType;
+ private String peer;
+ private String peerId;
+
+ public void setOperationName(String operationName) {
+ this.operationName = operationName;
+ }
+
+ public void setOperationId(String operationId) {
+ this.operationId = operationId;
+ }
+
+ public void setParentSpanId(String parentSpanId) {
+ this.parentSpanId = parentSpanId;
+ }
+
+ public void setSpanId(String spanId) {
+ this.spanId = spanId;
+ }
+
+ public void setSpanLayer(String spanLayer) {
+ this.spanLayer = spanLayer;
+ }
+
+ public void setTags(List<Map<String, String>> tags) {
+ this.tags = tags;
+ }
+
+ public void setLogs(List<Map<String, List<Map<String, String>>>> logs) {
+ this.logs = logs;
+ }
+
+ public void setStartTime(String startTime) {
+ this.startTime = startTime;
+ }
+
+ public void setEndTime(String endTime) {
+ this.endTime = endTime;
+ }
+
+ public void setComponentId(String componentId) {
+ this.componentId = componentId;
+ }
+
+ public void setComponentName(String componentName) {
+ this.componentName = componentName;
+ }
+
+ public void setError(String error) {
+ isError = error;
+ }
+
+ public void setSpanType(String spanType) {
+ this.spanType = spanType;
+ }
+
+ public void setPeer(String peer) {
+ this.peer = peer;
+ }
+
+ public void setPeerId(String peerId) {
+ this.peerId = peerId;
+ }
+
+ public void setRefs(List<Map<String, Object>> refs) {
+ this.refs = refs;
+ }
+
+ @Override
+ public String operationName() {
+ return operationName;
+ }
+
+ @Override
+ public String operationId() {
+ return operationId;
+ }
+
+ @Override
+ public String parentSpanId() {
+ return parentSpanId;
+ }
+
+ @Override
+ public String spanId() {
+ return spanId;
+ }
+
+ @Override
+ public String spanLayer() {
+ return spanLayer;
+ }
+
+ @Override
+ public List<KeyValuePair> tags() {
+ if (tags == null) {
+ return new ArrayList<>();
+ }
+ List<KeyValuePair> result = new ArrayList<>();
+ for (Map<String, String> tag : tags) {
+ result.add(new KeyValuePair.Impl(tag.get("key"), tag.get("value")));
+ }
+ return result;
+ }
+
+ @Override
+ public List<LogEvent> logs() {
+ if (logs == null) {
+ return new ArrayList<>();
+ }
+ List<LogEvent> result = new ArrayList<>();
+ for (Map<String, List<Map<String, String>>> log : logs) {
+ List<Map<String, String>> events = log.get("logEvent");
+ LogEvent.Impl logEvent = new LogEvent.Impl();
+ for (Map<String, String> event : events) {
+ logEvent.add(event.get("key"), event.get("value"));
+ }
+ result.add(logEvent);
+ }
+
+ return result;
+ }
+
+ @Override
+ public String startTime() {
+ return startTime;
+ }
+
+ @Override
+ public String endTime() {
+ return endTime;
+ }
+
+ @Override
+ public String componentId() {
+ return componentId;
+ }
+
+ @Override
+ public String componentName() {
+ return componentName;
+ }
+
+ @Override
+ public String error() {
+ return isError;
+ }
+
+ @Override
+ public String spanType() {
+ return spanType;
+ }
+
+ @Override
+ public String peer() {
+ return peer;
+ }
+
+ @Override
+ public String peerId() {
+ return peerId;
+ }
+
+ @Override
+ public List<SegmentRef> refs() {
+ if (formatedRefs == null && refs != null) {
+ List<SegmentRef> segmentRefs = new ArrayList<>();
+ for (Map<String, Object> ref : refs) {
+ segmentRefs.add(new SegmentRefForRead(ref));
+ }
+
+ this.formatedRefs = segmentRefs;
+ }
+ return formatedRefs;
+ }
+
+ @Override
+ public void setActualRefs(List<SegmentRef> refs) {
+ this.actualRefs = refs;
+ }
+
+ @Override
+ public List<SegmentRef> actualRefs() {
+ return actualRefs;
+ }
+ }
+
+ public static class LogEventForRead {
+ private List<Map<String, String>> logEvent;
+
+ public List<Map<String, String>> getLogEvent() {
+ return logEvent;
+ }
+
+ public void setLogEvent(List<Map<String, String>> logEvent) {
+ this.logEvent = logEvent;
+ }
+ }
+
+ public String getSegmentId() {
+ return segmentId;
+ }
+
+ public List<SpanForRead> getSpans() {
+ return spans;
+ }
+
+ @Override
+ public void setSegmentId(String segmentId) {
+ this.segmentId = segmentId;
+ }
+
+ public void setSpans(List<SpanForRead> spans) {
+ this.spans = spans;
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/SegmentItem.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/SegmentItem.java
new file mode 100644
index 0000000..8a4a4b6
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/SegmentItem.java
@@ -0,0 +1,28 @@
+/*
+ * 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.plugin.test.agent.tool.validator.entity;
+
+import java.util.List;
+
+public interface SegmentItem {
+ String applicationCode();
+
+ String segmentSize();
+
+ List<Segment> segments();
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/SegmentItemForRead.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/SegmentItemForRead.java
new file mode 100644
index 0000000..5f1b4bf
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/SegmentItemForRead.java
@@ -0,0 +1,76 @@
+/*
+ * 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.plugin.test.agent.tool.validator.entity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class SegmentItemForRead implements SegmentItem {
+ private String applicationCode;
+ private String segmentSize;
+ private List<SegmentForRead> segments;
+
+ public List<SegmentForRead> getSegments() {
+ return segments;
+ }
+
+ public void setSegments(List<SegmentForRead> segments) {
+ this.segments = segments;
+ }
+
+ public String getApplicationCode() {
+ return applicationCode;
+ }
+
+ public void setApplicationCode(String applicationCode) {
+ this.applicationCode = applicationCode;
+ }
+
+ public String getSegmentSize() {
+ return segmentSize;
+ }
+
+ public void setSegmentSize(String segmentSize) {
+ this.segmentSize = segmentSize;
+ }
+
+ @Override
+ public String applicationCode() {
+ return applicationCode;
+ }
+
+ @Override
+ public String segmentSize() {
+ return segmentSize;
+ }
+
+ @Override
+ public List<Segment> segments() {
+ if (segments == null) {
+ return null;
+ }
+ return new ArrayList<>(segments);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder message = new StringBuilder(String.format("\nSegment Item[%s]", applicationCode));
+ message.append(String.format(" - segment size:\t\t%s\n", segmentSize));
+ return message.toString();
+ }
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/SegmentRef.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/SegmentRef.java
new file mode 100644
index 0000000..77cf0b7
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/SegmentRef.java
@@ -0,0 +1,45 @@
+/*
+ * 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.plugin.test.agent.tool.validator.entity;
+
+public interface SegmentRef {
+
+ String parentEndpointId();
+
+ String parentEndpointName();
+
+ String networkAddressId();
+
+ String entryEndpointId();
+
+ String refType();
+
+ String parentSpanId();
+
+ String parentTraceSegmentId();
+
+ String parentServiceInstanceId();
+
+ String networkAddress();
+
+ String entryEndpointName();
+
+ void parentTraceSegmentId(String parentTraceSegmentId);
+
+ String entryServiceInstanceId();
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/Span.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/Span.java
new file mode 100644
index 0000000..ea1bc99
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/entity/Span.java
@@ -0,0 +1,58 @@
+/*
+ * 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.plugin.test.agent.tool.validator.entity;
+
+import java.util.List;
+
+public interface Span {
+ String operationName();
+
+ String operationId();
+
+ String parentSpanId();
+
+ String spanId();
+
+ String spanLayer();
+
+ List<KeyValuePair> tags();
+
+ List<LogEvent> logs();
+
+ String startTime();
+
+ String endTime();
+
+ String componentId();
+
+ String componentName();
+
+ String error();
+
+ String spanType();
+
+ String peer();
+
+ String peerId();
+
+ List<SegmentRef> refs();
+
+ void setActualRefs(List<SegmentRef> refs);
+
+ List<SegmentRef> actualRefs();
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/exception/AssertFailedException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/exception/AssertFailedException.java
new file mode 100644
index 0000000..902c346
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/exception/AssertFailedException.java
@@ -0,0 +1,29 @@
+/*
+ * 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.plugin.test.agent.tool.validator.exception;
+
+public abstract class AssertFailedException extends RuntimeException {
+ protected AssertFailedException(String message) {
+ super(message);
+ }
+
+ protected AssertFailedException() {
+ }
+
+ public abstract String getCauseMessage();
+}
diff --git a/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/exception/IllegalDataFileException.java b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/exception/IllegalDataFileException.java
new file mode 100644
index 0000000..a80fa67
--- /dev/null
+++ b/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/exception/IllegalDataFileException.java
@@ -0,0 +1,31 @@
+/*
+ * 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.plugin.test.agent.tool.validator.exception;
+
+public class IllegalDataFileException extends AssertFailedException {
+ private final String fileName;
+
+ public IllegalDataFileException(String fileName) {
+ this.fileName = fileName;
+ }
+
+ @Override
+ public String getCauseMessage() {
+ return String.format("IllegalDataFileException %s ", fileName);
+ }
+}
diff --git a/validator/src/main/resources/log4j2.xml b/validator/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..342bd6d
--- /dev/null
+++ b/validator/src/main/resources/log4j2.xml
@@ -0,0 +1,37 @@
+<?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.
+ ~
+ -->
+<Configuration status="INFO">
+ <Appenders>
+ <Console name="console_out" target="SYSTEM_OUT">
+ <ThresholdFilter level="INFO"/>
+ <PatternLayout charset="UTF-8" pattern="[%d{yyyy-MM-dd HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
+ </Console>
+
+ <Console name="console_err" target="SYSTEM_ERR">
+ <ThresholdFilter level="ERROR"/>
+ <PatternLayout charset="UTF-8" pattern="[%d{yyyy-MM-dd HH:mm:ss:SSS}] [%p] - %l - %m%n"/>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Root level="INFO">
+ <AppenderRef ref="console_err"/>
+ <AppenderRef ref="console_out"/>
+ </Root>
+ </Loggers>
+</Configuration>
\ No newline at end of file
diff --git a/validator/src/test/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/DataAssertTest.java b/validator/src/test/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/DataAssertTest.java
new file mode 100644
index 0000000..3d730e6
--- /dev/null
+++ b/validator/src/test/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/DataAssertTest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.plugin.test.agent.tool.validator.assertor;
+
+import java.io.File;
+import org.apache.skywalking.plugin.test.agent.tool.validator.entity.Data;
+import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException;
+import org.junit.Test;
+
+public class DataAssertTest {
+
+ @Test
+ public void testAssertFunction() {
+ try {
+ File actualData = new File(DataAssertTest.class.getResource("/actualData.yaml").getFile());
+ File expectedData = new File(DataAssertTest.class.getResource("/expectedData.yaml").getFile());
+
+ DataAssert.assertEquals(Data.Loader.loadData("expectedData.yaml", expectedData), Data.Loader.loadData("actualData.yaml", actualData));
+ } catch (AssertFailedException e) {
+ System.out.println(String.format("\nassert failed.\n%s\n", e.getCauseMessage()));
+
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/validator/src/test/resources/actualData.yaml b/validator/src/test/resources/actualData.yaml
new file mode 100644
index 0000000..7eaa18e
--- /dev/null
+++ b/validator/src/test/resources/actualData.yaml
@@ -0,0 +1,295 @@
+# 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.
+{
+ "registryItems": {
+ "applications": [
+ {
+ "vertx-core-3.x-scenario": 2
+ }
+ ],
+ "instances": [
+ {
+ "vertx-core-3.x-scenario": 1
+ }
+ ],
+ "operationNames": [
+ {
+ "vertx-core-3.x-scenario": [
+ "/vertx-core-3-scenario/vertx-core/core-case",
+ "/vertx-core-3-scenario/vertx-core/executeTest",
+ "cluster-message-receiver"
+ ]
+ }
+ ]
+ },
+ "segmentItems": [
+ {
+ "applicationCode": "vertx-core-3.x-scenario",
+ "segmentSize": "8",
+ "segments": [
+ {
+ "segmentId": "1.159.15542729582940000",
+ "spans": [
+ {
+ "operationName": "#local-message-receiver",
+ "operationId": "0",
+ "parentSpanId": "-1",
+ "spanId": "0",
+ "spanLayer": "RPCFramework",
+ "refs": [
+ {
+ "parentEndpointId": 0,
+ "parentEndpoint": "local-message-receiver",
+ "networkAddressId": 0,
+ "entryEndpointId": 0,
+ "refType": "CrossThread",
+ "parentSpanId": 0,
+ "parentTraceSegmentId": "1.158.15542729582900006",
+ "parentServiceInstanceId": 1,
+ "networkAddress": "",
+ "entryEndpoint": "local-message-receiver",
+ "entryServiceInstanceId": 1
+ }
+ ],
+ "startTime": "1554272958294",
+ "endTime": "1554272958294",
+ "componentId": "59",
+ "componentName": "",
+ "isError": false,
+ "spanType": "Local",
+ "peer": "",
+ "peerId": "0"
+ }
+ ]
+ },
+ {
+ "segmentId": "1.158.15542729582900006",
+ "spans": [
+ {
+ "operationName": "local-message-receiver",
+ "operationId": "0",
+ "parentSpanId": "-1",
+ "spanId": "0",
+ "spanLayer": "RPCFramework",
+ "startTime": "1554272958290",
+ "endTime": "1554272958305",
+ "componentId": "59",
+ "componentName": "",
+ "isError": false,
+ "spanType": "Local",
+ "peer": "",
+ "peerId": "0"
+ }
+ ]
+ },
+ {
+ "segmentId": "1.158.15542729581640000",
+ "spans": [
+ {
+ "operationName": "/vertx-core-3-scenario/vertx-core/executeTest",
+ "operationId": "0",
+ "parentSpanId": "-1",
+ "spanId": "0",
+ "spanLayer": "Http",
+ "tags": [
+ {
+ "key": "http.method",
+ "value": "GET"
+ },
+ {
+ "key": "url",
+ "value": "http://localhost:8080/vertx-core-3-scenario/vertx-core/executeTest"
+ }
+ ],
+ "startTime": "1554272958168",
+ "endTime": "1554272958339",
+ "componentId": "59",
+ "componentName": "",
+ "isError": false,
+ "spanType": "Exit",
+ "peer": "/vertx-core-3-scenario/vertx-core/executeTest",
+ "peerId": "0"
+ }
+ ]
+ },
+ {
+ "segmentId": "1.158.15542729581890002",
+ "spans": [
+ {
+ "operationName": "/vertx-core-3-scenario/vertx-core/core-case",
+ "operationId": "0",
+ "parentSpanId": "-1",
+ "spanId": "0",
+ "spanLayer": "Http",
+ "tags": [
+ {
+ "key": "http.method",
+ "value": "GET"
+ },
+ {
+ "key": "url",
+ "value": "http://localhost:18080/vertx-core-3-scenario/vertx-core/core-case"
+ }
+ ],
+ "startTime": "1554272958190",
+ "endTime": "1554272958340",
+ "componentId": "59",
+ "componentName": "",
+ "isError": false,
+ "spanType": "Entry",
+ "peer": "",
+ "peerId": "0"
+ }
+ ]
+ },
+ {
+ "segmentId": "1.81.15542729583180000",
+ "spans": [
+ {
+ "operationName": "cluster-message-receiver",
+ "operationId": "0",
+ "parentSpanId": "-1",
+ "spanId": "0",
+ "spanLayer": "RPCFramework",
+ "refs": [
+ {
+ "parentEndpointId": 0,
+ "parentEndpoint": "cluster-message-receiver",
+ "networkAddressId": 0,
+ "entryEndpointId": 0,
+ "refType": "CrossProcess",
+ "parentSpanId": 0,
+ "parentTraceSegmentId": "1.158.15542729582940008",
+ "parentServiceInstanceId": 1,
+ "networkAddress": "localhost:45171",
+ "entryEndpoint": "cluster-message-receiver",
+ "entryServiceInstanceId": 1
+ }
+ ],
+ "startTime": "1554272958318",
+ "endTime": "1554272958320",
+ "componentId": "59",
+ "componentName": "",
+ "isError": false,
+ "spanType": "Entry",
+ "peer": "",
+ "peerId": "0"
+ }
+ ]
+ },
+ {
+ "segmentId": "1.158.15542729583390010",
+ "spans": [
+ {
+ "operationName": "#/vertx-core-3-scenario/vertx-core/executeTest",
+ "operationId": "0",
+ "parentSpanId": "-1",
+ "spanId": "0",
+ "spanLayer": "Http",
+ "refs": [
+ {
+ "parentEndpointId": 0,
+ "parentEndpoint": "/vertx-core-3-scenario/vertx-core/executeTest",
+ "networkAddressId": 0,
+ "entryEndpointId": 0,
+ "refType": "CrossThread",
+ "parentSpanId": 0,
+ "parentTraceSegmentId": "1.158.15542729581640000",
+ "parentServiceInstanceId": 1,
+ "networkAddress": "",
+ "entryEndpoint": "/vertx-core-3-scenario/vertx-core/executeTest",
+ "entryServiceInstanceId": 1
+ }
+ ],
+ "startTime": "1554272958339",
+ "endTime": "1554272958340",
+ "componentId": "59",
+ "componentName": "",
+ "isError": false,
+ "spanType": "Local",
+ "peer": "",
+ "peerId": "0"
+ }
+ ]
+ },
+ {
+ "segmentId": "1.158.15542729582940008",
+ "spans": [
+ {
+ "operationName": "cluster-message-receiver",
+ "operationId": "0",
+ "parentSpanId": "-1",
+ "spanId": "0",
+ "spanLayer": "RPCFramework",
+ "startTime": "1554272958294",
+ "endTime": "1554272958324",
+ "componentId": "59",
+ "componentName": "",
+ "isError": false,
+ "spanType": "Exit",
+ "peer": "localhost:45171",
+ "peerId": "0"
+ }
+ ]
+ },
+ {
+ "segmentId": "1.158.15542729582860004",
+ "spans": [
+ {
+ "operationName": "/vertx-core-3-scenario/vertx-core/executeTest",
+ "operationId": "0",
+ "parentSpanId": "-1",
+ "spanId": "0",
+ "spanLayer": "Http",
+ "tags": [
+ {
+ "key": "http.method",
+ "value": "GET"
+ },
+ {
+ "key": "url",
+ "value": "http://localhost:8080/vertx-core-3-scenario/vertx-core/executeTest"
+ }
+ ],
+ "refs": [
+ {
+ "parentEndpointId": 0,
+ "parentEndpoint": "/vertx-core-3-scenario/vertx-core/executeTest",
+ "networkAddressId": 0,
+ "entryEndpointId": 0,
+ "refType": "CrossProcess",
+ "parentSpanId": 0,
+ "parentTraceSegmentId": "1.158.15542729581640000",
+ "parentServiceInstanceId": 1,
+ "networkAddress": "/vertx-core-3-scenario/vertx-core/executeTest",
+ "entryEndpoint": "/vertx-core-3-scenario/vertx-core/executeTest",
+ "entryServiceInstanceId": 1
+ }
+ ],
+ "startTime": "1554272958286",
+ "endTime": "1554272958325",
+ "componentId": "59",
+ "componentName": "",
+ "isError": false,
+ "spanType": "Entry",
+ "peer": "",
+ "peerId": "0"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
diff --git a/validator/src/test/resources/expectedData.yaml b/validator/src/test/resources/expectedData.yaml
new file mode 100644
index 0000000..f3bdefd
--- /dev/null
+++ b/validator/src/test/resources/expectedData.yaml
@@ -0,0 +1,292 @@
+# 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.
+{
+ "registryItems": {
+ "applications": [
+ {
+ "vertx-core-3.x-scenario": 2
+ }
+ ],
+ "instances": [
+ {
+ "vertx-core-3.x-scenario": 1
+ }
+ ],
+ "operationNames": [
+ {
+ "vertx-core-3.x-scenario": [
+ "/vertx-core-3-scenario/vertx-core/executeTest",
+ "/vertx-core-3-scenario/vertx-core/core-case",
+ "cluster-message-receiver"
+ ]
+ }
+ ]
+ },
+ "segmentItems": [
+ {
+ "applicationCode": "vertx-core-3.x-scenario",
+ "segmentSize": "8",
+ "segments": [
+ {
+ "segmentId": "nq 0",
+ "spans": [
+ {
+ "operationName": "#local-message-receiver",
+ "operationId": "0",
+ "parentSpanId": "-1",
+ "spanId": "0",
+ "spanLayer": "RPCFramework",
+ "refs": [
+ {
+ "parentEndpointId": 0,
+ "parentEndpoint": "local-message-receiver",
+ "networkAddressId": 0,
+ "entryEndpointId": 0,
+ "refType": "CrossThread",
+ "parentSpanId": 0,
+ "parentTraceSegmentId": "not null",
+ "parentServiceInstanceId": 1,
+ "networkAddress": "",
+ "entryEndpoint": "local-message-receiver",
+ "entryServiceInstanceId": 1
+ }
+ ],
+ "startTime": "nq 0",
+ "endTime": "nq 0",
+ "componentId": "59",
+ "componentName": "",
+ "isError": false,
+ "spanType": "Local",
+ "peer": "",
+ "peerId": "0"
+ }
+ ]
+ },
+ {
+ "segmentId": "nq 0",
+ "spans": [
+ {
+ "operationName": "local-message-receiver",
+ "operationId": "0",
+ "parentSpanId": "-1",
+ "spanId": "0",
+ "spanLayer": "RPCFramework",
+ "startTime": "nq 0",
+ "endTime": "nq 0",
+ "componentId": "59",
+ "componentName": "",
+ "isError": false,
+ "spanType": "Local",
+ "peer": "",
+ "peerId": "0"
+ }
+ ]
+ },
+ {
+ "segmentId": "nq 0",
+ "spans": [
+ {
+ "operationName": "/vertx-core-3-scenario/vertx-core/executeTest",
+ "operationId": "0",
+ "parentSpanId": "-1",
+ "spanId": "0",
+ "spanLayer": "Http",
+ "tags": [
+ {
+ "key": "http.method",
+ "value": "GET"
+ },
+ {
+ "key": "url",
+ "value": "http://localhost:8080/vertx-core-3-scenario/vertx-core/executeTest"
+ }
+ ],
+ "startTime": "nq 0",
+ "endTime": "nq 0",
+ "componentId": "59",
+ "componentName": "",
+ "isError": false,
+ "spanType": "Exit",
+ "peer": "/vertx-core-3-scenario/vertx-core/executeTest",
+ "peerId": "0"
+ }
+ ]
+ },
+ {
+ "segmentId": "nq 0",
+ "spans": [
+ {
+ "operationName": "/vertx-core-3-scenario/vertx-core/core-case",
+ "operationId": "0",
+ "parentSpanId": "-1",
+ "spanId": "0",
+ "spanLayer": "Http",
+ "tags": [
+ {
+ "key": "http.method",
+ "value": "GET"
+ },
+ {
+ "key": "url",
+ "value": "http://localhost:18080/vertx-core-3-scenario/vertx-core/core-case"
+ }
+ ],
+ "startTime": "nq 0",
+ "endTime": "nq 0",
+ "componentId": "59",
+ "componentName": "",
+ "isError": false,
+ "spanType": "Entry",
+ "peerId": "0"
+ }
+ ]
+ },
+ {
+ "segmentId": "nq 0",
+ "spans": [
+ {
+ "operationName": "cluster-message-receiver",
+ "operationId": "0",
+ "parentSpanId": "-1",
+ "spanId": "0",
+ "spanLayer": "RPCFramework",
+ "refs": [
+ {
+ "parentEndpointId": 0,
+ "parentEndpoint": "cluster-message-receiver",
+ "networkAddressId": 0,
+ "entryEndpointId": 0,
+ "refType": "CrossProcess",
+ "parentSpanId": 0,
+ "parentTraceSegmentId": "not null",
+ "parentServiceInstanceId": 1,
+ "networkAddress": "not null",
+ "entryEndpoint": "cluster-message-receiver",
+ "entryServiceInstanceId": 1
+ }
+ ],
+ "startTime": "nq 0",
+ "endTime": "nq 0",
+ "componentId": "59",
+ "componentName": "",
+ "isError": false,
+ "spanType": "Entry",
+ "peer": "",
+ "peerId": "0"
+ }
+ ]
+ },
+ {
+ "segmentId": "nq 0",
+ "spans": [
+ {
+ "operationName": "#/vertx-core-3-scenario/vertx-core/executeTest",
+ "operationId": "0",
+ "parentSpanId": "-1",
+ "spanId": "0",
+ "spanLayer": "Http",
+ "refs": [
+ {
+ "parentEndpointId": 0,
+ "parentEndpoint": "/vertx-core-3-scenario/vertx-core/executeTest",
+ "networkAddressId": 0,
+ "entryEndpointId": 0,
+ "refType": "CrossThread",
+ "parentSpanId": 0,
+ "parentTraceSegmentId": "not null",
+ "parentServiceInstanceId": 1,
+ "networkAddress": "",
+ "entryEndpoint": "/vertx-core-3-scenario/vertx-core/executeTest",
+ "entryServiceInstanceId": 1
+ }
+ ],
+ "startTime": "nq 0",
+ "endTime": "nq 0",
+ "componentId": "59",
+ "componentName": "",
+ "isError": false,
+ "spanType": "Local",
+ "peer": "",
+ "peerId": "0"
+ }
+ ]
+ },
+ {
+ "segmentId": "nq 0",
+ "spans": [
+ {
+ "operationName": "cluster-message-receiver",
+ "operationId": "0",
+ "parentSpanId": "-1",
+ "spanId": "0",
+ "spanLayer": "RPCFramework",
+ "startTime": "nq 0",
+ "endTime": "nq 0",
+ "componentId": "59",
+ "componentName": "",
+ "isError": false,
+ "spanType": "Exit",
+ "peerId": "0"
+ }
+ ]
+ },
+ {
+ "segmentId": "nq 0",
+ "spans": [
+ {
+ "operationName": "/vertx-core-3-scenario/vertx-core/executeTest",
+ "operationId": "0",
+ "parentSpanId": "-1",
+ "spanId": "0",
+ "spanLayer": "Http",
+ "tags": [
+ {
+ "key": "http.method",
+ "value": "GET"
+ },
+ {
+ "key": "url",
+ "value": "http://localhost:8080/vertx-core-3-scenario/vertx-core/executeTest"
+ }
+ ],
+ "refs": [
+ {
+ "parentEndpointId": 0,
+ "parentEndpoint": "/vertx-core-3-scenario/vertx-core/executeTest",
+ "networkAddressId": 0,
+ "entryEndpointId": 0,
+ "refType": "CrossProcess",
+ "parentSpanId": 0,
+ "parentTraceSegmentId": "not null",
+ "parentServiceInstanceId": 1,
+ "networkAddress": "/vertx-core-3-scenario/vertx-core/executeTest",
+ "entryEndpoint": "/vertx-core-3-scenario/vertx-core/executeTest",
+ "entryServiceInstanceId": 1
+ }
+ ],
+ "startTime": "nq 0",
+ "endTime": "nq 0",
+ "componentId": "59",
+ "componentName": "",
+ "isError": false,
+ "spanType": "Entry",
+ "peerId": "0"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}