kavpreetgrewal commented on code in PR #54339:
URL: https://github.com/apache/spark/pull/54339#discussion_r2823895064
##########
connector/kafka-0-10-sql/src/test/scala/org/apache/spark/sql/kafka010/KafkaOffsetReaderSuite.scala:
##########
@@ -263,4 +266,60 @@ class KafkaOffsetReaderSuite extends QueryTest with
SharedSparkSession with Kafk
}
}
}
+
+ private def createReaderWithMockedStrategy(
+ mockStrategy: ConsumerStrategy): KafkaOffsetReaderAdmin = {
+ new KafkaOffsetReaderAdmin(
+ mockStrategy,
+ KafkaSourceProvider.kafkaParamsForDriver(Map(
+ "bootstrap.servers" -> testUtils.brokerAddress
+ )),
+ CaseInsensitiveMap(Map(
+ KafkaSourceProvider.FETCH_OFFSET_NUM_RETRY -> "3",
+ KafkaSourceProvider.FETCH_OFFSET_RETRY_INTERVAL_MS -> "0"
+ )),
+ ""
+ )
+ }
+
+ test("SPARK-55561: fetchPartitionOffsets retries on transient failures") {
+ val tp0 = new TopicPartition("topic", 0)
+ val tp1 = new TopicPartition("topic", 1)
+ val expectedPartitions = Set(tp0, tp1)
+
+ val mockStrategy = mock(classOf[ConsumerStrategy])
+ val mockAdmin = mock(classOf[Admin])
+ when(mockStrategy.createAdmin(any())).thenReturn(mockAdmin)
+ when(mockStrategy.assignedTopicPartitions(any()))
+ .thenThrow(new RuntimeException("Transient error"))
+ .thenThrow(new RuntimeException("Transient error"))
+ .thenReturn(expectedPartitions)
+
+ val reader = createReaderWithMockedStrategy(mockStrategy)
+ try {
Review Comment:
Added
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]