Github user dragos commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8872#discussion_r42724448
  
    --- Diff: 
core/src/test/scala/org/apache/spark/scheduler/mesos/MesosClusterSchedulerSuite.scala
 ---
    @@ -72,4 +78,56 @@ class MesosClusterSchedulerSuite extends SparkFunSuite 
with LocalSparkContext wi
         val state = scheduler.getSchedulerState()
         assert(state.queuedDrivers.isEmpty)
       }
    +
    +  test("can handle multiple roles") {
    +    val conf = new SparkConf()
    +    conf.setMaster("mesos://localhost:5050")
    +    conf.setAppName("spark mesos")
    +    val scheduler = new MesosClusterScheduler(
    +      new BlackHoleMesosClusterPersistenceEngineFactory, conf) {
    +      override def start(): Unit = { ready = true }
    +    }
    +    scheduler.start()
    +    val driver = mock[SchedulerDriver]
    +    val response = scheduler.submitDriver(
    +      new MesosDriverDescription("d1", "jar", 1500, 1, true,
    +        command,
    +        Map(("spark.mesos.executor.home", "test"), ("spark.app.name", 
"test")),
    +        "s1",
    +        new Date()))
    +    assert(response.success)
    +    val offer = Offer.newBuilder()
    +      .addResources(
    +        Resource.newBuilder().setRole("*")
    +          
.setScalar(Scalar.newBuilder().setValue(1).build()).setName("cpus").setType(Type.SCALAR))
    +      .addResources(
    +        Resource.newBuilder().setRole("*")
    +          
.setScalar(Scalar.newBuilder().setValue(1000).build()).setName("mem").setType(Type.SCALAR))
    +      .addResources(
    +        Resource.newBuilder().setRole("role2")
    +          
.setScalar(Scalar.newBuilder().setValue(1).build()).setName("cpus").setType(Type.SCALAR))
    +      .addResources(
    +        Resource.newBuilder().setRole("role2")
    +          
.setScalar(Scalar.newBuilder().setValue(500).build()).setName("mem").setType(Type.SCALAR))
    +      .setId(OfferID.newBuilder().setValue("o1").build())
    +      .setFrameworkId(FrameworkID.newBuilder().setValue("f1").build())
    +      .setSlaveId(SlaveID.newBuilder().setValue("s1").build())
    +      .setHostname("host1")
    +      .build()
    +
    +    val capture = ArgumentCaptor.forClass(classOf[Collection[TaskInfo]])
    +
    +    when(
    +      driver.launchTasks(
    +        Matchers.eq(Collections.singleton(offer.getId)),
    +        capture.capture())
    +    ).thenReturn(Status.valueOf(1))
    +
    +    scheduler.resourceOffers(driver, List(offer).asJava)
    +
    +    verify(driver, times(1)).launchTasks(
    --- End diff --
    
    Can you also test that the role is set? In other words, would this test 
fail without this patch?


---
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.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to