skywalker0618 commented on code in PR #18813:
URL: https://github.com/apache/hudi/pull/18813#discussion_r3286259641


##########
hudi-flink-datasource/hudi-flink/src/test/java/org/apache/hudi/sink/partitioner/index/TestRecordLevelIndexBackend.java:
##########
@@ -152,6 +156,38 @@ public void testLazyEvictUsesAccessOrder() throws 
Exception {
     }
   }
 
+  @Test
+  public void testConstructorPreSeedsMetricsForNullSafety() throws Exception {
+    // Without pre-seeding, bootstrapPartition would NPE before the bucket 
assign operator
+    // wires the real MetricGroup via registerMetrics(MetricGroup).
+    try (RecordLevelIndexBackend backend = createBackend()) {
+      assertNotNull(backend.getMetrics());
+    }
+  }
+
+  @Test
+  public void testRegisterMetricsRegistersRemoteRliHistograms() throws 
Exception {
+    CapturingMetricGroup metricGroup = new CapturingMetricGroup();
+    try (RecordLevelIndexBackend backend = createBackend()) {
+      backend.registerMetrics(metricGroup);
+
+      assertNotNull(metricGroup.getHistogram("remoteIndexLookupLatency"));
+      assertNotNull(metricGroup.getHistogram("remoteLookupKeysNum"));
+    }
+  }
+
+  @Test
+  public void testRegisterMetricsReplacesPreSeededMetrics() throws Exception {
+    try (RecordLevelIndexBackend backend = createBackend()) {
+      FlinkIndexBackendMetrics preSeeded = backend.getMetrics();
+      backend.registerMetrics(new CapturingMetricGroup());
+
+      assertNotNull(backend.getMetrics());
+      // The second call must rewire the field so the active metrics publish 
to the real metric group.

Review Comment:
   Fixed



-- 
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