Skip to content

Commit 8e89465

Browse files
committed
couple more sanity tests
extra test in driver builder for sanity
1 parent e820aa6 commit 8e89465

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/KubernetesVolumeUtilsSuite.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ class KubernetesVolumeUtilsSuite extends SparkFunSuite {
3333
KubernetesHostPathVolumeConf("/hostPath"))
3434
}
3535

36+
test("Parses subPath correctly") {
37+
val sparkConf = new SparkConf(false)
38+
sparkConf.set("test.emptyDir.volumeName.mount.path", "/path")
39+
sparkConf.set("test.emptyDir.volumeName.mount.readOnly", "true")
40+
sparkConf.set("test.emptyDir.volumeName.mount.subPath", "subPath")
41+
42+
val volumeSpec = KubernetesVolumeUtils.parseVolumesWithPrefix(sparkConf, "test.").head.get
43+
assert(volumeSpec.volumeName === "volumeName")
44+
assert(volumeSpec.mountPath === "/path")
45+
assert(volumeSpec.mountSubPath === "subPath")
46+
}
47+
3648
test("Parses persistentVolumeClaim volumes correctly") {
3749
val sparkConf = new SparkConf(false)
3850
sparkConf.set("test.persistentVolumeClaim.volumeName.mount.path", "/path")

resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/submit/KubernetesDriverBuilderSuite.scala

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,39 @@ class KubernetesDriverBuilderSuite extends SparkFunSuite {
169169
DRIVER_CMD_STEP_TYPE)
170170
}
171171

172+
test("Apply volumes step if a mount subpath is present.") {
173+
val volumeSpec = KubernetesVolumeSpec(
174+
"volume",
175+
"/tmp",
176+
"foo",
177+
false,
178+
KubernetesHostPathVolumeConf("/path"))
179+
val conf = KubernetesConf(
180+
new SparkConf(false),
181+
KubernetesDriverSpecificConf(
182+
JavaMainAppResource(None),
183+
"test-app",
184+
"main",
185+
Seq.empty),
186+
"prefix",
187+
"appId",
188+
Map.empty,
189+
Map.empty,
190+
Map.empty,
191+
Map.empty,
192+
Map.empty,
193+
volumeSpec :: Nil,
194+
hadoopConfSpec = None)
195+
validateStepTypesApplied(
196+
builderUnderTest.buildFromFeatures(conf),
197+
BASIC_STEP_TYPE,
198+
CREDENTIALS_STEP_TYPE,
199+
SERVICE_STEP_TYPE,
200+
LOCAL_DIRS_STEP_TYPE,
201+
MOUNT_VOLUMES_STEP_TYPE,
202+
DRIVER_CMD_STEP_TYPE)
203+
}
204+
172205
test("Apply template volume step if executor template is present.") {
173206
val sparkConf = spy(new SparkConf(false))
174207
doReturn(Option("filename")).when(sparkConf)

0 commit comments

Comments
 (0)