diff options
author | Stephen Haberman <stephen@exigencecorp.com> | 2013-01-15 11:48:50 -0600 |
---|---|---|
committer | Stephen Haberman <stephen@exigencecorp.com> | 2013-01-15 11:48:50 -0600 |
commit | d228bff440395e8e6b8d67483467dde65b08ab40 (patch) | |
tree | 2631ebcba8ed3834b0b8b18a185aa4ab2c743dee /core | |
parent | dd583b7ebf0e6620ec8e35424b59db451febe3e8 (diff) | |
download | spark-d228bff440395e8e6b8d67483467dde65b08ab40.tar.gz spark-d228bff440395e8e6b8d67483467dde65b08ab40.tar.bz2 spark-d228bff440395e8e6b8d67483467dde65b08ab40.zip |
Add a test.
Diffstat (limited to 'core')
-rw-r--r-- | core/src/test/scala/spark/scheduler/TaskContextSuite.scala | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/core/src/test/scala/spark/scheduler/TaskContextSuite.scala b/core/src/test/scala/spark/scheduler/TaskContextSuite.scala new file mode 100644 index 0000000000..f937877340 --- /dev/null +++ b/core/src/test/scala/spark/scheduler/TaskContextSuite.scala @@ -0,0 +1,43 @@ +package spark.scheduler + +import org.scalatest.FunSuite +import org.scalatest.BeforeAndAfter +import spark.TaskContext +import spark.RDD +import spark.SparkContext +import spark.Split + +class TaskContextSuite extends FunSuite with BeforeAndAfter { + + var sc: SparkContext = _ + + after { + if (sc != null) { + sc.stop() + sc = null + } + // To avoid Akka rebinding to the same port, since it doesn't unbind immediately on shutdown + System.clearProperty("spark.master.port") + } + + test("Calls executeOnCompleteCallbacks after failure") { + var completed = false + sc = new SparkContext("local", "test") + val rdd = new RDD[String](sc) { + override val splits = Array[Split](StubSplit(0)) + override val dependencies = List() + override def compute(split: Split, context: TaskContext) = { + context.addOnCompleteCallback(() => completed = true) + sys.error("failed") + } + } + val func = (c: TaskContext, i: Iterator[String]) => i.next + val task = new ResultTask[String, String](0, rdd, func, 0, Seq(), 0) + intercept[RuntimeException] { + task.run(0) + } + assert(completed === true) + } + + case class StubSplit(val index: Int) extends Split +}
\ No newline at end of file |