apoorvmittal10 commented on code in PR #15251: URL: https://github.com/apache/kafka/pull/15251#discussion_r1469851552
########## server/src/test/java/org/apache/kafka/server/ClientMetricsManagerTest.java: ########## @@ -1023,5 +1177,18 @@ public void testCacheExpirationTaskCancelledOnInstanceUpdate() throws UnknownHos assertNotNull(instance); assertNotNull(instance.expirationTimerTask()); assertEquals(1, clientMetricsManager.expirationTimer().size()); + // Metrics size should remain same on instance update. + assertEquals(12, kafkaMetrics.metrics().size()); + assertEquals((double) 1, getMetric(ClientMetricsManager.ClientMetricsStats.INSTANCE_COUNT).metricValue()); + } + + private KafkaMetric getMetric(String name) throws Exception { + Optional<Entry<MetricName, KafkaMetric>> metric = kafkaMetrics.metrics().entrySet().stream() Review Comment: The map has `MetricName` as the key, rather constructing `MetricName` again in tests with tags, I iterated on the map itself. Similar to how we do SelectorTest.java. -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org