MarcoLotz commented on a change in pull request #10042:
URL: https://github.com/apache/kafka/pull/10042#discussion_r579543547
##########
File path:
streams/src/test/java/org/apache/kafka/streams/tools/StreamsResetterTest.java
##########
@@ -76,6 +78,25 @@ public void
testResetToSpecificOffsetWhenBetweenBeginningAndEndOffset() {
assertEquals(3, records.count());
}
+ @Test
+ public void testResetToSpecificOffsetWhenPartitionIsEmpty() {
+ final MockConsumer<byte[], byte[]> emptyConsumer = new
MockConsumer<>(OffsetResetStrategy.EARLIEST);
+ emptyConsumer.assign(Collections.singletonList(topicPartition));
+
+ final Map<TopicPartition, Long> endOffsets = new HashMap<>();
+ endOffsets.put(topicPartition, 0L);
+ emptyConsumer.updateEndOffsets(endOffsets);
+
+ final Map<TopicPartition, Long> beginningOffsets = new HashMap<>();
+ beginningOffsets.put(topicPartition, 0L);
+ emptyConsumer.updateBeginningOffsets(beginningOffsets);
+
+ streamsResetter.resetOffsetsTo(emptyConsumer, inputTopicPartitions,
2L);
+
+ final ConsumerRecords<byte[], byte[]> records =
emptyConsumer.poll(Duration.ofMillis(500));
+ assertEquals(0, records.count());
Review comment:
@mjsax I have changed the PR to make sure that the tests verify the
committed offset. It seems to me, however, that the original test implementer
intent was to verify the position of the consumer after the method call - not
if it committed the offset. Specially because the ```position()``` and
```commitAsync()``` calls happen outside the methods under test.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]