Skip to content

Commit

Permalink
[SPARK-28115][CORE][TEST] Fix flaky test: SparkContextSuite.test reso…
Browse files Browse the repository at this point in the history
…urce scheduling under local-cluster mode

## What changes were proposed in this pull request?

The test `SparkContextSuite.test resource scheduling under local-cluster mode` has been flaky, because it expects the size of `sc.statusTracker.getExecutorInfos` be the same as the number of executors, while the returned list contains both the driver and executors.

## How was this patch tested?

Updated existing tests.

Closes #24917 from jiangxb1987/getExecutorInfos.

Authored-by: Xingbo Jiang <xingbo.jiang@databricks.com>
Signed-off-by: Xiangrui Meng <meng@databricks.com>
  • Loading branch information
jiangxb1987 authored and mengxr committed Jun 20, 2019
1 parent 25c5d57 commit d98a5ce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Expand Up @@ -99,6 +99,7 @@ class SparkStatusTracker private[spark] (sc: SparkContext, store: AppStatusStore
/**
* Returns information of all known executors, including host, port, cacheSize, numRunningTasks
* and memory metrics.
* Note this include information for both the driver and executors.
*/
def getExecutorInfos: Array[SparkExecutorInfo] = {
store.executorList(true).map { exec =>
Expand Down
12 changes: 3 additions & 9 deletions core/src/test/scala/org/apache/spark/SparkContextSuite.scala
Expand Up @@ -750,9 +750,7 @@ class SparkContextSuite extends SparkFunSuite with LocalSparkContext with Eventu
sc = new SparkContext(conf)

// Ensure all executors has started
eventually(timeout(10.seconds)) {
assert(sc.statusTracker.getExecutorInfos.size == 1)
}
TestUtils.waitUntilExecutorsUp(sc, 1, 10000)
assert(sc.resources.size === 1)
assert(sc.resources.get(GPU).get.addresses === Array("5", "6"))
assert(sc.resources.get(GPU).get.name === "gpu")
Expand Down Expand Up @@ -780,9 +778,7 @@ class SparkContextSuite extends SparkFunSuite with LocalSparkContext with Eventu
sc = new SparkContext(conf)

// Ensure all executors has started
eventually(timeout(10.seconds)) {
assert(sc.statusTracker.getExecutorInfos.size == 1)
}
TestUtils.waitUntilExecutorsUp(sc, 1, 10000)
// driver gpu resources file should take precedence over the script
assert(sc.resources.size === 1)
assert(sc.resources.get(GPU).get.addresses === Array("0", "1", "8"))
Expand Down Expand Up @@ -855,9 +851,7 @@ class SparkContextSuite extends SparkFunSuite with LocalSparkContext with Eventu
sc = new SparkContext(conf)

// Ensure all executors has started
eventually(timeout(60.seconds)) {
assert(sc.statusTracker.getExecutorInfos.size == 3)
}
TestUtils.waitUntilExecutorsUp(sc, 3, 60000)

val rdd = sc.makeRDD(1 to 10, 9).mapPartitions { it =>
val context = TaskContext.get()
Expand Down

0 comments on commit d98a5ce

Please sign in to comment.