This is an automated email from the ASF dual-hosted git repository. wusheng pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/master by this push: new 5bb35e3 validator enhancement (#3750) 5bb35e3 is described below commit 5bb35e3f7d7c1f7534708de67b8d37d531a438b8 Author: zhangwei <pk...@outlook.com> AuthorDate: Thu Oct 31 12:38:23 2019 +0800 validator enhancement (#3750) --- .../tool/validator/assertor/SegmentAssert.java | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/plugin/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/SegmentAssert.java b/test/plugin/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/SegmentAssert.java index 68faf42..aabba74 100644 --- a/test/plugin/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/SegmentAssert.java +++ b/test/plugin/validator/src/main/java/org/apache/skywalking/plugin/test/agent/tool/validator/assertor/SegmentAssert.java @@ -20,6 +20,8 @@ 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.SegmentRefAssertFailedException; +import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.SegmentRefNotFoundException; import org.apache.skywalking.plugin.test.agent.tool.validator.exception.AssertFailedException; import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.KeyValueNotEqualsException; import org.apache.skywalking.plugin.test.agent.tool.validator.assertor.exception.LogEventKeyNotEqualsException; @@ -125,6 +127,10 @@ public class SegmentAssert { 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) { @@ -189,4 +195,28 @@ public class SegmentAssert { } } + 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.entryServiceName()).assertValue("entry service name", actual.entryServiceName()); + ExpressParser.parse(expected.parentServiceName()).assertValue("parent service name", actual.parentServiceName()); + ExpressParser.parse(expected.refType()).assertValue("ref type", actual.refType()); + return true; + } catch (ValueAssertFailedException e) { + throw new SegmentRefAssertFailedException(e, expected, actual); + } + } }