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

    https://github.com/apache/spark/pull/4957#discussion_r26113197
  
    --- Diff: 
streaming/src/test/scala/org/apache/spark/streaming/ReceiverSuite.scala ---
    @@ -161,50 +161,27 @@ class ReceiverSuite extends TestSuiteBase with 
Timeouts with Serializable {
         val maxRate = 100
         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]
    +    val generatedData = 0 until expectedMessages
     
         // Generate blocks
         val startTime = System.currentTimeMillis()
    +    val blockGenerator = new BlockGenerator(blockGeneratorListener, 1, 
conf)
         blockGenerator.start()
    -    var count = 0
    -    while(System.currentTimeMillis - startTime < waitTime) {
    -      blockGenerator.addData(count)
    -      generatedData += count
    -      count += 1
    -      Thread.sleep(1)
    -    }
    +    generatedData.foreach(blockGenerator.addData(_))
         blockGenerator.stop()
    +    val endTime = System.currentTimeMillis()
     
    +    // should have been rate limited
    +    assert(endTime - startTime >= waitTime, "Should have taken longer than 
the theoretical minimum time")
    +
    +    // we should get the same data
         val recordedBlocks = blockGeneratorListener.arrayBuffers
         val recordedData = recordedBlocks.flatten
         assert(blockGeneratorListener.arrayBuffers.size > 0, "No blocks 
received")
         assert(recordedData.toSet === generatedData.toSet, "Received data not 
same")
    -
    --- End diff --
    
    The thing is, it doesn't actually seem to do that. The test is expecting to 
get ~10 messages per block. I ran the test a few times and saw numbers like 49 
and 1. I also got corresponding varying numbers of messages.
    
    I'll have another look and see if I can find a more reliable way of doing 
this.


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