|
@@ -19,10 +19,12 @@
|
|
|
|
|
|
package org.elasticsearch.ingest;
|
|
|
|
|
|
+import org.elasticsearch.Version;
|
|
|
import org.elasticsearch.common.collect.MapBuilder;
|
|
|
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
|
import org.elasticsearch.test.ESTestCase;
|
|
|
+import org.elasticsearch.test.VersionUtils;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.Collections;
|
|
@@ -40,7 +42,24 @@ public class IngestStatsTests extends ESTestCase {
|
|
|
Map<String, List<IngestStats.ProcessorStat>> processorStats = createProcessorStats(pipelineStats);
|
|
|
IngestStats ingestStats = new IngestStats(totalStats, pipelineStats, processorStats);
|
|
|
IngestStats serializedStats = serialize(ingestStats);
|
|
|
- assertIngestStats(ingestStats, serializedStats, true);
|
|
|
+ assertIngestStats(ingestStats, serializedStats, true, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void testBWCIngestProcessorTypeStats() throws IOException {
|
|
|
+ IngestStats.Stats totalStats = new IngestStats.Stats(50, 100, 200, 300);
|
|
|
+ List<IngestStats.PipelineStat> pipelineStats = createPipelineStats();
|
|
|
+ Map<String, List<IngestStats.ProcessorStat>> processorStats = createProcessorStats(pipelineStats);
|
|
|
+ IngestStats expectedIngestStats = new IngestStats(totalStats, pipelineStats, processorStats);
|
|
|
+
|
|
|
+ //legacy output logic
|
|
|
+ BytesStreamOutput out = new BytesStreamOutput();
|
|
|
+ out.setVersion(VersionUtils.getPreviousVersion(Version.V_7_6_0));
|
|
|
+ expectedIngestStats.writeTo(out);
|
|
|
+
|
|
|
+ StreamInput in = out.bytes().streamInput();
|
|
|
+ in.setVersion(VersionUtils.getPreviousVersion(Version.V_7_6_0));
|
|
|
+ IngestStats serializedStats = new IngestStats(in);
|
|
|
+ assertIngestStats(expectedIngestStats, serializedStats, true, false);
|
|
|
}
|
|
|
|
|
|
private List<IngestStats.PipelineStat> createPipelineStats() {
|
|
@@ -70,7 +89,8 @@ public class IngestStatsTests extends ESTestCase {
|
|
|
return new IngestStats(in);
|
|
|
}
|
|
|
|
|
|
- private void assertIngestStats(IngestStats ingestStats, IngestStats serializedStats, boolean expectProcessors){
|
|
|
+ private void assertIngestStats(IngestStats ingestStats, IngestStats serializedStats, boolean expectProcessors,
|
|
|
+ boolean expectProcessorTypes){
|
|
|
assertNotSame(ingestStats, serializedStats);
|
|
|
assertNotSame(ingestStats.getTotalStats(), serializedStats.getTotalStats());
|
|
|
assertNotSame(ingestStats.getPipelineStats(), serializedStats.getPipelineStats());
|
|
@@ -92,6 +112,11 @@ public class IngestStatsTests extends ESTestCase {
|
|
|
for (IngestStats.ProcessorStat serializedProcessorStat : serializedProcessorStats) {
|
|
|
IngestStats.ProcessorStat ps = it.next();
|
|
|
assertEquals(ps.getName(), serializedProcessorStat.getName());
|
|
|
+ if (expectProcessorTypes) {
|
|
|
+ assertEquals(ps.getType(), serializedProcessorStat.getType());
|
|
|
+ } else {
|
|
|
+ assertEquals("_NOT_AVAILABLE", serializedProcessorStat.getType());
|
|
|
+ }
|
|
|
assertStats(ps.getStats(), serializedProcessorStat.getStats());
|
|
|
}
|
|
|
assertFalse(it.hasNext());
|