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

    https://github.com/apache/spark/pull/17774#discussion_r113871876
  
    --- Diff: 
external/kafka-0-10/src/test/scala/org/apache/spark/streaming/kafka010/DirectKafkaStreamSuite.scala
 ---
    @@ -617,6 +617,94 @@ class DirectKafkaStreamSuite
         ssc.stop()
       }
     
    +  test("maxMessagesPerPartition with rate equal to one") {
    +    val topic = "backpressure"
    +    val kafkaParams = getKafkaParams()
    +    val batchIntervalMilliseconds = 10000
    +    val sparkConf = new SparkConf()
    +      // Safe, even with streaming, because we're using the direct API.
    +      // Using 1 core is useful to make the test more predictable.
    +      .setMaster("local[1]")
    +      .setAppName(this.getClass.getSimpleName)
    +      .set("spark.streaming.kafka.maxRatePerPartition", "100")
    +
    +    // Setup the streaming context
    +    ssc = new StreamingContext(sparkConf, 
Milliseconds(batchIntervalMilliseconds))
    +    val estimatedRate = 1
    +    val fromOffsets = Map(
    +      new TopicPartition(topic, 0) -> 0L,
    +      new TopicPartition(topic, 1) -> 0L,
    +      new TopicPartition(topic, 2) -> 0L
    +    )
    +    val kafkaStream = withClue("Error creating direct stream") {
    +      new DirectKafkaInputDStream[String, String](
    +        ssc,
    +        preferredHosts,
    +        ConsumerStrategies.Subscribe[String, String](List(topic), 
kafkaParams.asScala),
    +        new DefaultPerPartitionConfig(sparkConf)
    +      ) {
    +        currentOffsets = fromOffsets
    +        override val rateController = Some(new ConstantRateController(id, 
null, estimatedRate))
    +      }
    +    }
    +
    +    val offsets = Map[TopicPartition, Long](
    +      new TopicPartition(topic, 0) -> 100L,
    +      new TopicPartition(topic, 1) -> 100L,
    +      new TopicPartition(topic, 2) -> 100L
    +    )
    +    val result = kafkaStream.maxMessagesPerPartition(offsets)
    +    assert(result.isDefined, s"Messages per partitions should exist for 
estimated rate of 1")
    --- End diff --
    
    After omitting the case of zero messages per topic, one of the tests is 
redundant. I removed it from each `DirectKafkaStreamSuite`.


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