hudi-agent commented on code in PR #19968:
URL: https://github.com/apache/hudi/pull/19968#discussion_r4021618597


##########
hudi-flink-datasource/hudi-flink/src/test/java/org/apache/hudi/sink/compact/handler/TestDataTableCompactHandler.java:
##########
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hudi.sink.compact.handler;
+
+import org.apache.hudi.client.HoodieFlinkWriteClient;
+import org.apache.hudi.common.model.CompactionOperation;
+import org.apache.hudi.exception.HoodieException;
+import org.apache.hudi.sink.compact.CompactionCommitEvent;
+import org.apache.hudi.sink.compact.CompactionPlanEvent;
+import org.apache.hudi.sink.utils.NonThrownExecutor;
+import org.apache.hudi.table.HoodieFlinkTable;
+
+import org.apache.flink.metrics.Counter;
+import org.apache.flink.metrics.MetricGroup;
+import org.apache.flink.util.ExceptionUtils;
+import org.apache.flink.util.function.ThrowingRunnable;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+/**
+ * Tests that a compaction failure occurring on the async {@link 
NonThrownExecutor} path is
+ * reflected in the {@code compactionErrorCount} metric instead of being 
swallowed silently.
+ */
+class TestDataTableCompactHandler {
+
+  @Test
+  @SuppressWarnings("unchecked")
+  void testAsyncCompactionFailureIncrementsErrorMetric() throws Exception {
+    HoodieFlinkWriteClient<?> writeClient = mock(HoodieFlinkWriteClient.class);
+    HoodieFlinkTable<?> table = mock(HoodieFlinkTable.class);
+    when(writeClient.getHoodieTable()).thenReturn((HoodieFlinkTable) table);
+
+    RuntimeException compactionFailure = new RuntimeException("compaction 
boom");
+    DataTableCompactHandler handler = new DataTableCompactHandler(writeClient, 
0) {
+      @Override
+      protected void doCompaction(CompactionPlanEvent event, 
org.apache.flink.util.Collector<CompactionCommitEvent> collector, boolean 
needReloadMetaClient) throws Exception {

Review Comment:
   🤖 nit: a few types here (`org.apache.flink.util.Collector`, 
`org.slf4j.LoggerFactory`, etc.) are used fully-qualified inline rather than 
imported — might be worth adding the imports for consistency with the rest of 
the file.
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



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