kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mimai...@apache.org
Subject [kafka] branch 2.6 updated: KAFKA-10557: Missing docs when describing topic configs including (#9360)
Date Fri, 02 Oct 2020 11:07:15 GMT
This is an automated email from the ASF dual-hosted git repository.

mimaison pushed a commit to branch 2.6
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/2.6 by this push:
     new 54cea1e  KAFKA-10557: Missing docs when describing topic configs including (#9360)
54cea1e is described below

commit 54cea1eccdc0bb1fc3c96de48917940fbc61cab8
Author: Edoardo Comar <ecomar@uk.ibm.com>
AuthorDate: Fri Oct 2 10:09:10 2020 +0100

    KAFKA-10557: Missing docs when describing topic configs including (#9360)
    
    Reviewers: Rajini Sivaram <rajinisivaram@gmail.com>
    
    Co-authored-by: Edoardo Comar <ecomar@uk.ibm.com>
    Co-authored-by: Mickael Maison <mickael.maison@gmail.com>
---
 .../src/main/scala/kafka/server/AdminManager.scala |  2 +-
 .../scala/unit/kafka/server/AdminManagerTest.scala | 81 ++++++++++++++++++++++
 2 files changed, 82 insertions(+), 1 deletion(-)

diff --git a/core/src/main/scala/kafka/server/AdminManager.scala b/core/src/main/scala/kafka/server/AdminManager.scala
index 5fc411d..ce4b266 100644
--- a/core/src/main/scala/kafka/server/AdminManager.scala
+++ b/core/src/main/scala/kafka/server/AdminManager.scala
@@ -715,7 +715,7 @@ class AdminManager(val config: KafkaConfig,
     val source = if (allSynonyms.isEmpty) ConfigSource.DEFAULT_CONFIG else allSynonyms.head.source
     val synonyms = if (!includeSynonyms) List.empty else allSynonyms
     val dataType = configResponseType(configEntryType)
-    val configDocumentation = if (includeDocumentation) brokerDocumentation(name) else null
+    val configDocumentation = if (includeDocumentation) logConfig.documentationOf(name) else
null
     new DescribeConfigsResponse.ConfigEntry(name, valueAsString, source, isSensitive, false,
synonyms.asJava, dataType, configDocumentation)
   }
 
diff --git a/core/src/test/scala/unit/kafka/server/AdminManagerTest.scala b/core/src/test/scala/unit/kafka/server/AdminManagerTest.scala
new file mode 100644
index 0000000..f3ffbc2
--- /dev/null
+++ b/core/src/test/scala/unit/kafka/server/AdminManagerTest.scala
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package kafka.server
+
+import kafka.utils.TestUtils
+import kafka.zk.KafkaZkClient
+import org.apache.kafka.common.config.ConfigResource
+import org.apache.kafka.common.metrics.Metrics
+import org.apache.kafka.common.protocol.Errors
+import org.apache.kafka.common.requests.DescribeConfigsResponse
+
+import org.easymock.EasyMock
+import org.junit.{After, Test}
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertFalse
+import org.junit.Assert.assertNotEquals
+import org.junit.Assert.assertNotNull
+
+import java.util.Properties
+import scala.collection.Map
+
+
+class AdminManagerTest {
+
+  private val zkClient: KafkaZkClient = EasyMock.createNiceMock(classOf[KafkaZkClient])
+  private val metrics = new Metrics()
+  private val brokerId = 1
+  private val topic = "topic-1"
+  private val metadataCache: MetadataCache = EasyMock.createNiceMock(classOf[MetadataCache])
+
+  @After
+  def tearDown(): Unit = {
+    metrics.close()
+  }
+
+  def createAdminManager(): AdminManager = {
+    val props = TestUtils.createBrokerConfig(brokerId, "zk")
+    new AdminManager(KafkaConfig.fromProps(props), metrics, metadataCache, zkClient)
+  }
+
+  @Test
+  def testDescribeConfigsWithDocumentation(): Unit = {
+    EasyMock.expect(zkClient.getEntityConfigs(ConfigType.Topic, topic)).andReturn(new Properties)
+    EasyMock.expect(zkClient.getEntityConfigs(ConfigType.Broker, brokerId.toString)).andReturn(new
Properties)
+    EasyMock.expect(metadataCache.contains(topic)).andReturn(true)
+    EasyMock.replay(zkClient, metadataCache)
+
+    val adminManager = createAdminManager()
+
+    val resources = Map[ConfigResource, Option[Set[String]]](
+      new ConfigResource(ConfigResource.Type.TOPIC, topic) -> Option.empty,
+      new ConfigResource(ConfigResource.Type.BROKER, brokerId.toString) -> Option.empty
+    )
+
+    val results: Map[ConfigResource, DescribeConfigsResponse.Config] = adminManager.describeConfigs(resources,
true, true)
+    assertEquals(2, results.size)
+    results.foreach{ case (resource, config) => {
+      assertEquals(Errors.NONE, config.error.error)
+      assertFalse("Should return configs", config.entries.isEmpty)
+      config.entries.forEach(c => {
+        assertNotNull(s"Config ${c.name} should have non null documentation", c.documentation)
+        assertNotEquals(s"Config ${c.name} should have non blank documentation", "", c.documentation.trim)
+      })
+    }}
+  }
+}


Mime
View raw message