Browse Source

HDFS-11474. Ozone: TestContainerMapping needs to cleanup levelDB files.Contributed by Xiaoyu Yao.

Anu Engineer 8 years ago
parent
commit
f4529316bd

+ 5 - 1
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/ozone/scm/container/TestContainerMapping.java

@@ -17,6 +17,7 @@
 package org.apache.hadoop.ozone.scm.container;
 package org.apache.hadoop.ozone.scm.container;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileUtil;
 import org.apache.hadoop.ozone.OzoneConfigKeys;
 import org.apache.hadoop.ozone.OzoneConfigKeys;
 import org.apache.hadoop.ozone.container.common.SCMTestUtils;
 import org.apache.hadoop.ozone.container.common.SCMTestUtils;
 import org.apache.hadoop.scm.container.common.helpers.Pipeline;
 import org.apache.hadoop.scm.container.common.helpers.Pipeline;
@@ -42,6 +43,8 @@ import java.util.UUID;
 public class TestContainerMapping {
 public class TestContainerMapping {
   private static ContainerMapping mapping;
   private static ContainerMapping mapping;
   private static MockNodeManager nodeManager;
   private static MockNodeManager nodeManager;
+  private static File testDir;
+
   @Rule
   @Rule
   public ExpectedException thrown = ExpectedException.none();
   public ExpectedException thrown = ExpectedException.none();
   @BeforeClass
   @BeforeClass
@@ -53,7 +56,7 @@ public class TestContainerMapping {
         TestContainerMapping.class.getSimpleName());
         TestContainerMapping.class.getSimpleName());
 
 
     conf.set(OzoneConfigKeys.OZONE_CONTAINER_METADATA_DIRS, path);
     conf.set(OzoneConfigKeys.OZONE_CONTAINER_METADATA_DIRS, path);
-    File testDir = Paths.get(path).toFile();
+    testDir = Paths.get(path).toFile();
     boolean folderExisted = testDir.exists() || testDir.mkdirs();
     boolean folderExisted = testDir.exists() || testDir.mkdirs();
     if (!folderExisted) {
     if (!folderExisted) {
       throw new IOException("Unable to create test diectory path");
       throw new IOException("Unable to create test diectory path");
@@ -65,6 +68,7 @@ public class TestContainerMapping {
   @AfterClass
   @AfterClass
   public static void cleanup() throws IOException {
   public static void cleanup() throws IOException {
     mapping.close();
     mapping.close();
+    FileUtil.fullyDelete(testDir);
   }
   }
 
 
   @Before
   @Before