@@ -42,6 +42,38 @@ import org.apache.spark.{LocalSparkContext, SparkConf, SparkContext, SparkFunSui
42
42
43
43
class MesosSchedulerBackendSuite extends SparkFunSuite with LocalSparkContext with MockitoSugar {
44
44
45
+ test(" Use configured mesosExecutor.cores for ExecutorInfo" ) {
46
+ val mesosExecutorCores = 3
47
+ val conf = new SparkConf
48
+ conf.set(" spark.mesos.mesosExecutor.cores" , mesosExecutorCores.toString)
49
+
50
+ val listenerBus = mock[LiveListenerBus ]
51
+ listenerBus.post(
52
+ SparkListenerExecutorAdded (anyLong, " s1" , new ExecutorInfo (" host1" , 2 , Map .empty)))
53
+
54
+ val sc = mock[SparkContext ]
55
+ when(sc.getSparkHome()).thenReturn(Option (" /spark-home" ))
56
+
57
+ when(sc.conf).thenReturn(conf)
58
+ when(sc.executorEnvs).thenReturn(new mutable.HashMap [String , String ])
59
+ when(sc.executorMemory).thenReturn(100 )
60
+ when(sc.listenerBus).thenReturn(listenerBus)
61
+ val taskScheduler = mock[TaskSchedulerImpl ]
62
+ when(taskScheduler.CPUS_PER_TASK ).thenReturn(2 )
63
+
64
+ val mesosSchedulerBackend = new MesosSchedulerBackend (taskScheduler, sc, " master" )
65
+
66
+ val resources = Arrays .asList(
67
+ mesosSchedulerBackend.createResource(" cpus" , 4 ),
68
+ mesosSchedulerBackend.createResource(" mem" , 1024 ))
69
+ // uri is null.
70
+ val (executorInfo, _) = mesosSchedulerBackend.createExecutorInfo(resources, " test-id" )
71
+ val executorResources = executorInfo.getResourcesList
72
+ val cpus = executorResources.asScala.find(_.getName.equals(" cpus" )).get.getScalar.getValue
73
+
74
+ assert(cpus === mesosExecutorCores)
75
+ }
76
+
45
77
test(" check spark-class location correctly" ) {
46
78
val conf = new SparkConf
47
79
conf.set(" spark.mesos.executor.home" , " /mesos-home" )
@@ -263,7 +295,6 @@ class MesosSchedulerBackendSuite extends SparkFunSuite with LocalSparkContext wi
263
295
.setSlaveId(SlaveID .newBuilder().setValue(s " s ${id.toString}" ))
264
296
.setHostname(s " host ${id.toString}" ).build()
265
297
266
-
267
298
val mesosOffers = new java.util.ArrayList [Offer ]
268
299
mesosOffers.add(offer)
269
300
0 commit comments