You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2020/08/17 22:36:02 UTC

[GitHub] [helix] kaisun2000 commented on issue #1289: Fix flaky test TestTaskAssignmentCalculator

kaisun2000 commented on issue #1289:
URL: https://github.com/apache/helix/issues/1289#issuecomment-675148772


   ```
    public TaskState pollForWorkflowState(String workflowName, long timeout,
         TaskState... targetStates) throws InterruptedException {
       // Wait for completion.
       long st = System.currentTimeMillis();
       WorkflowContext ctx;
       Set<TaskState> allowedStates = new HashSet<>(Arrays.asList(targetStates));
   
       long timeToSleep = timeout > 100L ? 100L : timeout;
       do {
         Thread.sleep(timeToSleep);
         ctx = getWorkflowContext(workflowName);
       } while ((ctx == null || ctx.getWorkflowState() == null
           || !allowedStates.contains(ctx.getWorkflowState()))
           && System.currentTimeMillis() < st + timeout);
   
       if (ctx == null || !allowedStates.contains(ctx.getWorkflowState())) {
         throw new HelixException(String.format(
             "Workflow \"%s\" context is empty or not in states: \"%s\", current state: \"%s\"",
             workflowName, Arrays.asList(targetStates),
             ctx == null ? "null" : ctx.getWorkflowState().toString()));
       }
   
       return ctx.getWorkflowState();
     }
   
   
   ```
   
   Is it possible that only one job failing would cause workflow failure? `!allowedStates.contains(ctx.getWorkflowState()))`


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

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



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org