Github user JoshRosen commented on a diff in the pull request:
https://github.com/apache/spark/pull/945#discussion_r17558868
--- Diff:
streaming/src/test/scala/org/apache/spark/streaming/NetworkReceiverSuite.scala
---
@@ -146,6 +146,44 @@ class NetworkReceiverSuite extends FunSuite with
Timeouts {
assert(recordedData.toSet === generatedData.toSet)
}
+ test("block generator throttling") {
+ val blockGeneratorListener = new FakeBlockGeneratorListener
+ val blockInterval = 50
+ val maxRate = 200
+ val conf = new SparkConf().set("spark.streaming.blockInterval",
blockInterval.toString).
+ set("spark.streaming.receiver.maxRate", maxRate.toString)
+ val blockGenerator = new BlockGenerator(blockGeneratorListener, 1,
conf)
+ val expectedBlocks = 20
+ val waitTime = expectedBlocks * blockInterval
+ val expectedMessages = maxRate * waitTime / 1000
+ val expectedMessagesPerBlock = maxRate * blockInterval / 1000
+ val generatedData = new ArrayBuffer[Int]
+
+ // Generate blocks
+ val startTime = System.currentTimeMillis()
+ blockGenerator.start()
+ var count = 0
+ while(System.currentTimeMillis - startTime < waitTime) {
+ blockGenerator += count
+ generatedData += count
+ count += 1
+ Thread.sleep(1)
+ }
+ blockGenerator.stop()
+
+ val recordedData = blockGeneratorListener.arrayBuffers
+ assert(blockGeneratorListener.arrayBuffers.size > 0)
+ assert(recordedData.flatten.toSet === generatedData.toSet)
+ // recordedData size should be close to the expected rate
+ assert(recordedData.flatten.size >= expectedMessages * 0.9 &&
+ recordedData.flatten.size <= expectedMessages * 1.1 )
+ // the first and last block may be incomplete, so we slice them out
+ recordedData.slice(1, recordedData.size - 1).foreach { block =>
+ assert(block.size >= expectedMessagesPerBlock * 0.8 &&
--- End diff --
This test is still a frequent cause of Jenkins failures; I'm investigating
fixes, but I'd appreciate help.
---
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]