Github user squito commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5636#discussion_r38558785
  
    --- Diff: 
core/src/test/scala/org/apache/spark/scheduler/DAGSchedulerSuite.scala ---
    @@ -473,6 +473,280 @@ class DAGSchedulerSuite
         assertDataStructuresEmpty()
       }
     
    +  // Helper function to validate state when creating tests for task 
failures
    +  def checkStageId(stageId: Int, attempt: Int, stageAttempt: TaskSet) {
    +    assert(stageAttempt.stageId === stageId)
    +    assert(stageAttempt.stageAttemptId == attempt)
    +  }
    +
    +  def makeCompletions(stageAttempt: TaskSet, reduceParts: Int): 
Seq[(Success.type, MapStatus)] = {
    +    stageAttempt.tasks.zipWithIndex.map { case (task, idx) =>
    +      (Success, makeMapStatus("host" + ('A' + idx).toChar, reduceParts))
    +    }.toSeq
    +  }
    +
    +  def setupStageAbortTest(sc: SparkContext) {
    +    sc.listenerBus.addListener(new EndListener())
    +    ended = false
    +    jobResult = null
    +  }
    +
    +  // Create a new Listener to confirm that the listenerBus sees the JobEnd 
message
    +  // when we abort the stage. This message will also be consumed by the 
EventLoggingListener
    +  // so this will propagate up to the user.
    +  var ended = false
    +  var jobResult : JobResult = null
    +
    +  class EndListener extends SparkListener {
    +    override def onJobEnd(jobEnd: SparkListenerJobEnd): Unit = {
    +      jobResult = jobEnd.jobResult
    +      ended = true
    +    }
    +  }
    +
    +  // Helper functions to extract commonly used code in Fetch Failure test 
cases
    +  /**
    +   * Common code to get the next stage attempt, confirm it's the one we 
expect, and complete it
    +   * succesfullly.
    +   *
    +   * @param stageId - The current stageId
    +   * @param attemptIdx - The current attempt count
    +   * @param numShufflePartitions - The number of partitions in the next 
stage
    +   */
    +  def completeNextShuffleMapSuccesfully(stageId: Int, attemptIdx: Int,
    +      numShufflePartitions: Int): Unit = {
    +    val stageAttempt = taskSets.last
    +    checkStageId(stageId, attemptIdx, stageAttempt)
    +    complete(stageAttempt, makeCompletions(stageAttempt, 
numShufflePartitions))
    +  }
    +
    +  /**
    +   * Common code to get the next stage attempt, confirm it's the one we 
expect, and complete it
    +   * with all FetchFailure.
    --- End diff --
    
    to expand on this slightly -- the one case where do want to have more than 
one fetch failure is "Multiple tasks w/ fetch failures in same stage attempt 
should not abort the stage".  I know the other cases could just have one fetch 
failure, but it seems they are still testing the right thing with all fetch 
failures, and this way we can reuse this method.  Of course there are no end of 
different variants we could add tests for, but it seems to me this is a 
reasonably good balance.  I suppose we could also add an `nTasksToFail` param 
here, with a `-1` or `None` meaning fail all tasks.  And then the other tests 
could even check multiple permutations, if you think that would add.  I don't 
have any strong feelings on whether that added complexity in the test cases is 
worth it.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to