voonhous commented on code in PR #17677:
URL: https://github.com/apache/hudi/pull/17677#discussion_r2643414768


##########
hudi-flink-datasource/hudi-flink/src/test/java/org/apache/hudi/utils/TestUtils.java:
##########
@@ -157,4 +159,14 @@ public static String 
amendCompletionTimeToLatest(HoodieTableMetaClient metaClien
     Files.move(sourcePath, newFilePath);
     return newCompletionTime;
   }
+
+  public static boolean waitUntil(BooleanSupplier condition, int 
timeoutSeconds) throws InterruptedException {
+    for (int i = 0; i < timeoutSeconds; i++) {
+      if (condition.getAsBoolean()) {
+        return true;
+      }
+      TimeUnit.SECONDS.sleep(1);
+    }
+    return false;
+  }

Review Comment:
   ```suggestion
   /**
    * Waits for a condition to be met within a specific timeout.
    *
    * @param condition      The condition to poll.
    * @param timeoutSeconds Maximum time to wait in seconds.
    * @param errorMessage   The message to display if the timeout is reached.
    * @throws InterruptedException if the sleep is interrupted.
    * @throws AssertionError if the condition is not met within the timeout.
    */
   public static boolean waitUntil(BooleanSupplier condition, int 
timeoutSeconds, String errorMessage) 
       throws InterruptedException {
     long limit = System.currentTimeMillis() + (timeoutSeconds * 1000L);
     while (System.currentTimeMillis() < limit) {
       if (condition.getAsBoolean()) {
         return true;
       }
       TimeUnit.MILLISECONDS.sleep(500);
     }
     // Fail the test with a descriptive message
     throw new AssertionError(errorMessage + " (timeout: " + timeoutSeconds + 
"s)");
   }
   ```
   
   Nit: use while loop + epoch comparison, add error message. 



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