prat0318 commented on a change in pull request #11552: URL: https://github.com/apache/kafka/pull/11552#discussion_r769902172
########## File path: clients/src/test/java/org/apache/kafka/clients/MetadataTest.java ########## @@ -372,6 +372,31 @@ public void testUpdateLastEpoch() { assertOptional(metadata.lastSeenLeaderEpoch(tp), leaderAndEpoch -> assertEquals(leaderAndEpoch.intValue(), 12)); } + @Test + public void testEpochUpdateAfterTopicDeletion() { + TopicPartition tp = new TopicPartition("topic-1", 0); + Map<String, Uuid> topicIds = Collections.singletonMap("topic-1", Uuid.randomUuid()); + + MetadataResponse metadataResponse = emptyMetadataResponse(); + metadata.updateWithCurrentRequestVersion(metadataResponse, false, 0L); + + // Start with a topic A with a topic ID foo + metadataResponse = RequestTestUtils.metadataUpdateWithIds("dummy", 1, Collections.emptyMap(), Collections.singletonMap("topic-1", 1), _tp -> 10, topicIds); + metadata.updateWithCurrentRequestVersion(metadataResponse, false, 1L); + assertEquals(Optional.of(10), metadata.lastSeenLeaderEpoch(tp)); + + // Topic A is now deleted so Response contains an Error. LeaderEpoch should still return maintain Old value Review comment: removed. ########## File path: clients/src/test/java/org/apache/kafka/clients/MetadataTest.java ########## @@ -372,6 +372,31 @@ public void testUpdateLastEpoch() { assertOptional(metadata.lastSeenLeaderEpoch(tp), leaderAndEpoch -> assertEquals(leaderAndEpoch.intValue(), 12)); } + @Test + public void testEpochUpdateAfterTopicDeletion() { + TopicPartition tp = new TopicPartition("topic-1", 0); + Map<String, Uuid> topicIds = Collections.singletonMap("topic-1", Uuid.randomUuid()); + + MetadataResponse metadataResponse = emptyMetadataResponse(); + metadata.updateWithCurrentRequestVersion(metadataResponse, false, 0L); + + // Start with a topic A with a topic ID foo + metadataResponse = RequestTestUtils.metadataUpdateWithIds("dummy", 1, Collections.emptyMap(), Collections.singletonMap("topic-1", 1), _tp -> 10, topicIds); + metadata.updateWithCurrentRequestVersion(metadataResponse, false, 1L); + assertEquals(Optional.of(10), metadata.lastSeenLeaderEpoch(tp)); + + // Topic A is now deleted so Response contains an Error. LeaderEpoch should still return maintain Old value + metadataResponse = RequestTestUtils.metadataUpdateWith("dummy", 1, Collections.singletonMap("topic-1", Errors.UNKNOWN_TOPIC_OR_PARTITION), new HashMap<>()); Review comment: ack -- 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