Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@ class BarrierTaskContextSuite extends SparkFunSuite with LocalSparkContext {
assert(error.contains("within 1 second(s)"))
}


def testBarrierTaskKilled(sc: SparkContext, interruptOnCancel: Boolean): Unit = {
sc.setLocalProperty(SparkContext.SPARK_JOB_INTERRUPT_ON_CANCEL, interruptOnCancel.toString)

def testBarrierTaskKilled(interruptOnKill: Boolean): Unit = {
withTempDir { dir =>
val killedFlagFile = "barrier.task.killed"
val rdd = sc.makeRDD(Seq(0, 1), 2)
Expand All @@ -181,12 +178,15 @@ class BarrierTaskContextSuite extends SparkFunSuite with LocalSparkContext {

val listener = new SparkListener {
override def onTaskStart(taskStart: SparkListenerTaskStart): Unit = {
new Thread {
override def run: Unit = {
Thread.sleep(1000)
sc.killTaskAttempt(taskStart.taskInfo.taskId, interruptThread = false)
}
}.start()
val partitionId = taskStart.taskInfo.index
if (partitionId == 0) {
new Thread {
override def run: Unit = {
Thread.sleep(1000)
sc.killTaskAttempt(taskStart.taskInfo.taskId, interruptThread = interruptOnKill)
}
}.start()
}
}
}
sc.addSparkListener(listener)
Expand All @@ -201,15 +201,25 @@ class BarrierTaskContextSuite extends SparkFunSuite with LocalSparkContext {
}
}

test("barrier task killed") {
test("barrier task killed, no interrupt") {
val conf = new SparkConf()
.set("spark.barrier.sync.timeout", "1")
.set(TEST_NO_STAGE_RETRY, true)
.setMaster("local-cluster[4, 1, 1024]")
.setAppName("test-cluster")
sc = new SparkContext(conf)

testBarrierTaskKilled(interruptOnKill = false)
}

test("barrier task killed, interrupt") {
val conf = new SparkConf()
.set("spark.barrier.sync.timeout", "1")
.set(TEST_NO_STAGE_RETRY, true)
.setMaster("local-cluster[4, 1, 1024]")
.setAppName("test-cluster")
sc = new SparkContext(conf)

testBarrierTaskKilled(sc, true)
testBarrierTaskKilled(sc, false)
testBarrierTaskKilled(interruptOnKill = true)
}
}