cshannon commented on code in PR #3384:
URL: https://github.com/apache/accumulo/pull/3384#discussion_r1186710772


##########
test/src/main/java/org/apache/accumulo/test/functional/MemoryStarvedScanIT.java:
##########
@@ -377,31 +381,37 @@ public void testBatchScanPauses() throws Exception {
         // Grab the current paused count, wait two seconds and then confirm 
that
         // the number of rows fetched by the memoryConsumingScanner has not 
increased
         // and that the scan delay counter has increased.
-        double returned = SCAN_RETURNED_EARLY.doubleValue();
-        double paused = SCAN_START_DELAYED.doubleValue();
+        final double returned = SCAN_RETURNED_EARLY.doubleValue();
+        final double paused = SCAN_START_DELAYED.doubleValue();
         Thread.sleep(1500);
         assertEquals(currentCount, fetched.get());
-        assertTrue(SCAN_START_DELAYED.doubleValue() >= paused);
-        assertTrue(SCAN_RETURNED_EARLY.doubleValue() >= returned);
-        assertEquals(1, LOW_MEM_DETECTED.get());
+
+        assertTrue(
+            Wait.waitFor(() -> (SCAN_START_DELAYED.doubleValue() >= paused), 
20_000L, 1000L));
+        assertTrue(
+            Wait.waitFor(() -> (SCAN_RETURNED_EARLY.doubleValue() >= 
returned), 20_000L, 1000L));
+        assertTrue(Wait.waitFor(() -> (LOW_MEM_DETECTED.get() == 1), 20_000L, 
1000L));
 
         // Perform the check again
-        paused = SCAN_START_DELAYED.doubleValue();
-        returned = SCAN_RETURNED_EARLY.doubleValue();
+        final double paused2 = SCAN_START_DELAYED.doubleValue();
+        final double returned2 = SCAN_RETURNED_EARLY.doubleValue();
         Thread.sleep(1500);
         assertEquals(currentCount, fetched.get());
-        assertTrue(SCAN_START_DELAYED.doubleValue() >= paused);
-        assertEquals(returned, SCAN_RETURNED_EARLY.doubleValue());
-        assertEquals(1, LOW_MEM_DETECTED.get());
+
+        assertTrue(
+            Wait.waitFor(() -> (SCAN_START_DELAYED.doubleValue() >= paused2), 
20_000L, 1000L));
+        assertTrue(
+            Wait.waitFor(() -> (SCAN_RETURNED_EARLY.doubleValue() == 
returned2), 20_000L, 1000L));
+        assertTrue(Wait.waitFor(() -> (LOW_MEM_DETECTED.get() == 1), 20_000L, 
1000L));
 
         // Free the memory which will allow the pausing scanner to continue
         freeServerMemory(client, table);
 
         t.join();
         assertEquals(30, fetched.get());
         // allow metic collection to cycle.
-        Thread.sleep(6_000);
-        assertEquals(0, LOW_MEM_DETECTED.get());
+        Thread.sleep(3_000);

Review Comment:
   Another case where the sleep can be removed



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

Reply via email to