Skip to content

Commit 4087936

Browse files
Ji YanJi Yan
authored andcommitted
add test
1 parent ecb7a8e commit 4087936

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

resource-managers/mesos/src/test/scala/org/apache/spark/scheduler/cluster/mesos/MesosSchedulerUtilsSuite.scala

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class MesosSchedulerUtilsSuite extends SparkFunSuite with Matchers with MockitoS
7373
}
7474

7575
val utils = new MesosSchedulerUtils { }
76+
7677
// scalastyle:on structural.type
7778

7879
test("use at-least minimum overhead") {
@@ -253,4 +254,33 @@ class MesosSchedulerUtilsSuite extends SparkFunSuite with Matchers with MockitoS
253254
val portsToUse = getRangesFromResources(resourcesToBeUsed).map{r => r._1}
254255
portsToUse.isEmpty shouldBe true
255256
}
257+
258+
test("Parse arbitrary parameter to pass into docker containerizer") {
259+
val parsed = MesosSchedulerBackendUtil.parseParamsSpec("a=1,b=2,c=3")
260+
parsed(0).getKey shouldBe "a"
261+
parsed(0).getValue shouldBe "1"
262+
parsed(1).getKey shouldBe "b"
263+
parsed(1).getValue shouldBe "2"
264+
parsed(2).getKey shouldBe "c"
265+
parsed(2).getValue shouldBe "3"
266+
267+
val invalid = MesosSchedulerBackendUtil.parseParamsSpec("a,b")
268+
invalid.length shouldBe 0
269+
}
270+
271+
test("ContainerInfo contains parsed arbitrary parameters") {
272+
val conf = new SparkConf()
273+
conf.set("spark.mesos.executor.docker.params", "a=1,b=2,c=3")
274+
conf.set("spark.mesos.executor.docker.image", "test")
275+
276+
val containerInfo = MesosSchedulerBackendUtil.containerInfo(conf)
277+
val params = containerInfo.getDocker.getParametersList
278+
params.size() shouldBe 3
279+
params.get(0).getKey shouldBe "a"
280+
params.get(0).getValue shouldBe "1"
281+
params.get(1).getKey shouldBe "b"
282+
params.get(1).getValue shouldBe "2"
283+
params.get(2).getKey shouldBe "c"
284+
params.get(2).getValue shouldBe "3"
285+
}
256286
}

0 commit comments

Comments
 (0)