Fix ingest stats test bug. (#50653)
This test code fixes a serialization test bug: https://gradle-enterprise.elastic.co/s/7x2ct6yywkw3o Rarely stats for the same processor are generated and the production code then sums up these stats. However the test code wasn't summing up in that case, which caused inconsistencies between the actual and expected results. Closes #50507
This commit is contained in:
parent
1299dda437
commit
7be43e9f6d
|
@ -71,9 +71,23 @@ public class ClusterStatsNodesTests extends ESTestCase {
|
|||
NodeStats nodeStats = randomValueOtherThanMany(n -> n.getIngestStats() == null, NodeStatsTests::createNodeStats);
|
||||
|
||||
SortedMap<String, long[]> processorStats = new TreeMap<>();
|
||||
nodeStats.getIngestStats().getProcessorStats().values().forEach(l -> l.forEach(s -> processorStats.put(s.getType(),
|
||||
new long[] { s.getStats().getIngestCount(), s.getStats().getIngestFailedCount(),
|
||||
s.getStats().getIngestCurrent(), s.getStats().getIngestTimeInMillis()})));
|
||||
nodeStats.getIngestStats().getProcessorStats().values().forEach(stats -> {
|
||||
stats.forEach(stat -> {
|
||||
processorStats.compute(stat.getType(), (key, value) -> {
|
||||
if (value == null) {
|
||||
return new long[] { stat.getStats().getIngestCount(), stat.getStats().getIngestFailedCount(),
|
||||
stat.getStats().getIngestCurrent(), stat.getStats().getIngestTimeInMillis()};
|
||||
} else {
|
||||
value[0] += stat.getStats().getIngestCount();
|
||||
value[1] += stat.getStats().getIngestFailedCount();
|
||||
value[2] += stat.getStats().getIngestCurrent();
|
||||
value[3] += stat.getStats().getIngestTimeInMillis();
|
||||
return value;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
ClusterStatsNodes.IngestStats stats = new ClusterStatsNodes.IngestStats(Collections.singletonList(nodeStats));
|
||||
assertThat(stats.pipelineCount, equalTo(nodeStats.getIngestStats().getProcessorStats().size()));
|
||||
String processorStatsString = "{";
|
||||
|
|
Loading…
Reference in New Issue