lucasbru commented on code in PR #15965:
URL: https://github.com/apache/kafka/pull/15965#discussion_r1603953323
##########
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:
Could you not use the helper method below here?
--
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]