From d3a451611cc01a65cc0f305c72c04d64af0e7d38 Mon Sep 17 00:00:00 2001 From: Raymond Xu <2701446+xushiyan@users.noreply.github.com> Date: Mon, 8 Mar 2021 01:36:03 -0800 Subject: [PATCH] [MINOR] HoodieClientTestHarness close resources in AfterAll phase (#2646) Parameterized test case like `org.apache.hudi.table.upgrade.TestUpgradeDowngrade#testUpgrade` incurs flakiness when org.apache.hadoop.fs.FileSystem#closeAll is invoked at BeforeEach; it should be invoked in AfterAll instead. --- .../org/apache/hudi/testutils/HoodieClientTestHarness.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/testutils/HoodieClientTestHarness.java b/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/testutils/HoodieClientTestHarness.java index 75c139e43..72b277128 100644 --- a/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/testutils/HoodieClientTestHarness.java +++ b/hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/testutils/HoodieClientTestHarness.java @@ -48,6 +48,7 @@ import org.apache.log4j.Logger; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.JavaSparkContext; import org.apache.spark.sql.SQLContext; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestInfo; import scala.Tuple2; @@ -86,6 +87,11 @@ public abstract class HoodieClientTestHarness extends HoodieCommonTestHarness im protected transient MiniDFSCluster dfsCluster; protected transient DistributedFileSystem dfs; + @AfterAll + public static void tearDownAll() throws IOException { + FileSystem.closeAll(); + } + @BeforeEach public void setTestMethodName(TestInfo testInfo) { if (testInfo.getTestMethod().isPresent()) { @@ -246,7 +252,6 @@ public abstract class HoodieClientTestHarness extends HoodieCommonTestHarness im * @throws IOException */ protected void initDFS() throws IOException { - FileSystem.closeAll(); hdfsTestService = new HdfsTestService(); dfsCluster = hdfsTestService.start(true);