Skip to content

Commit 67967fc

Browse files
committed
fix kafka api test
1 parent 6737a0f commit 67967fc

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

core/src/test/scala/unit/kafka/server/KafkaApisTest.scala

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4246,9 +4246,6 @@ class KafkaApisTest extends Logging {
42464246
testConsumerListOffsetWithUnsupportedVersion(-6, 1)
42474247
}
42484248

4249-
// TODO: FIXME - This test is currently failing because topic ID resolution from metadata cache is not working correctly
4250-
// The issue is that metadataCache.getTopicName(topicId) returns None even after addTopicToMetadataCache is called
4251-
// This needs further investigation into how KRaftMetadataCache handles topic ID to name resolution
42524249
@Test
42534250
def testHandleListOffsetRequestWithTopicId(): Unit = {
42544251
val tp = new TopicPartition("foo", 0)
@@ -4300,8 +4297,9 @@ class KafkaApisTest extends Logging {
43004297
kafkaApis.handleListOffsetRequest(request)
43014298

43024299
val response = verifyNoThrottling[ListOffsetsResponse](request)
4303-
assertTrue(response.topics.asScala.exists(_.name == tp.topic), s"Topic ${tp.topic} not found in response. Found: ${response.topics.asScala.map(_.name).mkString(", ")}")
4304-
val topicResponse = response.topics.asScala.find(_.name == tp.topic).get
4300+
// v12 does not return topic name, return topic id instead
4301+
assertTrue(response.topics.asScala.exists(_.name == ""), s"Topic ${tp.topic} not found in response. Found: ${response.topics.asScala.map(_.name).mkString(", ")}")
4302+
val topicResponse = response.topics.asScala.find(_.name == "").get
43054303
assertEquals(topicId, topicResponse.topicId)
43064304
val partitionData = topicResponse.partitions.asScala.find(_.partitionIndex == tp.partition).get
43074305
assertEquals(Errors.NONE.code, partitionData.errorCode)
@@ -10472,9 +10470,7 @@ class KafkaApisTest extends Logging {
1047210470

1047310471
private def addTopicToMetadataCache(topic: String, numPartitions: Int, numBrokers: Int = 1, topicId: Uuid = Uuid.ZERO_UUID): Unit = {
1047410472
val updateMetadata = createBasicMetadata(topic, numPartitions, 0, numBrokers, topicId)
10475-
System.err.println("kkk updateMetadata" + updateMetadata)
1047610473
MetadataCacheTest.updateCache(metadataCache, updateMetadata)
10477-
System.err.println("kkk metadataCache" + metadataCache)
1047810474
}
1047910475

1048010476
private def createMetadataBroker(brokerId: Int,

core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6099,11 +6099,6 @@ class ReplicaManagerTest {
60996099
}
61006100
}
61016101

6102-
// Note: Removed testFetchOffsetWithMatchingTopicId because the test requires complex metadata cache setup.
6103-
// The INCONSISTENT_TOPIC_ID validation is already tested in testFetchOffsetWithInconsistentTopicId,
6104-
// and the ZERO_UUID compatibility is tested in testFetchOffsetWithZeroUuid.
6105-
// Together, these tests provide sufficient coverage of the topic ID validation logic in fetchOffset.
6106-
61076102
@Test
61086103
def testFetchOffsetWithInconsistentTopicId(): Unit = {
61096104
// Use class-level topicId as the correct one, and create a wrong one

0 commit comments

Comments
 (0)