Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mock-collector/src/main/assembly/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
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>
<id>mock-collector-assembly</id>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you need to change this?

<formats>
<format>tar.gz</format>
</formats>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,24 @@ private static void logsEquals(List<LogData> excepted, List<LogData> actual) {
if (actual == null || excepted.size() != actual.size()) {
throw new LogSizeNotEqualsException(excepted.size(), (actual != null) ? actual.size() : 0);
}

Comparator<LogData> logComparator = (log1, log2) -> {
String ep1 = log1.getEndpoint() != null ? log1.getEndpoint() : "";
String ep2 = log2.getEndpoint() != null ? log2.getEndpoint() : "";
int cmp = ep1.compareTo(ep2);
if (cmp != 0) return cmp;

String type1 = log1.getBody() != null && log1.getBody().getType() != null ? log1.getBody().getType() : "";
String type2 = log2.getBody() != null && log2.getBody().getType() != null ? log2.getBody().getType() : "";
cmp = type1.compareTo(type2);
if (cmp != 0) return cmp;

String content1 = getContentValue(log1);
String content2 = getContentValue(log2);
return content1.compareTo(content2);
};

excepted.sort(logComparator);
actual.sort(logComparator);
for (int index = 0; index < excepted.size(); index++) {
LogData exceptedLog = excepted.get(index);
LogData actualLog = actual.get(index);
Expand Down Expand Up @@ -144,4 +161,13 @@ private static void keyValuePairEquals(LogTags.KeyValuePair excepted, LogTags.Ke
ExpressParser.parse(excepted.getValue()).assertValue("", actual.getValue());
}

private static String getContentValue(LogData log) {
if (log.getBody() == null || log.getBody().getContent() == null) return "";
Map<String, String> content = log.getBody().getContent();
if (content.get("text") != null) return content.get("text");
if (content.get("json") != null) return content.get("json");
if (content.get("yaml") != null) return content.get("yaml");
return "";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ public List<KeyValuePair> events() {
return keyValuePairs;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,4 @@ public void setSpans(List<SpanForRead> spans) {
this.spans = spans;
}

}
}
20 changes: 19 additions & 1 deletion validator/src/test/resources/actualData.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ meterItems:
singleValue: 200.0
logItems:
- serviceName: foo
logSize: 2
logSize: 4
logs:
- timestamp: 12345667890
endpoint: "/foo1"
Expand Down Expand Up @@ -204,6 +204,24 @@ logItems:
spanId: 1
tags: {}
layer: ''
- timestamp: 111
endpoint: ''
body:
type: ''
content:
text: "empty endpoint log2"
traceContext: { }
tags: { }
layer: ''
- timestamp: 1111
endpoint: ''
body:
type: ''
content:
text: "empty endpoint log1"
traceContext: { }
tags: { }
layer: ''

- serviceName: bar
logSize: 1
Expand Down
20 changes: 19 additions & 1 deletion validator/src/test/resources/expectedData.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,26 @@ meterItems:
singleValue: ge 0
logItems:
- serviceName: foo
logSize: 2
logSize: 4
logs:
- timestamp: gt 0
endpoint: ''
body:
type: ''
content:
text: "empty endpoint log1"
traceContext: { }
tags: { }
layer: ''
- timestamp: gt 0
endpoint: ''
body:
type: ''
content:
text: "empty endpoint log2"
traceContext: { }
tags: { }
layer: ''
- timestamp: gt 0
endpoint: "/foo1"
body:
Expand Down