Github user pwendell commented on a diff in the pull request:
https://github.com/apache/spark/pull/1487#discussion_r15156158
--- Diff:
core/src/test/scala/org/apache/spark/scheduler/mesos/MesosSchedulerBackendSuite.scala
---
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.scheduler.mesos
+
+import org.scalatest.FunSuite
+import org.apache.spark.{SparkConf, SparkContext, LocalSparkContext}
+import org.apache.spark.scheduler.{TaskDescription, WorkerOffer,
TaskSchedulerImpl}
+import org.apache.spark.scheduler.cluster.mesos.MesosSchedulerBackend
+import org.apache.mesos.SchedulerDriver
+import org.apache.mesos.Protos._
+import org.scalatest.mock.EasyMockSugar
+import org.apache.mesos.Protos.Value.Scalar
+import org.easymock.{Capture, EasyMock}
+import java.nio.ByteBuffer
+import java.util.Collections
+import java.util
+
+class MesosSchedulerBackendSuite extends FunSuite with LocalSparkContext
with EasyMockSugar {
+ test("mesos resource offer is launching tasks") {
+ def createOffer(id: Int, mem: Int, cpu: Int) = {
+ val builder = Offer.newBuilder()
+ builder.addResourcesBuilder()
+ .setName("mem")
+ .setType(Value.Type.SCALAR)
+ .setScalar(Scalar.newBuilder().setValue(mem))
+ builder.addResourcesBuilder()
+ .setName("cpus")
+ .setType(Value.Type.SCALAR)
+ .setScalar(Scalar.newBuilder().setValue(cpu))
+
builder.setId(OfferID.newBuilder().setValue(id.toString).build()).setFrameworkId(FrameworkID.newBuilder().setValue("f1"))
+
.setSlaveId(SlaveID.newBuilder().setValue("s1")).setHostname("localhost").build()
+ }
+
+ val driver = EasyMock.createMock(classOf[SchedulerDriver])
+ val taskScheduler = EasyMock.createMock(classOf[TaskSchedulerImpl])
+ val offers = new java.util.ArrayList[Offer]
+ offers.add(createOffer(1, 101, 1))
+ offers.add(createOffer(1, 99, 1))
+
+ val conf = new SparkConf
+ conf.set("spark.executor.memory", "100m")
+ conf.set("spark.home", "/path")
+ val sc = new SparkContext("local-cluster[2 , 1 , 512]", "test", conf)
--- End diff --
it would be better not to create a whole SparkContext here for the tests
(creating a local context like this is really expensive). Instead, could this
test just create a MesosSchedulerBackend directly? I think you can even just
pass it `null` for the SparkContext (or you could mock one, depending on how it
is used).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---