voonhous commented on code in PR #19205: URL: https://github.com/apache/hudi/pull/19205#discussion_r3773363824
########## hudi-client/hudi-client-common/src/test/java/org/apache/hudi/config/TestHoodieWriteConfigMetaFieldsMode.java: ########## @@ -0,0 +1,189 @@ +/* + * 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.config; + +import org.apache.hudi.common.model.HoodieTableType; +import org.apache.hudi.common.model.MetaFieldsMode; +import org.apache.hudi.common.table.HoodieTableConfig; + +import org.junit.jupiter.api.Test; + +import java.util.Properties; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Validates the writer-side accessors and validation guards for the meta-field-population modes + * on {@link HoodieWriteConfig}. Companion test for the {@link HoodieTableConfig} accessors lives + * in {@code TestHoodieMetaFieldsMode}; this test covers the writer-builder surface and the + * cross-flag validation that runs at {@code build()} time. + */ +class TestHoodieWriteConfigMetaFieldsMode { Review Comment: Re-checking on `4dbf37ee61b0`: the fold-in was answered, but the coverage gap in the same comment is still open. `grep -c EngineType hudi-client/hudi-client-common/src/test/java/org/apache/hudi/config/TestHoodieWriteConfigMetaFieldsMode.java` returns 0. `baseBuilder()` never calls `withEngineType`, and `Builder.engineType` defaults to `SPARK`, so the guard added at `HoodieWriteConfig.java:3990` is never entered. Mutating it to `checkArgument(true, ...)` leaves all 15 methods in the class green -- the Spark-only restriction, which is one of the two things bounding this feature's blast radius, is unverified. The MoR guard right above it is covered (`rejectsSelectiveModeOnMergeOnRead`, `allowsAllAndNoneOnMergeOnRead`), so this is just the sibling being missed rather than a disagreement about whether it is worth testing. `TestHoodieWriteConfig.java:786,793` already has the `withEngineType` fixture to copy. Please add: ```java @ParameterizedTest @EnumSource(value = EngineType.class, names = {"FLINK", "JAVA"}) void rejectsSelectiveModeOnNonSparkEngines(EngineType engineType) { Throwable t = assertThrows(IllegalArgumentException.class, () -> baseBuilder() .withEngineType(engineType) .withMetaFieldsMode(MetaFieldsMode.COMMIT_TIME_ONLY).build()); assertTrue(t.getMessage().contains(engineType.toString())); } ``` plus one case asserting `FLINK` + `ALL`/`NONE` still builds, so the guard cannot be widened by accident. -- 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]
