Skip to content

Commit 3edb94e

Browse files
KAFKA-10557: Missing docs when describing topic configs including (#9360)
Reviewers: Rajini Sivaram <[email protected]> Co-authored-by: Edoardo Comar <[email protected]> Co-authored-by: Mickael Maison <[email protected]>
1 parent 57c2216 commit 3edb94e

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

core/src/main/scala/kafka/server/AdminManager.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ class AdminManager(val config: KafkaConfig,
764764
val source = if (allSynonyms.isEmpty) ConfigSource.DEFAULT_CONFIG.id else allSynonyms.head.source
765765
val synonyms = if (!includeSynonyms) List.empty else allSynonyms
766766
val dataType = configResponseType(configEntryType)
767-
val configDocumentation = if (includeDocumentation) brokerDocumentation(name) else null
767+
val configDocumentation = if (includeDocumentation) logConfig.documentationOf(name) else null
768768
new DescribeConfigsResponseData.DescribeConfigsResourceResult()
769769
.setName(name).setValue(valueAsString).setConfigSource(source)
770770
.setIsSensitive(isSensitive).setReadOnly(false).setSynonyms(synonyms.asJava)

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

+32
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ import org.apache.kafka.common.protocol.Errors
2929
import org.junit.{After, Test}
3030
import org.junit.Assert.assertEquals
3131
import org.junit.Assert.assertFalse
32+
import org.junit.Assert.assertNotNull
33+
import org.junit.Assert.assertNotEquals
34+
import java.util.Properties
3235

3336
class AdminManagerTest {
3437

@@ -80,4 +83,33 @@ class AdminManagerTest {
8083
assertEquals(Errors.NONE.code, results.head.errorCode())
8184
assertFalse("Should return configs", results.head.configs().isEmpty)
8285
}
86+
87+
@Test
88+
def testDescribeConfigsWithDocumentation(): Unit = {
89+
EasyMock.expect(zkClient.getEntityConfigs(ConfigType.Topic, topic)).andReturn(new Properties)
90+
EasyMock.expect(zkClient.getEntityConfigs(ConfigType.Broker, brokerId.toString)).andReturn(new Properties)
91+
EasyMock.expect(metadataCache.contains(topic)).andReturn(true)
92+
EasyMock.replay(zkClient, metadataCache)
93+
94+
val adminManager = createAdminManager()
95+
96+
val resources = List(
97+
new DescribeConfigsRequestData.DescribeConfigsResource()
98+
.setResourceName(topic)
99+
.setResourceType(ConfigResource.Type.TOPIC.id),
100+
new DescribeConfigsRequestData.DescribeConfigsResource()
101+
.setResourceName(brokerId.toString)
102+
.setResourceType(ConfigResource.Type.BROKER.id))
103+
104+
val results: List[DescribeConfigsResponseData.DescribeConfigsResult] = adminManager.describeConfigs(resources, true, true)
105+
assertEquals(2, results.size)
106+
results.foreach(r => {
107+
assertEquals(Errors.NONE.code, r.errorCode)
108+
assertFalse("Should return configs", r.configs.isEmpty)
109+
r.configs.forEach(c => {
110+
assertNotNull(s"Config ${c.name} should have non null documentation", c.documentation)
111+
assertNotEquals(s"Config ${c.name} should have non blank documentation", "", c.documentation.trim)
112+
})
113+
})
114+
}
83115
}

0 commit comments

Comments
 (0)