You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/06/30 18:13:58 UTC

[GitHub] [pinot] jackjlli commented on a diff in pull request #8999: Retry validateJobs for a while to avoid flaky errors

jackjlli commented on code in PR #8999:
URL: https://github.com/apache/pinot/pull/8999#discussion_r911318797


##########
pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/minion/PinotTaskManagerStatelessTest.java:
##########
@@ -239,10 +242,20 @@ private void validateJob(String taskType, String cronExpression)
         throw new RuntimeException(e);
       }
     }, TIMEOUT_IN_MS, "JobDetail exiting but missing JobTrigger");
-    List<? extends Trigger> triggersOfJob = scheduler.getTriggersOfJob(jobKey);
-    Trigger trigger = triggersOfJob.iterator().next();
-    assertTrue(trigger instanceof CronTrigger);
-    assertEquals(((CronTrigger) trigger).getCronExpression(), cronExpression);
+
+    // There is no guarantee that previous changes have been applied, therefore we need to
+    // retry the check for a bit
+    TestUtils.waitForResult(() -> {

Review Comment:
   You can use `waitForCondition` instead of `waitForResult`, as the logic here doesn't require to return anything.



##########
pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/minion/PinotTaskManagerStatelessTest.java:
##########
@@ -239,10 +242,20 @@ private void validateJob(String taskType, String cronExpression)
         throw new RuntimeException(e);
       }
     }, TIMEOUT_IN_MS, "JobDetail exiting but missing JobTrigger");
-    List<? extends Trigger> triggersOfJob = scheduler.getTriggersOfJob(jobKey);
-    Trigger trigger = triggersOfJob.iterator().next();
-    assertTrue(trigger instanceof CronTrigger);
-    assertEquals(((CronTrigger) trigger).getCronExpression(), cronExpression);
+
+    // There is no guarantee that previous changes have been applied, therefore we need to
+    // retry the check for a bit
+    TestUtils.waitForResult(() -> {
+      try {
+        List<? extends Trigger> triggersOfJob = scheduler.getTriggersOfJob(jobKey);
+        Trigger trigger = triggersOfJob.iterator().next();
+        assertTrue(trigger instanceof CronTrigger);

Review Comment:
   If `waitForCondition` is used, you may need to replace this assertion statement with returning true or false.



-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org