jolshan commented on a change in pull request #11331: URL: https://github.com/apache/kafka/pull/11331#discussion_r746785542
########## File path: core/src/test/scala/unit/kafka/server/KafkaApisTest.scala ########## @@ -2440,6 +2442,57 @@ class KafkaApisTest { assertNull(partitionData.abortedTransactions) } + /** + * Verifies that partitions with unknown topic ID errors are added to the erroneous set and there is not an attempt to fetch them. + */ + @Test + def testFetchRequestErroneousPartitions(): Unit = { + val tidp = new TopicIdPartition(Uuid.randomUuid(), new TopicPartition("foo", 0)) + val tp = tidp.topicPartition + val nullTp = new TopicPartition(null, tp.partition) + addTopicToMetadataCache(tp.topic, 1, topicId = tidp.topicId) + + expect(replicaManager.getLogConfig(EasyMock.eq(nullTp))).andReturn(None) + + // Simulate unknown topic ID in the context + val fetchData = Map(new TopicIdPartition(tidp.topicId(), new TopicPartition(null, tidp.partition)) -> + new FetchRequest.PartitionData(tidp.topicId, 0, 0, 1000, Optional.empty())).asJava + val fetchDataBuilder = Map(tp -> new FetchRequest.PartitionData(tidp.topicId, 0, 0, 1000, + Optional.empty())).asJava + val fetchMetadata = new JFetchMetadata(0, 0) + val fetchContext = new FullFetchContext(time, new FetchSessionCache(1000, 100), + fetchMetadata, fetchData, false, false) + expect(fetchManager.newContext( + anyObject[Short], + anyObject[JFetchMetadata], + anyObject[Boolean], + anyObject[util.Map[TopicIdPartition, FetchRequest.PartitionData]], + anyObject[util.List[TopicIdPartition]], + anyObject[util.Map[Uuid, String]])).andReturn(fetchContext) Review comment: I copied this from the test above. 😅 Wasn't sure if we wanted consistency amongst the tests. -- 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