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

    https://github.com/apache/spark/pull/17774#discussion_r113753764
  
    --- 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 --
    
    The actual result should be deterministic, why not check the correct value 
instead of just `not None` ?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to