@@ -87,25 +87,41 @@ class SparkSubmitSuite extends FunSuite with ShouldMatchers {
8787 }
8888
8989 test(" handles arguments with --key=val" ) {
90- val clArgs = Seq (" --jars=one.jar,two.jar,three.jar" , " --name=myApp" )
90+ val clArgs = Seq (
91+ " --jars=one.jar,two.jar,three.jar" ,
92+ " --name=myApp" )
9193 val appArgs = new SparkSubmitArguments (clArgs)
9294 appArgs.jars should be (" one.jar,two.jar,three.jar" )
9395 appArgs.name should be (" myApp" )
9496 }
9597
9698 test(" handles arguments to user program" ) {
97- val clArgs = Seq (" --name" , " myApp" , " --class" , " Foo" , " userjar.jar" , " some" , " --weird" , " args" )
99+ val clArgs = Seq (
100+ " --name" , " myApp" ,
101+ " --class" , " Foo" ,
102+ " userjar.jar" ,
103+ " some" ,
104+ " --weird" , " args" )
98105 val appArgs = new SparkSubmitArguments (clArgs)
99106 appArgs.childArgs should be (Seq (" some" , " --weird" , " args" ))
100107 }
101108
102109 test(" handles YARN cluster mode" ) {
103- val clArgs = Seq (" --deploy-mode" , " cluster" ,
104- " --master" , " yarn" , " --executor-memory" , " 5g" , " --executor-cores" , " 5" ,
105- " --class" , " org.SomeClass" , " --jars" , " one.jar,two.jar,three.jar" ,
106- " --driver-memory" , " 4g" , " --queue" , " thequeue" , " --files" , " file1.txt,file2.txt" ,
107- " --archives" , " archive1.txt,archive2.txt" , " --num-executors" , " 6" , " --name" , " beauty" ,
108- " thejar.jar" , " arg1" , " arg2" )
110+ val clArgs = Seq (
111+ " --deploy-mode" , " cluster" ,
112+ " --master" , " yarn" ,
113+ " --executor-memory" , " 5g" ,
114+ " --executor-cores" , " 5" ,
115+ " --class" , " org.SomeClass" ,
116+ " --jars" , " one.jar,two.jar,three.jar" ,
117+ " --driver-memory" , " 4g" ,
118+ " --queue" , " thequeue" ,
119+ " --files" , " file1.txt,file2.txt" ,
120+ " --archives" , " archive1.txt,archive2.txt" ,
121+ " --num-executors" , " 6" ,
122+ " --name" , " beauty" ,
123+ " thejar.jar" ,
124+ " arg1" , " arg2" )
109125 val appArgs = new SparkSubmitArguments (clArgs)
110126 val (childArgs, classpath, sysProps, mainClass) = createLaunchEnv(appArgs)
111127 val childArgsStr = childArgs.mkString(" " )
@@ -127,12 +143,21 @@ class SparkSubmitSuite extends FunSuite with ShouldMatchers {
127143 }
128144
129145 test(" handles YARN client mode" ) {
130- val clArgs = Seq (" --deploy-mode" , " client" ,
131- " --master" , " yarn" , " --executor-memory" , " 5g" , " --executor-cores" , " 5" ,
132- " --class" , " org.SomeClass" , " --jars" , " one.jar,two.jar,three.jar" ,
133- " --driver-memory" , " 4g" , " --queue" , " thequeue" , " --files" , " file1.txt,file2.txt" ,
134- " --archives" , " archive1.txt,archive2.txt" , " --num-executors" , " 6" , " --name" , " trill" ,
135- " thejar.jar" , " arg1" , " arg2" )
146+ val clArgs = Seq (
147+ " --deploy-mode" , " client" ,
148+ " --master" , " yarn" ,
149+ " --executor-memory" , " 5g" ,
150+ " --executor-cores" , " 5" ,
151+ " --class" , " org.SomeClass" ,
152+ " --jars" , " one.jar,two.jar,three.jar" ,
153+ " --driver-memory" , " 4g" ,
154+ " --queue" , " thequeue" ,
155+ " --files" , " file1.txt,file2.txt" ,
156+ " --archives" , " archive1.txt,archive2.txt" ,
157+ " --num-executors" , " 6" ,
158+ " --name" , " trill" ,
159+ " thejar.jar" ,
160+ " arg1" , " arg2" )
136161 val appArgs = new SparkSubmitArguments (clArgs)
137162 val (childArgs, classpath, sysProps, mainClass) = createLaunchEnv(appArgs)
138163 childArgs.mkString(" " ) should be (" arg1 arg2" )
@@ -142,6 +167,7 @@ class SparkSubmitSuite extends FunSuite with ShouldMatchers {
142167 classpath should contain (" two.jar" )
143168 classpath should contain (" three.jar" )
144169 sysProps(" spark.app.name" ) should be (" trill" )
170+ sysProps(" spark.jars" ) should be (" one.jar,two.jar,three.jar,thejar.jar" )
145171 sysProps(" spark.executor.memory" ) should be (" 5g" )
146172 sysProps(" spark.executor.cores" ) should be (" 5" )
147173 sysProps(" spark.yarn.queue" ) should be (" thequeue" )
@@ -152,9 +178,15 @@ class SparkSubmitSuite extends FunSuite with ShouldMatchers {
152178 }
153179
154180 test(" handles standalone cluster mode" ) {
155- val clArgs = Seq (" --deploy-mode" , " cluster" ,
156- " --master" , " spark://h:p" , " --class" , " org.SomeClass" ,
157- " --supervise" , " --driver-memory" , " 4g" , " --driver-cores" , " 5" , " thejar.jar" , " arg1" , " arg2" )
181+ val clArgs = Seq (
182+ " --deploy-mode" , " cluster" ,
183+ " --master" , " spark://h:p" ,
184+ " --class" , " org.SomeClass" ,
185+ " --supervise" ,
186+ " --driver-memory" , " 4g" ,
187+ " --driver-cores" , " 5" ,
188+ " thejar.jar" ,
189+ " arg1" , " arg2" )
158190 val appArgs = new SparkSubmitArguments (clArgs)
159191 val (childArgs, classpath, sysProps, mainClass) = createLaunchEnv(appArgs)
160192 val childArgsStr = childArgs.mkString(" " )
@@ -166,9 +198,15 @@ class SparkSubmitSuite extends FunSuite with ShouldMatchers {
166198 }
167199
168200 test(" handles standalone client mode" ) {
169- val clArgs = Seq (" --deploy-mode" , " client" ,
170- " --master" , " spark://h:p" , " --executor-memory" , " 5g" , " --total-executor-cores" , " 5" ,
171- " --class" , " org.SomeClass" , " --driver-memory" , " 4g" , " thejar.jar" , " arg1" , " arg2" )
201+ val clArgs = Seq (
202+ " --deploy-mode" , " client" ,
203+ " --master" , " spark://h:p" ,
204+ " --executor-memory" , " 5g" ,
205+ " --total-executor-cores" , " 5" ,
206+ " --class" , " org.SomeClass" ,
207+ " --driver-memory" , " 4g" ,
208+ " thejar.jar" ,
209+ " arg1" , " arg2" )
172210 val appArgs = new SparkSubmitArguments (clArgs)
173211 val (childArgs, classpath, sysProps, mainClass) = createLaunchEnv(appArgs)
174212 childArgs.mkString(" " ) should be (" arg1 arg2" )
@@ -179,9 +217,15 @@ class SparkSubmitSuite extends FunSuite with ShouldMatchers {
179217 }
180218
181219 test(" handles mesos client mode" ) {
182- val clArgs = Seq (" --deploy-mode" , " client" ,
183- " --master" , " mesos://h:p" , " --executor-memory" , " 5g" , " --total-executor-cores" , " 5" ,
184- " --class" , " org.SomeClass" , " --driver-memory" , " 4g" , " thejar.jar" , " arg1" , " arg2" )
220+ val clArgs = Seq (
221+ " --deploy-mode" , " client" ,
222+ " --master" , " mesos://h:p" ,
223+ " --executor-memory" , " 5g" ,
224+ " --total-executor-cores" , " 5" ,
225+ " --class" , " org.SomeClass" ,
226+ " --driver-memory" , " 4g" ,
227+ " thejar.jar" ,
228+ " arg1" , " arg2" )
185229 val appArgs = new SparkSubmitArguments (clArgs)
186230 val (childArgs, classpath, sysProps, mainClass) = createLaunchEnv(appArgs)
187231 childArgs.mkString(" " ) should be (" arg1 arg2" )
@@ -192,15 +236,17 @@ class SparkSubmitSuite extends FunSuite with ShouldMatchers {
192236 }
193237
194238 test(" launch simple application with spark-submit" ) {
195- runSparkSubmit(
196- Seq (
197- " --class" , SimpleApplicationTest .getClass.getName.stripSuffix(" $" ),
198- " --name" , " testApp" ,
199- " --master" , " local" ,
200- " unUsed.jar" ))
239+ val unusedJar = TestUtils .createJarWithClasses(Seq .empty)
240+ val args = Seq (
241+ " --class" , SimpleApplicationTest .getClass.getName.stripSuffix(" $" ),
242+ " --name" , " testApp" ,
243+ " --master" , " local" ,
244+ unusedJar.toString)
245+ runSparkSubmit(args)
201246 }
202247
203248 test(" spark submit includes jars passed in through --jar" ) {
249+ val unusedJar = TestUtils .createJarWithClasses(Seq .empty)
204250 val jar1 = TestUtils .createJarWithClasses(Seq (" SparkSubmitClassA" ))
205251 val jar2 = TestUtils .createJarWithClasses(Seq (" SparkSubmitClassB" ))
206252 val jarsString = Seq (jar1, jar2).map(j => j.toString).mkString(" ," )
@@ -209,7 +255,7 @@ class SparkSubmitSuite extends FunSuite with ShouldMatchers {
209255 " --name" , " testApp" ,
210256 " --master" , " local-cluster[2,1,512]" ,
211257 " --jars" , jarsString,
212- " unused.jar " )
258+ unusedJar.toString )
213259 runSparkSubmit(args)
214260 }
215261
@@ -227,7 +273,7 @@ object JarCreationTest {
227273 def main (args : Array [String ]) {
228274 val conf = new SparkConf ()
229275 val sc = new SparkContext (conf)
230- val result = sc.makeRDD(1 to 100 , 10 ).mapPartitions{ x =>
276+ val result = sc.makeRDD(1 to 100 , 10 ).mapPartitions { x =>
231277 var foundClasses = false
232278 try {
233279 Class .forName(" SparkSubmitClassA" , true , Thread .currentThread().getContextClassLoader)
@@ -248,7 +294,6 @@ object SimpleApplicationTest {
248294 def main (args : Array [String ]) {
249295 val conf = new SparkConf ()
250296 val sc = new SparkContext (conf)
251-
252297 val configs = Seq (" spark.master" , " spark.app.name" )
253298 for (config <- configs) {
254299 val masterValue = conf.get(config)
@@ -266,6 +311,5 @@ object SimpleApplicationTest {
266311 s " Master had $config= $masterValue but executor had $config= $executorValue" )
267312 }
268313 }
269-
270314 }
271315}
0 commit comments