lianetm commented on code in PR #15965:
URL: https://github.com/apache/kafka/pull/15965#discussion_r1605041571

##########
core/src/test/scala/integration/kafka/api/PlaintextConsumerCallbackTest.scala:
##########
@@ -84,29 +84,87 @@ class PlaintextConsumerCallbackTest extends 
AbstractConsumerTest {
   @ParameterizedTest(name = 
TestInfoUtils.TestWithParameterizedQuorumAndGroupProtocolNames)
   @MethodSource(Array("getTestQuorumAndGroupProtocolParametersAll"))
   def testConsumerRebalanceListenerBeginningOffsetsOnPartitionsRevoked(quorum: 
String, groupProtocol: String): Unit = {
-    val tp = new TopicPartition(topic, 0);
+    val tp = new TopicPartition(topic, 0)
     triggerOnPartitionsRevoked { (consumer, _) =>
       val map = consumer.beginningOffsets(Collections.singletonList(tp))
       assertTrue(map.containsKey(tp))
       assertEquals(0, map.get(tp))
     }
   }
 
+  @ParameterizedTest(name = 
TestInfoUtils.TestWithParameterizedQuorumAndGroupProtocolNames)
+  @MethodSource(Array("getTestQuorumAndGroupProtocolParametersAll"))
+  def 
testGetPositionOfNewlyAssignedPartitionOnPartitionsAssignedCallback(quorum: 
String, groupProtocol: String): Unit = {
+    val tp = new TopicPartition(topic, 0)
+    triggerOnPartitionsAssigned { (consumer, _) => assertDoesNotThrow(() => 
consumer.position(tp)) }
+  }
+
+  @ParameterizedTest(name = 
TestInfoUtils.TestWithParameterizedQuorumAndGroupProtocolNames)
+  @MethodSource(Array("getTestQuorumAndGroupProtocolParametersAll"))
+  def 
testSeekPositionOfNewlyAssignedPartitionOnPartitionsAssignedCallback(quorum: 
String, groupProtocol: String): Unit = {
+    val consumer = createConsumer()
+    val startingOffset = 100L
+    val totalRecords = 120L
+
+    val producer = createProducer()
+    val startingTimestamp = 0
+    sendRecords(producer, totalRecords.toInt, tp, startingTimestamp)
+
+    consumer.subscribe(asList(topic), new ConsumerRebalanceListener {
+      override def onPartitionsAssigned(partitions: 
util.Collection[TopicPartition]): Unit = {
+        consumer.seek(tp, startingOffset)
+      }
+
+      override def onPartitionsRevoked(partitions: 
util.Collection[TopicPartition]): Unit = {
+        // noop
+      }
+    })
+    consumeAndVerifyRecords(consumer, numRecords = (totalRecords - 
startingOffset).toInt,
+      startingOffset = startingOffset.toInt, startingKeyAndValueIndex = 
startingOffset.toInt,
+      startingTimestamp = startingOffset)
+  }
+
+  @ParameterizedTest(name = 
TestInfoUtils.TestWithParameterizedQuorumAndGroupProtocolNames)
+  @MethodSource(Array("getTestQuorumAndGroupProtocolParametersAll"))
+  def testPauseOnPartitionsAssignedCallback(quorum: String, groupProtocol: 
String): Unit = {
+    val consumer = createConsumer()
+    val totalRecords = 100L
+    val partitionsAssigned = new AtomicBoolean(false)
+
+    val producer = createProducer()
+    val startingTimestamp = 0
+    sendRecords(producer, totalRecords.toInt, tp, startingTimestamp)
+
+    consumer.subscribe(asList(topic), new ConsumerRebalanceListener {

Review Comment:
   I couldn't initially mainly because of the close and poll in the helper, 
that played against what I needed to test in these 2, but then I myself removed 
the close and forgot to try again :). So I did integrate the helper here now, 
with a minor twist  to pass the consumer as param. Also it allowed me to 
simplify the seek/pause test in one, given that we do need to pause to properly 
check the seek behaviour, so removed the extra test for pause. Good catch, 
thanks!



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to