Skip to content

Commit 02b5cea

Browse files
author
Andrew Or
committed
Fix tests
1 parent d2b1ef8 commit 02b5cea

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

core/src/test/scala/org/apache/spark/deploy/SparkSubmitSuite.scala

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,18 @@ class SparkSubmitSuite extends FunSuite with Matchers with ResetSystemProperties
201201
}
202202

203203
test("handles standalone cluster mode") {
204+
testStandaloneCluster(useRest = true)
205+
}
206+
207+
test("handles legacy standalone cluster mode") {
208+
testStandaloneCluster(useRest = false)
209+
}
210+
211+
/**
212+
* Test whether the launch environment is correctly set up in standalone cluster mode.
213+
* @param useRest whether to use the REST submission gateway introduced in Spark 1.3
214+
*/
215+
private def testStandaloneCluster(useRest: Boolean): Unit = {
204216
val clArgs = Seq(
205217
"--deploy-mode", "cluster",
206218
"--master", "spark://h:p",
@@ -212,17 +224,26 @@ class SparkSubmitSuite extends FunSuite with Matchers with ResetSystemProperties
212224
"thejar.jar",
213225
"arg1", "arg2")
214226
val appArgs = new SparkSubmitArguments(clArgs)
227+
appArgs.useRest = useRest
215228
val (childArgs, classpath, sysProps, mainClass) = prepareSubmitEnvironment(appArgs)
216229
val childArgsStr = childArgs.mkString(" ")
217-
childArgsStr should startWith ("--memory 4g --cores 5 --supervise")
218-
childArgsStr should include regex ("launch spark://h:p .*thejar.jar org.SomeClass arg1 arg2")
219-
mainClass should be ("org.apache.spark.deploy.Client")
220-
classpath should have size (0)
221-
sysProps should have size (5)
230+
if (useRest) {
231+
childArgsStr should endWith ("thejar.jar org.SomeClass arg1 arg2")
232+
mainClass should be ("org.apache.spark.deploy.rest.StandaloneRestClient")
233+
} else {
234+
childArgsStr should startWith ("--supervise --memory 4g --cores 5")
235+
childArgsStr should include regex "launch spark://h:p .*thejar.jar org.SomeClass arg1 arg2"
236+
mainClass should be ("org.apache.spark.deploy.Client")
237+
}
238+
classpath should have size 0
239+
sysProps should have size 8
222240
sysProps.keys should contain ("SPARK_SUBMIT")
223241
sysProps.keys should contain ("spark.master")
224242
sysProps.keys should contain ("spark.app.name")
225243
sysProps.keys should contain ("spark.jars")
244+
sysProps.keys should contain ("spark.driver.memory")
245+
sysProps.keys should contain ("spark.driver.cores")
246+
sysProps.keys should contain ("spark.driver.supervise")
226247
sysProps.keys should contain ("spark.shuffle.spill")
227248
sysProps("spark.shuffle.spill") should be ("false")
228249
}

0 commit comments

Comments
 (0)