clintropolis commented on code in PR #18742:
URL: https://github.com/apache/druid/pull/18742#discussion_r2529270226


##########
embedded-tests/src/test/java/org/apache/druid/testing/embedded/query/QueryVirtualStorageTest.java:
##########
@@ -152,88 +158,141 @@ void testQueryPartials()
         "select count(*) from \"%s\" WHERE __time >= TIMESTAMP '2015-09-12 
14:00:00' and __time < TIMESTAMP '2015-09-12 19:00:00'",
         "select count(*) from \"%s\" WHERE __time >= TIMESTAMP '2015-09-12 
19:00:00' and __time < TIMESTAMP '2015-09-13 00:00:00'"
     };
-    final long[] expectedResults = new long[] {
-        9770,
-        10524,
-        10267,
-        8683
-    };
+    final long[] expectedResults = new long[]{9770, 10524, 10267, 8683};
+    final long[] expectedLoads = new long[]{8L, 6L, 5L, 5L};
+
+
+    LatchableEmitter emitter = historical.latchableEmitter();
+    // sleep to clear out the pipe to get zerod out storage monitor metrics 
and then flush (which clears out the
+    // internal events stores in test emitter)
+    sleepForStorageMonitor();
+    emitter.flush();
+
+    emitter.waitForAnyEventWithMetricName(StorageMonitor.VSF_LOAD_COUNT);
+    long beforeLoads = getMetricTotal(emitter, StorageMonitor.VSF_LOAD_COUNT);
+    // confirm flushed
+    Assertions.assertEquals(0, beforeLoads);
 
+    // run the queries in order
     Assertions.assertEquals(expectedResults[0], 
Long.parseLong(cluster.runSql(queries[0], dataSource)));
-    assertMetrics(1, 8L);
+    assertQueryMetrics(1, expectedLoads[0]);
     Assertions.assertEquals(expectedResults[1], 
Long.parseLong(cluster.runSql(queries[1], dataSource)));
-    assertMetrics(2, 6L);
+    assertQueryMetrics(2, expectedLoads[1]);
     Assertions.assertEquals(expectedResults[2], 
Long.parseLong(cluster.runSql(queries[2], dataSource)));
-    assertMetrics(3, 5L);
+    assertQueryMetrics(3, expectedLoads[2]);
     Assertions.assertEquals(expectedResults[3], 
Long.parseLong(cluster.runSql(queries[3], dataSource)));
-    assertMetrics(4, 5L);
+    assertQueryMetrics(4, expectedLoads[3]);
 
+    sleepForStorageMonitor();
+    emitter.waitForAnyEventWithMetricName(StorageMonitor.VSF_LOAD_COUNT);
+    long firstLoads = getMetricTotal(emitter, StorageMonitor.VSF_LOAD_COUNT);
+    Assertions.assertTrue(firstLoads >= 24, "expected " + 24 + " but only got 
" + firstLoads);
+
+    long expectedTotalHits = 0;
+    long expectedTotalLoad = 0;
     for (int i = 0; i < 1000; i++) {
       int nextQuery = ThreadLocalRandom.current().nextInt(queries.length);
       Assertions.assertEquals(expectedResults[nextQuery], 
Long.parseLong(cluster.runSql(queries[nextQuery], dataSource)));
-      assertMetrics(i + 5, null);
+      assertQueryMetrics(i + 5, null);
+      long actualLoads = getMetricLatestEvent(emitter, 
DefaultQueryMetrics.QUERY_ON_DEMAND_LOAD_COUNT, i + 5);
+      expectedTotalLoad += actualLoads;
+      expectedTotalHits += (expectedLoads[nextQuery] - actualLoads);
     }
+
+    sleepForStorageMonitor();
+
+    emitter.waitForAnyEventWithMetricName(StorageMonitor.VSF_HIT_COUNT);

Review Comment:
   yea, i guess this method isn't necessary, i guess i was thinking it would be 
common for looking for things from monitors like i'm doing here, but i guess it 
doesn't save all that much



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to