Skip to content

Commit

Permalink
Fix typo in test
Browse files Browse the repository at this point in the history
  • Loading branch information
tgravescs committed Jan 14, 2020
1 parent f99f1cf commit 954ba00
Showing 1 changed file with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,20 @@
package org.apache.spark.resource

import org.apache.spark.{SparkConf, SparkFunSuite}
import org.apache.spark.internal.config.{EXECUTOR_CORES, EXECUTOR_MEMORY, EXECUTOR_MEMORY_OVERHEAD, SPARK_EXECUTOR_PREFIX}
import org.apache.spark.internal.config.{EXECUTOR_CORES, EXECUTOR_MEMORY, EXECUTOR_MEMORY_OVERHEAD, SPARK_EXECUTOR_PREFIX, SPARK_TASK_PREFIX}
import org.apache.spark.internal.config.Python.PYSPARK_EXECUTOR_MEMORY
import org.apache.spark.resource.TestResourceIDs._

class ResourceProfileSuite extends SparkFunSuite {

override def beforeAll() {
try {
ResourceProfile.clearDefaultProfile
} finally {
super.beforeAll()
}
}

override def afterEach() {
try {
ResourceProfile.clearDefaultProfile
Expand Down Expand Up @@ -60,14 +69,14 @@ class ResourceProfileSuite extends SparkFunSuite {
conf.set(EXECUTOR_MEMORY_OVERHEAD.key, "1g")
conf.set(EXECUTOR_MEMORY.key, "4g")
conf.set(EXECUTOR_CORES.key, "4")
conf.set("spark.task.resource.gpu.amount", "1")
conf.set("$SPARK_EXECUTOR_PREFIX.resource.gpu.amount", "1")
conf.set("$SPARK_EXECUTOR_PREFIX.resource.gpu.discoveryScript", "nameOfScript")
conf.set(TASK_GPU_ID.amountConf, "1")
conf.set(EXECUTOR_GPU_ID.amountConf, "1")
conf.set(EXECUTOR_GPU_ID.discoveryScriptConf, "nameOfScript")
val rprof = ResourceProfile.getOrCreateDefaultProfile(conf)
assert(rprof.id === ResourceProfile.DEFAULT_RESOURCE_PROFILE_ID)
val execResources = rprof.executorResources
assert(execResources.size === 5,
"Executor resources should contain cores, memory, and gpu " + execResources)
assert(execResources.size === 5, s"Executor resources should contain cores, pyspark " +
s"memory, memory overhead, memory, and gpu $execResources")
assert(execResources.contains("gpu"), "Executor resources should have gpu")
assert(rprof.executorResources(ResourceProfile.CORES).amount === 4,
"Executor resources should have 4 core")
Expand All @@ -86,8 +95,8 @@ class ResourceProfileSuite extends SparkFunSuite {

test("test default profile task gpus fractional") {
val sparkConf = new SparkConf()
.set("spark.executor.resource.gpu.amount", "2")
.set("spark.task.resource.gpu.amount", "0.33")
.set(EXECUTOR_GPU_ID.amountConf, "2")
.set(TASK_GPU_ID.amountConf, "0.33")
val immrprof = ResourceProfile.getOrCreateDefaultProfile(sparkConf)
assert(immrprof.taskResources.get("gpu").get.amount == 0.33)
}
Expand Down

0 comments on commit 954ba00

Please sign in to comment.