diff --git a/src/main/java/org/opensearch/performanceanalyzer/reader/ShardRequestMetricsSnapshot.java b/src/main/java/org/opensearch/performanceanalyzer/reader/ShardRequestMetricsSnapshot.java index c89fa67c1..b9374240c 100644 --- a/src/main/java/org/opensearch/performanceanalyzer/reader/ShardRequestMetricsSnapshot.java +++ b/src/main/java/org/opensearch/performanceanalyzer/reader/ShardRequestMetricsSnapshot.java @@ -166,7 +166,7 @@ public SelectHavingStep fetchLatency() { this.add(DSL.field(DSL.name(Fields.SHARD_ROLE.toString()), String.class)); this.add(DSL.field(DSL.name(Fields.ST.toString()), Long.class)); this.add(DSL.field(DSL.name(Fields.ET.toString()), Long.class)); - this.add(DSL.field(DSL.name(Fields.DOC_COUNT.toString()), Long.class)); + this.add(DSL.field(DSL.name(Fields.DOC_COUNT.toString()), Double.class)); this.add( DSL.field(Fields.ET.toString()) .minus(DSL.field(Fields.ST.toString())) diff --git a/src/test/java/org/opensearch/performanceanalyzer/reader/ReaderMetricsProcessorTests.java b/src/test/java/org/opensearch/performanceanalyzer/reader/ReaderMetricsProcessorTests.java index 1e41f1b43..1d88666c3 100644 --- a/src/test/java/org/opensearch/performanceanalyzer/reader/ReaderMetricsProcessorTests.java +++ b/src/test/java/org/opensearch/performanceanalyzer/reader/ReaderMetricsProcessorTests.java @@ -7,6 +7,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -53,6 +54,42 @@ public void before() throws Exception { rootLocation = "build/resources/test/reader/"; } + @Test + public void testShardBulkParseAndQuery() throws Exception { + deleteAll(); + ReaderMetricsProcessor mp = + new ReaderMetricsProcessor(rootLocation, true, new AppContext()); + + mp.processMetrics(rootLocation, 1566413985000L); + mp.processMetrics(rootLocation, 1566413990000L); + + Result res = + mp.getMetricsDB() + .getValue() + .queryMetric( + Arrays.asList("ShardEvents", "ShardBulkDocs"), + Arrays.asList("sum", "sum"), + Arrays.asList("Operation")); + + boolean shardbulkEncountered = false; + + for (Record record : res) { + if (PerformanceAnalyzerMetrics.sShardBulkPath.equals(record.get("Operation"))) { + assertNotNull(record.get("ShardEvents")); + assertNotNull(record.get("ShardBulkDocs")); + assertEquals(1519.0, (Double) record.get("ShardEvents"), 0.0); + assertEquals(507096.0, (Double) record.get("ShardBulkDocs"), 0.0); + shardbulkEncountered = true; + } + } + + assertTrue(shardbulkEncountered); + + mp.trimOldSnapshots(); + mp.trimOldMetricsDBFiles(); + mp.deleteDBs(); + } + @Test public void testReaderMetricsProcessorFrequently() throws Exception { deleteAll();