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

    https://github.com/apache/spark/pull/5636#discussion_r36260666
  
    --- Diff: 
core/src/test/scala/org/apache/spark/scheduler/DAGSchedulerSuite.scala ---
    @@ -473,6 +473,299 @@ 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 numPartitions - The number of partitions in the next stage
    +   */
    +  def completeNextShuffleMapSuccesfully(stageId: Int, attemptIdx: Int, 
numPartitions: Int): Unit = {
    +    val stageAttempt = taskSets.last
    +    checkStageId(stageId, attemptIdx, stageAttempt)
    +    complete(stageAttempt, makeCompletions(stageAttempt, numPartitions))
    +  }
    +
    +  /**
    +   * Common code to get the next stage attempt, confirm it's the one we 
expect, and complete it
    +   * with an intermediate FetchFailure.
    +   *
    +   * @param stageId - The current stageId
    +   * @param attemptIdx - The current attempt count
    +   * @param shuffleId - The shuffleId of the stage with a fetch failure
    +   */
    +  def completeNextShuffleMapWithFailureAndSuccess(stageId: Int,
    +      attemptIdx: Int,
    +      shuffleId: Int,
    +      numPartitions: Int): Unit = {
    +    val stageAttempt = taskSets.last
    +    checkStageId(stageId, attemptIdx, stageAttempt)
    +
    +    val stageSuccesses = stageAttempt.tasks.tail.map { _ => (Success, 
makeMapStatus("hostB",
    +      numPartitions))}
    +    complete(stageAttempt,
    +      Seq((FetchFailed(makeBlockManagerId("hostA"), shuffleId, 0, 0, 
"ignored"), null))
    +        ++ stageSuccesses
    +    )
    +  }
    +
    +  /**
    +   * Common code to get the next stage attempt, confirm it's the one we 
expect, and complete it
    +   * with all FetchFailure.
    +   *
    +   * @param stageId - The current stageId
    +   * @param attemptIdx - The current attempt count
    +   * @param shuffleId - The shuffleId of the stage with a fetch failure
    +   */
    +  def completeNextShuffleMapWithFetchFailure(stageId: Int,
    +      attemptIdx: Int,
    +      shuffleId: Int): Unit = {
    --- End diff --
    
    how about changing the last argument to being the `ShuffleDependency`?  I 
think the type will help make sure you stick in the right argument, plus avoid 
having to pull out the id in all the call sites


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to