mingyen066 commented on code in PR #22977:
URL: https://github.com/apache/kafka/pull/22977#discussion_r3674430396
##########
core/src/test/scala/unit/kafka/server/KafkaConfigTest.scala:
##########
@@ -1709,6 +1709,36 @@ class KafkaConfigTest {
assertEquals("3", originals.get(KRaftConfigs.NODE_ID_CONFIG))
}
+ @Test
+ def testBrokerIdDeprecationWarning(): Unit = {
+ val deprecationWarning = "The 'broker.id' configuration is deprecated and
will be removed in " +
+ "Apache Kafka 5.0. Please use 'node.id' instead."
+
+ // Register on the KafkaConfig logger rather than the root logger, so that
the warning is only
+ // captured if it is actually logged by `object KafkaConfig`.
+ Using.resource(LogCaptureAppender.createAndRegister(KafkaConfig.getClass))
{ appender =>
+ appender.setClassLogger(KafkaConfig.getClass, Level.WARN)
+ // The appender cannot be reset, so the counts asserted below are
cumulative.
+ def warningCount: Int = appender.getMessages.asScala.count(_ ==
deprecationWarning)
+
+ // Only node.id set: no warning.
+ val props = new Properties()
+ props.putAll(kraftProps())
+ KafkaConfig.fromProps(props)
Review Comment:
Great suggestion, thanks — done! Both values are covered now, since the
warning must fire regardless of `doLog` (the broker startup path passes `doLog
= false`), so this locks that in.
--
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]