Skip to content

Commit

Permalink
Update ReceiverTrackerSuite.scala
Browse files Browse the repository at this point in the history
  • Loading branch information
nishkamravi2 committed Jun 23, 2015
1 parent f747739 commit 1918819
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ReceiverTrackerSuite extends TestSuiteBase {
val executors: List[String] = List("0", "1", "2", "3")

test("receiver scheduling - all or none have preferred location") {

def parse(s: String): Array[Array[String]] = {
val outerSplit = s.split("\\|")
val loc = new Array[Array[String]](outerSplit.length)
Expand All @@ -41,18 +42,20 @@ class ReceiverTrackerSuite extends TestSuiteBase {
}
loc
}

def testScheduler(numReceivers: Int, preferredLocation: Boolean, allocation: String) {
val receivers =
if (preferredLocation) {
(0 until numReceivers).map(i => new DummyReceiver(host =
Array.tabulate(numReceivers)(i => new DummyReceiver(host =
Some(((i + 1) % executors.length).toString)))
} else {
(0 until numReceivers).map(i => new DummyReceiver)
Array.tabulate(numReceivers)(_ => new DummyReceiver)
}
val locations = launcher.scheduleReceivers(receivers, executors)
val expectedLocations = parse(allocation)
assert(locations.deep === expectedLocations.deep)
}

testScheduler(numReceivers = 5, preferredLocation = false, allocation = "0|1|2|3|0")
testScheduler(numReceivers = 3, preferredLocation = false, allocation = "0,3|1|2")
testScheduler(numReceivers = 4, preferredLocation = true, allocation = "1|2|3|0")
Expand Down

0 comments on commit 1918819

Please sign in to comment.