1
0

[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.
This commit is contained in:
Raymond Xu
2021-03-08 01:36:03 -08:00
committed by GitHub
parent 8b9dea4ad9
commit d3a451611c

View File

@@ -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);