From ee5654e47b5c8b837073c2e83464163a25d9dc72 Mon Sep 17 00:00:00 2001 From: Timothy Brown Date: Sun, 24 Jul 2022 15:25:28 -0700 Subject: [PATCH 1/3] reuse FileSystem in SparkClientFunctionalTestHarness and close it after test --- .../SparkClientFunctionalTestHarness.java | 14 +++++++++++++- pom.xml | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/testutils/SparkClientFunctionalTestHarness.java b/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/testutils/SparkClientFunctionalTestHarness.java index f9676c6c477be..e469d4fb8275a 100644 --- a/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/testutils/SparkClientFunctionalTestHarness.java +++ b/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/testutils/SparkClientFunctionalTestHarness.java @@ -67,6 +67,7 @@ import org.apache.spark.sql.SQLContext; import org.apache.spark.sql.SparkSession; import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.io.TempDir; @@ -96,6 +97,7 @@ public class SparkClientFunctionalTestHarness implements SparkProvider, HoodieMe private static transient JavaSparkContext jsc; private static transient HoodieSparkEngineContext context; private static transient TimelineService timelineService; + private FileSystem fileSystem; /** * An indicator of the initialization status. @@ -128,7 +130,10 @@ public Configuration hadoopConf() { } public FileSystem fs() { - return FSUtils.getFs(basePath(), hadoopConf()); + if (fileSystem == null) { + fileSystem = FSUtils.getFs(basePath(), hadoopConf()); + } + return fileSystem; } @Override @@ -208,6 +213,13 @@ public static synchronized void resetSpark() { } } + @AfterEach + public void closeFilesystem() throws IOException { + if (fileSystem != null) { + fileSystem.close(); + } + } + protected JavaRDD tagLocation( HoodieIndex index, JavaRDD records, HoodieTable table) { return HoodieJavaRDD.getJavaRDD( diff --git a/pom.xml b/pom.xml index 36fbfb4505d89..1b4e471ea7d08 100644 --- a/pom.xml +++ b/pom.xml @@ -102,8 +102,8 @@ 2.17 3.0.1-b12 1.10.1 - 5.7.2 - 5.7.2 + 5.8.2 + 5.8.2 1.7.2 3.3.3 2.17.2 From 4345133281042a0f46f28765b285aca51a430c1b Mon Sep 17 00:00:00 2001 From: Timothy Brown Date: Sun, 24 Jul 2022 16:15:42 -0700 Subject: [PATCH 2/3] revert junit version upgrade --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 1b4e471ea7d08..36fbfb4505d89 100644 --- a/pom.xml +++ b/pom.xml @@ -102,8 +102,8 @@ 2.17 3.0.1-b12 1.10.1 - 5.8.2 - 5.8.2 + 5.7.2 + 5.7.2 1.7.2 3.3.3 2.17.2 From 36cc806477cb75f8c168ce0420849886ab5e650f Mon Sep 17 00:00:00 2001 From: Timothy Brown Date: Sun, 24 Jul 2022 16:20:56 -0700 Subject: [PATCH 3/3] set fileSystem to null in cleanup --- .../hudi/testutils/SparkClientFunctionalTestHarness.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/testutils/SparkClientFunctionalTestHarness.java b/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/testutils/SparkClientFunctionalTestHarness.java index e469d4fb8275a..c58dd178dca3a 100644 --- a/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/testutils/SparkClientFunctionalTestHarness.java +++ b/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/testutils/SparkClientFunctionalTestHarness.java @@ -214,9 +214,10 @@ public static synchronized void resetSpark() { } @AfterEach - public void closeFilesystem() throws IOException { + public void closeFileSystem() throws IOException { if (fileSystem != null) { fileSystem.close(); + fileSystem = null; } }