cshuo commented on code in PR #19543:
URL: https://github.com/apache/hudi/pull/19543#discussion_r3733054781


##########
hudi-flink-datasource/hudi-flink/src/test/java/org/apache/hudi/sink/v2/utils/TestPipelinesV2.java:
##########
@@ -0,0 +1,200 @@
+/*
+ * 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.v2.utils;
+
+import org.apache.hudi.client.model.HoodieFlinkInternalRow;
+import org.apache.hudi.configuration.FlinkOptions;
+import org.apache.hudi.configuration.OptionsResolver;
+import org.apache.hudi.exception.HoodieException;
+import org.apache.hudi.sink.utils.Pipelines;
+import org.apache.hudi.utils.TestConfigurations;
+
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.dag.Transformation;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.streaming.api.datastream.DataStream;
+import org.apache.flink.streaming.api.datastream.DataStreamSink;
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.table.data.RowData;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.MockedStatic;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.mockStatic;
+
+/** Tests topology construction and routing in {@link PipelinesV2}. */
+class TestPipelinesV2 {
+
+  private Configuration conf;
+  private DataStream<RowData> input;
+
+  @BeforeEach
+  void setUp() {
+    conf = new Configuration();
+    StreamExecutionEnvironment env = 
StreamExecutionEnvironment.getExecutionEnvironment();
+    input = env.fromCollection(
+        Collections.<RowData>emptyList(),
+        TypeInformation.of(RowData.class));
+  }
+
+  @Test
+  void testSinkUsesModeSpecificParallelismAndStableIdentity() {
+    conf.set(FlinkOptions.OPERATION, "bulk_insert");
+    conf.set(FlinkOptions.WRITE_TASKS, 4);
+
+    DataStreamSink<RowData> sink = PipelinesV2.sink(
+        input, conf, TestConfigurations.ROW_TYPE, false, true);
+
+    assertEquals(4, sink.getTransformation().getParallelism());
+    assertEquals("sink_v2", sink.getTransformation().getName());

Review Comment:
   The test name promises stable operator identity, but this assertion only 
checks the display name. Flink uses the operator UID for savepoint/checkpoint 
state mapping, so removing or changing the uid assignment would still pass 
while potentially breaking recovery across upgrades. Please assert that 
getUid() is present and has the expected stable value or structure.



##########
hudi-flink-datasource/hudi-flink/src/test/java/org/apache/hudi/sink/v2/utils/TestPipelinesV2.java:
##########
@@ -0,0 +1,200 @@
+/*
+ * 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.v2.utils;
+
+import org.apache.hudi.client.model.HoodieFlinkInternalRow;
+import org.apache.hudi.configuration.FlinkOptions;
+import org.apache.hudi.configuration.OptionsResolver;
+import org.apache.hudi.exception.HoodieException;
+import org.apache.hudi.sink.utils.Pipelines;
+import org.apache.hudi.utils.TestConfigurations;
+
+import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.dag.Transformation;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.streaming.api.datastream.DataStream;
+import org.apache.flink.streaming.api.datastream.DataStreamSink;
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.table.data.RowData;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.MockedStatic;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.mockStatic;
+
+/** Tests topology construction and routing in {@link PipelinesV2}. */
+class TestPipelinesV2 {
+
+  private Configuration conf;
+  private DataStream<RowData> input;
+
+  @BeforeEach
+  void setUp() {
+    conf = new Configuration();
+    StreamExecutionEnvironment env = 
StreamExecutionEnvironment.getExecutionEnvironment();
+    input = env.fromCollection(
+        Collections.<RowData>emptyList(),
+        TypeInformation.of(RowData.class));
+  }
+
+  @Test
+  void testSinkUsesModeSpecificParallelismAndStableIdentity() {
+    conf.set(FlinkOptions.OPERATION, "bulk_insert");
+    conf.set(FlinkOptions.WRITE_TASKS, 4);
+
+    DataStreamSink<RowData> sink = PipelinesV2.sink(
+        input, conf, TestConfigurations.ROW_TYPE, false, true);
+
+    assertEquals(4, sink.getTransformation().getParallelism());
+    assertEquals("sink_v2", sink.getTransformation().getName());
+  }
+
+  @Test
+  void testServiceTopologiesUseExpectedSingletonCommitOperators() {
+    conf.set(FlinkOptions.CLUSTERING_TASKS, 3);
+    conf.set(FlinkOptions.COMPACTION_TASKS, 2);
+
+    DataStream<RowData> clean = PipelinesV2.cleanV2(conf, input);
+    DataStream<RowData> cluster = PipelinesV2.clusterV2(
+        conf, TestConfigurations.ROW_TYPE, input);
+    DataStream<RowData> compact = PipelinesV2.compactV2(conf, input);
+
+    assertOperator(clean, "clean_commits", 1, 1);
+    assertOperator(cluster, "clustering_commit", 1, 1);
+    assertOperator(compact, "compact_commit", 1, 1);
+    assertEquals(3, transformation(cluster, 
"clustering_task").getParallelism());

Review Comment:
   The environment retains its default parallelism, which is normally 1 in this 
test, so removing an explicit singleton parallelism setting can still leave 
these assertions green. Please set the environment default to a distinct 
non-singleton value and also assert that cluster_plan_generate and 
compact_plan_generate remain singleton with max parallelism 1. Since this test 
covers topology routing, it would also be valuable to verify that both 
plan-to-task edges retain Pipelines.IndexPartitioner; otherwise duplicate plan 
scheduling or routing regressions could pass unnoticed.



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