mimaison commented on code in PR #20672:
URL: https://github.com/apache/kafka/pull/20672#discussion_r2460342450


##########
core/src/test/scala/unit/kafka/server/DynamicBrokerConfigTest.scala:
##########
@@ -1065,6 +1066,45 @@ class DynamicBrokerConfigTest {
     )
     
assertFalse(ctx.currentDefaultLogConfig.get().originals().containsKey(SocketServerConfigs.ADVERTISED_LISTENERS_CONFIG))
   }
+
+  @Test
+  def testClientTelemetryExporter(): Unit = {
+    val brokerId = 0
+    val origProps = TestUtils.createBrokerConfig(brokerId, port = 8181)
+    val config = KafkaConfig(origProps)
+    val metrics = mock(classOf[Metrics])
+    val telemetryPlugin = mock(classOf[ClientTelemetryExporterPlugin])
+
+    config.dynamicConfig.initialize(Some(telemetryPlugin))
+    val m = new DynamicMetricsReporters(brokerId, config, metrics, "clusterId")
+    config.dynamicConfig.addReconfigurable(m)
+
+    def updateReporter(reporterClass: Class[_]): Unit = {
+      val props = new Properties()
+      props.put(MetricConfigs.METRIC_REPORTER_CLASSES_CONFIG, 
reporterClass.getName)
+      config.dynamicConfig.updateDefaultConfig(props)
+    }
+
+    // Reporter implementing only ClientTelemetryExporterProvider
+    updateReporter(classOf[TestExporterOnly])

Review Comment:
   I'm not sure I understand what you mean. Since your implementations are 
effectively empty (none of the methods have any code), you get the exact same 
behavior with a mocked class.
   
   So replacing `updateReporter(classOf[TestExporterOnly])` with 
`updateReporter(mock(classOf[ClientTelemetryExporterProvider]).getClass)` 
should work. This would remove the need to have the `TestExporterOnly` 
implementation. Same for `TestReceiverOnly`.
   
   I think Mockito also allows defining mocks that implement multiple 
interfaces, so we can potentially do the same for `TestReceiverAndExporter` 
too. I'm not entirely sure about the syntax though, I leave that for you to 
check.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to