kevin-wu24 commented on code in PR #20021:
URL: https://github.com/apache/kafka/pull/20021#discussion_r2164259100
##########
metadata/src/test/java/org/apache/kafka/image/loader/metrics/MetadataLoaderMetricsTest.java:
##########
@@ -153,8 +161,43 @@ public void testSetValueOfCurrentControllerId() {
}
}
+ @Test
+ public void testFinalizedFeatureLevelMetrics() {
+ MetricsRegistry registry = new MetricsRegistry();
+ try {
+ try (FakeMetadataLoaderMetrics fakeMetrics = new
FakeMetadataLoaderMetrics(registry)) {
+ @SuppressWarnings("unchecked")
+ Gauge<Short> finalizedMetadataVersion = (Gauge<Short>) registry
+ .allMetrics()
+ .get(metricName("MetadataLoader", "FinalizedLevel",
"featureName=metadataVersion"));
+ @SuppressWarnings("unchecked")
+ Gauge<Short> finalizedKRaftVersion = (Gauge<Short>) registry
+ .allMetrics()
+ .get(metricName("MetadataLoader", "FinalizedLevel",
"featureName=kraftVersion"));
+
+ assertEquals(MINIMUM_VERSION.featureLevel(),
finalizedMetadataVersion.value());
+ assertEquals((short) 0, finalizedKRaftVersion.value());
+
+
fakeMetrics.metrics.setFinalizedFeatureLevel(MetadataVersion.FEATURE_NAME,
MetadataVersion.LATEST_PRODUCTION.featureLevel());
+ assertEquals(MetadataVersion.LATEST_PRODUCTION.featureLevel(),
finalizedMetadataVersion.value());
+
+
fakeMetrics.metrics.setFinalizedFeatureLevel(KRaftVersion.FEATURE_NAME,
KRaftVersion.LATEST_PRODUCTION.featureLevel());
+ assertEquals(KRaftVersion.LATEST_PRODUCTION.featureLevel(),
finalizedKRaftVersion.value());
+ }
+ ControllerMetricsTestUtils.assertMetricsForTypeEqual(registry,
"kafka.server",
+ Set.of());
+ } finally {
+ registry.shutdown();
+ }
+ }
+
private static MetricName metricName(String type, String name) {
String mBeanName = String.format("kafka.server:type=%s,name=%s", type,
name);
return new MetricName("kafka.server", type, name, null, mBeanName);
}
+
+ private static MetricName metricName(String type, String name, String
scope) {
+ String mBeanName = String.format("kafka.server:type=%s,name=%s,%s",
type, name, scope);
+ return new MetricName("kafka.server", type, name, scope, mBeanName);
+ }
Review Comment:
I would like to leave the methods as is. I think combining them both into
one variadic method is a bit harder to read.
--
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]