Github user markhamstra commented on a diff in the pull request:
https://github.com/apache/spark/pull/8402#discussion_r37923582
--- Diff:
core/src/test/scala/org/apache/spark/scheduler/DAGSchedulerSuite.scala ---
@@ -695,6 +695,126 @@ 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,
+ s": expected stage $stageId, got ${stageAttempt.stageId}")
+ assert(stageAttempt.stageAttemptId == attempt,
+ s": expected stage attempt $attempt, got
${stageAttempt.stageAttemptId}")
+ }
+
+ 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
+ }
+
--- End diff --
Try this on for size. There's some more that could be done similar to
this, but as an experiment I just did the refactoring for these three methods,
and I think I like the results.
```scala
private implicit class ExtendedTaskSet(taskSet: TaskSet) {
/** Validate state when creating tests for task failures. */
def checkStageId(stageId: Int, attempt: Int): Unit = {
assert(taskSet.stageId === stageId,
s": expected stage $stageId, got ${taskSet.stageId}")
assert(taskSet.stageAttemptId == attempt,
s": expected stage attempt $attempt, got ${taskSet.stageAttemptId}")
}
/** Send the given CompletionEvent messages for the tasks in the
TaskSet. */
def complete(results: Seq[(TaskEndReason, Any)]) {
assert(taskSet.tasks.length >= results.size)
for ((result, i) <- results.zipWithIndex) {
if (i < taskSet.tasks.length) {
runEvent(CompletionEvent(
taskSet.tasks(i), result._1, result._2, null,
createFakeTaskInfo(), null))
}
}
}
def makeCompletions(reduceParts: Int): Seq[(Success.type, MapStatus)] =
{
taskSet.tasks.zipWithIndex.map { case (task, idx) =>
(Success, makeMapStatus("host" + ('A' + idx).toChar, reduceParts))
}.toSeq
}
}
```
---
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]