Skip to content

Commit 87647ed

Browse files
committed
Added a test case of SparkPi with an argument
1 parent 6a1353f commit 87647ed

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

integration-test/src/test/scala/org/apache/spark/deploy/k8s/integrationtest/KubernetesSuite.scala

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ private[spark] class KubernetesSuite extends FunSuite with BeforeAndAfterAll wit
7575
runSparkPiAndVerifyCompletion()
7676
}
7777

78+
test("Run SparkPi with an argument.") {
79+
runSparkPiAndVerifyCompletion(appArgs = Array("5"))
80+
}
81+
7882
test("Run SparkPi with custom driver pod name, labels, annotations, and environment variables.") {
7983
sparkAppConf
8084
.set("spark.kubernetes.driver.pod.name", "spark-integration-spark-pi")
@@ -122,12 +126,13 @@ private[spark] class KubernetesSuite extends FunSuite with BeforeAndAfterAll wit
122126
private def runSparkPiAndVerifyCompletion(
123127
appResource: String = CONTAINER_LOCAL_SPARK_DISTRO_EXAMPLES_JAR,
124128
driverPodChecker: Pod => Unit = doBasicDriverPodCheck,
125-
executorPodChecker: Pod => Unit = doBasicExecutorPodCheck): Unit = {
129+
executorPodChecker: Pod => Unit = doBasicExecutorPodCheck,
130+
appArgs: Array[String] = Array.empty[String]): Unit = {
126131
runSparkApplicationAndVerifyCompletion(
127132
appResource,
128133
SPARK_PI_MAIN_CLASS,
129134
Seq("Pi is roughly 3"),
130-
Array.empty[String],
135+
appArgs,
131136
driverPodChecker,
132137
executorPodChecker)
133138
}
@@ -141,7 +146,8 @@ private[spark] class KubernetesSuite extends FunSuite with BeforeAndAfterAll wit
141146
executorPodChecker: Pod => Unit): Unit = {
142147
val appArguments = SparkAppArguments(
143148
mainAppResource = appResource,
144-
mainClass = mainClass)
149+
mainClass = mainClass,
150+
appArgs = appArgs)
145151
SparkAppLauncher.launch(appArguments, sparkAppConf, TIMEOUT.value.toSeconds.toInt)
146152

147153
val driverPod = kubernetesTestComponents.kubernetesClient

integration-test/src/test/scala/org/apache/spark/deploy/k8s/integrationtest/KubernetesTestComponents.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ private[spark] class SparkAppConf {
9393

9494
private[spark] case class SparkAppArguments(
9595
mainAppResource: String,
96-
mainClass: String)
96+
mainClass: String,
97+
appArgs: Array[String])
9798

9899
private[spark] object SparkAppLauncher extends Logging {
99100

@@ -106,7 +107,9 @@ private[spark] object SparkAppLauncher extends Logging {
106107
"--deploy-mode", "cluster",
107108
"--class", appArguments.mainClass,
108109
"--master", appConf.get("spark.master")
109-
) ++ appConf.toStringArray :+ appArguments.mainAppResource
110+
) ++ appConf.toStringArray :+
111+
appArguments.mainAppResource :+
112+
appArguments.appArgs.mkString(" ")
110113
logInfo(s"Launching a spark app with command line: ${commandLine.mkString(" ")}")
111114
ProcessUtils.executeProcess(commandLine, timeoutSecs)
112115
}

0 commit comments

Comments
 (0)