Github user gpang commented on a diff in the pull request:
https://github.com/apache/spark/pull/18098#discussion_r122734682
--- Diff:
resource-managers/mesos/src/test/scala/org/apache/spark/scheduler/cluster/mesos/MesosCoarseGrainedSchedulerBackendSuite.scala
---
@@ -586,6 +586,44 @@ class MesosCoarseGrainedSchedulerBackendSuite extends
SparkFunSuite
assert(backend.isReady)
}
+ test("supports data locality with dynamic allocation") {
+ setBackend(Map(
+ "spark.dynamicAllocation.enabled" -> "true",
+ "spark.dynamicAllocation.testing" -> "true",
+ "spark.locality.wait" -> "2s"))
+
+ assert(backend.getExecutorIds().isEmpty)
+
+ backend.requestTotalExecutors(2, 2, Map("hosts10" -> 1, "hosts11" ->
1))
+
+ // Offer non-local resources, which should be rejected
+ var id = 1
+ offerResources(List(Resources(backend.executorMemory(sc), 1)), id)
+ verifyTaskNotLaunched(driver, s"o$id")
+ id = 2
+ offerResources(List(Resources(backend.executorMemory(sc), 1)), id)
+ verifyTaskNotLaunched(driver, s"o$id")
+
+ // Offer local resource
+ id = 10
+ offerResources(List(Resources(backend.executorMemory(sc), 1)), id)
+ var launchedTasks = verifyTaskLaunched(driver, s"o$id")
+ assert(s"s$id" == launchedTasks.head.getSlaveId.getValue)
+ registerMockExecutor(launchedTasks.head.getTaskId.getValue, s"s$id", 1)
+ assert(backend.getExecutorIds().size == 1)
+
+ // Wait longer than spark.locality.wait
+ Thread.sleep(3000)
+
+ // Offer non-local resource, which should be accepted
+ id = 1
+ offerResources(List(Resources(backend.executorMemory(sc), 1)), id)
+ launchedTasks = verifyTaskLaunched(driver, s"o$id")
+ assert(s"s$id" == launchedTasks.head.getSlaveId.getValue)
+ registerMockExecutor(launchedTasks.head.getTaskId.getValue, s"s$id", 1)
+ assert(backend.getExecutorIds().size == 2)
+ }
--- End diff --
Updated test to increase test coverage.
---
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]