Skip to content

Commit 1938e61

Browse files
committed
fix unittest issue
1 parent 0daeb5a commit 1938e61

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

core/src/test/scala/org/apache/spark/deploy/StandaloneDynamicAllocationSuite.scala

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -417,16 +417,13 @@ class StandaloneDynamicAllocationSuite
417417
assert(apps.head.executors.size === 2)
418418
assert(apps.head.getExecutorLimit === Int.MaxValue)
419419
}
420+
var apps = getApplications()
420421
// sync executors between the Master and the driver, needed because
421422
// the driver refuses to kill executors it does not know about
422423
syncExecutors(sc)
423424
val executors = getExecutorIds(sc)
424425
assert(executors.size === 2)
425-
// force kill busy executor
426-
assert(killExecutor(sc, executors.head, force = true))
427-
var apps = getApplications()
428-
// kill executor successfully
429-
assert(apps.head.executors.size === 1)
426+
430427
// simulate running a task on the executor
431428
val getMap = PrivateMethod[mutable.HashMap[String, Int]]('executorIdToTaskCount)
432429
val taskScheduler = sc.taskScheduler.asInstanceOf[TaskSchedulerImpl]
@@ -435,7 +432,14 @@ class StandaloneDynamicAllocationSuite
435432
// kill the busy executor without force; this should fail
436433
assert(killExecutor(sc, executors.head, force = false))
437434
apps = getApplications()
435+
assert(apps.head.executors.size === 2)
436+
437+
// force kill busy executor
438+
assert(killExecutor(sc, executors.head, force = true))
439+
apps = getApplications()
440+
// kill executor successfully
438441
assert(apps.head.executors.size === 1)
442+
439443
}
440444

441445
// ===============================

0 commit comments

Comments
 (0)