You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2020/06/18 02:27:14 UTC

[GitHub] [hudi] xushiyan commented on a change in pull request #1746: [HUDI-996] Add SharedResources

xushiyan commented on a change in pull request #1746:
URL: https://github.com/apache/hudi/pull/1746#discussion_r441931628



##########
File path: hudi-utilities/src/test/java/org/apache/hudi/utilities/functional/TestHoodieSnapshotCopier.java
##########
@@ -147,14 +142,4 @@ public void testSnapshotCopy() throws Exception {
 
     assertTrue(fs.exists(new Path(outputPath + "/_SUCCESS")));
   }
-
-  @AfterEach
-  public void cleanup() {
-    if (rootPath != null) {
-      new File(rootPath).delete();
-    }
-    if (jsc != null) {
-      jsc.stop();
-    }
-  }

Review comment:
       `@TempDir java.nio.file.Path tempDir` will clean up itself automatically

##########
File path: hudi-utilities/src/test/java/org/apache/hudi/utilities/functional/TestChainedTransformer.java
##########
@@ -0,0 +1,69 @@
+/*
+ * 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.utilities.functional;
+
+import org.apache.hudi.utilities.testutils.SharedResources;
+import org.apache.hudi.utilities.transform.ChainedTransformer;
+import org.apache.hudi.utilities.transform.Transformer;
+
+import org.apache.spark.sql.Dataset;
+import org.apache.spark.sql.Row;
+import org.apache.spark.sql.RowFactory;
+import org.apache.spark.sql.types.DataTypes;
+import org.apache.spark.sql.types.StructField;
+import org.apache.spark.sql.types.StructType;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.apache.spark.sql.types.DataTypes.IntegerType;
+import static org.apache.spark.sql.types.DataTypes.StringType;
+import static org.apache.spark.sql.types.DataTypes.createStructField;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+@Tag("suite")
+public class TestChainedTransformer extends SharedResources {

Review comment:
       functional test separated from its unit test class

##########
File path: hudi-utilities/src/test/java/org/apache/hudi/utilities/transform/TestChainedTransformer.java
##########
@@ -19,67 +19,15 @@
 
 package org.apache.hudi.utilities.transform;
 
-import org.apache.hudi.utilities.UtilHelpers;
-
-import org.apache.spark.api.java.JavaSparkContext;
-import org.apache.spark.sql.Dataset;
-import org.apache.spark.sql.Row;
-import org.apache.spark.sql.RowFactory;
-import org.apache.spark.sql.SparkSession;
-import org.apache.spark.sql.types.DataTypes;
-import org.apache.spark.sql.types.StructField;
-import org.apache.spark.sql.types.StructType;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import java.util.Arrays;
 import java.util.List;
 
 import static org.apache.spark.sql.types.DataTypes.IntegerType;
-import static org.apache.spark.sql.types.DataTypes.StringType;
-import static org.apache.spark.sql.types.DataTypes.createStructField;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
 public class TestChainedTransformer {
-
-  private JavaSparkContext jsc;
-  private SparkSession sparkSession;
-
-  @BeforeEach
-  public void setUp() {
-    jsc = UtilHelpers.buildSparkContext(this.getClass().getName() + "-hoodie", "local[2]");
-    sparkSession = SparkSession.builder().config(jsc.getConf()).getOrCreate();
-  }
-
-  @AfterEach
-  public void tearDown() {
-    jsc.stop();
-  }
-
-  @Test
-  public void testChainedTransformation() {

Review comment:
       moved to functional

##########
File path: hudi-utilities/src/test/java/org/apache/hudi/utilities/TestHoodieSnapshotExporter.java
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.utilities;
+
+import org.apache.hudi.utilities.HoodieSnapshotExporter.OutputFormatValidator;
+
+import com.beust.jcommander.ParameterException;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.NullSource;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+public class TestHoodieSnapshotExporter {

Review comment:
       unit test separated from its functional test class

##########
File path: hudi-utilities/src/test/java/org/apache/hudi/utilities/checkpointing/TestKafkaConnectHdfsProvider.java
##########
@@ -19,37 +19,39 @@
 package org.apache.hudi.utilities.checkpointing;
 
 import org.apache.hudi.common.config.TypedProperties;
-import org.apache.hudi.common.testutils.HoodieCommonTestHarness;
 import org.apache.hudi.common.testutils.HoodieTestUtils;
 import org.apache.hudi.exception.HoodieException;
 
 import org.apache.hadoop.conf.Configuration;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 import java.io.File;
+import java.nio.file.Files;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 
-public class TestKafkaConnectHdfsProvider extends HoodieCommonTestHarness {
+public class TestKafkaConnectHdfsProvider {

Review comment:
       This can be a unit test; getting rid of CommonTestHarness

##########
File path: hudi-utilities/src/test/java/org/apache/hudi/utilities/functional/TestHoodieSnapshotExporter.java
##########
@@ -258,49 +253,21 @@ public void setUp() throws Exception {
     public void testExportWithPartitionField() throws IOException {
       // `driver` field is set in HoodieTestDataGenerator
       cfg.outputPartitionField = "driver";
-      new HoodieSnapshotExporter().export(jsc, cfg);
+      new HoodieSnapshotExporter().export(jsc(), cfg);
 
-      assertEquals(NUM_RECORDS, sqlContext.read().format("json").load(targetPath).count());
-      assertTrue(dfs.exists(new Path(targetPath + "/_SUCCESS")));
-      assertTrue(dfs.listStatus(new Path(targetPath)).length > 1);
+      assertEquals(NUM_RECORDS, sqlContext().read().format("json").load(targetPath).count());
+      assertTrue(dfs().exists(new Path(targetPath + "/_SUCCESS")));
+      assertTrue(dfs().listStatus(new Path(targetPath)).length > 1);
     }
 
     @Test
     public void testExportForUserDefinedPartitioner() throws IOException {
       cfg.outputPartitioner = UserDefinedPartitioner.class.getName();
-      new HoodieSnapshotExporter().export(jsc, cfg);
-
-      assertEquals(NUM_RECORDS, sqlContext.read().format("json").load(targetPath).count());
-      assertTrue(dfs.exists(new Path(targetPath + "/_SUCCESS")));
-      assertTrue(dfs.exists(new Path(String.format("%s/%s=%s", targetPath, UserDefinedPartitioner.PARTITION_NAME, PARTITION_PATH))));
-    }
-  }
-
-  @Nested
-  public class TestHoodieSnapshotExporterInputValidation {

Review comment:
       moved to unit test

##########
File path: scripts/run_travis_tests.sh
##########
@@ -20,12 +20,13 @@ mode=$1
 sparkVersion=2.4.4
 hadoopVersion=2.7
 
-if [ "$mode" = "unit" ];
-then
+if [ "$mode" = "unit" ]; then
   echo "Running Unit Tests"
   mvn test -DskipITs=true -B
-elif [ "$mode" = "integration" ];
-then
+elif [ "$mode" = "functional" ]; then
+  echo "Running Functional Test Suite"
+  mvn test -pl hudi-utilities -Pfunctional-test-suite -B

Review comment:
       to begin with utilities module; later expand to others




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org