Skip to content

Commit

Permalink
Eliminate dependency on even distribution by BlockGenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
David McGuire committed Apr 18, 2015
1 parent 8f2934b commit b33b796
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,20 @@ class ReceiverSuite extends TestSuiteBase with Timeouts with Serializable {
s"#records received = $numMessages, not between $minExpectedMessages and $maxExpectedMessages"
)

// XXX Checking every block would require an even distribution of messages across blocks,
// which throttling code does not control. Therefore, test against the average.
val minExpectedMessagesPerBlock = expectedMessagesPerBlock - 0.05 * expectedMessagesPerBlock
val maxExpectedMessagesPerBlock = expectedMessagesPerBlock + 0.05 * expectedMessagesPerBlock
val receivedBlockSizes = recordedBlocks.map { _.size }.mkString(",")

// the first and last block may be incomplete, so we slice them out
val validBlocks = recordedBlocks.drop(1).dropRight(1)
val averageBlockSize = validBlocks.map(block => block.size).sum / validBlocks.size

assert(
// the first and last block may be incomplete, so we slice them out
recordedBlocks.drop(1).dropRight(1).forall { block =>
block.size >= minExpectedMessagesPerBlock && block.size <= maxExpectedMessagesPerBlock
},
averageBlockSize >= minExpectedMessagesPerBlock && averageBlockSize <= maxExpectedMessagesPerBlock,
s"# records in received blocks = [$receivedBlockSizes], not between " +
s"$minExpectedMessagesPerBlock and $maxExpectedMessagesPerBlock"
s"$minExpectedMessagesPerBlock and $maxExpectedMessagesPerBlock, on average"
)
}

Expand Down

0 comments on commit b33b796

Please sign in to comment.