FrankChen021 commented on code in PR #19886:
URL: https://github.com/apache/druid/pull/19886#discussion_r3732894928


##########
embedded-tests/src/test/java/org/apache/druid/testing/embedded/query/QueryVirtualStorageTest.java:
##########
@@ -222,24 +225,61 @@ void testQueryPartials()
       expectedTotalHits += (expectedLoads[nextQuery] - actualLoads);
     }
 
-    emitter.waitForNextEvent(event -> 
event.hasMetricName(StorageMonitor.VSF_HIT_COUNT));
+    final long expectedTotalHitsForWait = expectedTotalHits;
+    emitter.waitForEventAggregate(
+        event -> event.hasMetricName(StorageMonitor.VSF_HIT_COUNT),
+        aggregate -> aggregate.hasSumAtLeast(expectedTotalHitsForWait)
+    );
     long hits = emitter.getMetricEventLongSum(StorageMonitor.VSF_HIT_COUNT);
     Assertions.assertTrue(hits >= expectedTotalHits, "expected " + 
expectedTotalHits + " but only got " + hits);
     if (expectedTotalHits > 0) {
-      emitter.waitForNextEvent(event -> 
event.hasMetricName(StorageMonitor.VSF_HIT_BYTES));
+      emitter.waitForEventAggregate(
+          event -> event.hasMetricName(StorageMonitor.VSF_HIT_BYTES),
+          aggregate -> aggregate.hasSumAtLeast(1)
+      );
       
Assertions.assertTrue(emitter.getMetricEventLongSum(StorageMonitor.VSF_HIT_BYTES)
 > 0);
     }
-    emitter.waitForNextEvent(event -> 
event.hasMetricName(StorageMonitor.VSF_LOAD_BEGIN_COUNT));
+    final long expectedTotalLoadForWait = expectedTotalLoad;
+    emitter.waitForEventAggregate(
+        event -> event.hasMetricName(StorageMonitor.VSF_LOAD_BEGIN_COUNT),
+        aggregate -> aggregate.hasSumAtLeast(expectedTotalLoadForWait)
+    );
     long loads = 
emitter.getMetricEventLongSum(StorageMonitor.VSF_LOAD_BEGIN_COUNT);
     Assertions.assertTrue(loads >= expectedTotalLoad, "expected " + 
expectedTotalLoad + " but only got " + loads);
+    emitter.waitForEventAggregate(
+        event -> event.hasMetricName(StorageMonitor.VSF_LOAD_BEGIN_BYTES),
+        aggregate -> aggregate.hasSumAtLeast(1)
+    );
     
Assertions.assertTrue(emitter.getMetricEventLongSum(StorageMonitor.VSF_LOAD_BEGIN_BYTES)
 > 0);
+    emitter.waitForEventAggregate(
+        event -> event.hasMetricName(StorageMonitor.VSF_LOAD_COUNT),
+        aggregate -> aggregate.hasSumAtLeast(1)
+    );
     
Assertions.assertTrue(emitter.getMetricEventLongSum(StorageMonitor.VSF_LOAD_COUNT)
 > 0);
+    emitter.waitForEventAggregate(
+        event -> event.hasMetricName(StorageMonitor.VSF_LOAD_BYTES),
+        aggregate -> aggregate.hasSumAtLeast(1)
+    );
     
Assertions.assertTrue(emitter.getMetricEventLongSum(StorageMonitor.VSF_LOAD_BYTES)
 > 0);
-    emitter.waitForNextEvent(event -> 
event.hasMetricName(StorageMonitor.VSF_READ_COUNT));
+    emitter.waitForEventAggregate(
+        event -> event.hasMetricName(StorageMonitor.VSF_READ_COUNT),
+        aggregate -> aggregate.hasSumAtLeast(1)
+    );
     
Assertions.assertTrue(emitter.getMetricEventLongSum(StorageMonitor.VSF_READ_COUNT)
 > 0);
+    emitter.waitForEventAggregate(
+        event -> event.hasMetricName(StorageMonitor.VSF_READ_BYTES),
+        aggregate -> aggregate.hasSumAtLeast(1)
+    );
     
Assertions.assertTrue(emitter.getMetricEventLongSum(StorageMonitor.VSF_READ_BYTES)
 > 0);
+    emitter.waitForEventAggregate(
+        event -> event.hasMetricName(StorageMonitor.VSF_READ_TIME),
+        aggregate -> aggregate.hasCountAtLeast(1)
+    );
     
Assertions.assertTrue(emitter.getMetricEventLongSum(StorageMonitor.VSF_READ_TIME)
 >= 0);
-    emitter.waitForNextEvent(event -> 
event.hasMetricName(StorageMonitor.VSF_EVICT_COUNT));
+    emitter.waitForEventAggregate(
+        event -> event.hasMetricName(StorageMonitor.VSF_EVICT_COUNT),
+        aggregate -> aggregate.hasSumAtLeast(1)

Review Comment:
   Addressed in commit b1098584ea. StorageMonitor.doMonitor emits 
VSF_EVICT_COUNT, VSF_EVICT_BYTES, and VSF_REJECT_COUNT in separate consecutive 
emit calls; LatchableEmitter can release the count wait before the later 
callbacks run. Added aggregate waits for VSF_EVICT_BYTES (sum >= 1) and 
VSF_REJECT_COUNT (at least one event, preserving the expected cumulative value 
of 0) before the assertions. Checkstyle and SpotBugs passed with no 
violations/bugs. The focused test compiled but could not start because this 
environment has no valid Docker runtime.



-- 
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