Browse Source

YARN-11829. Make test directory unique to avoid locking after test cleanup (#7755)

* The file handles are exclusively held for the
  duration of the file operation on Windows.
  This poses a problem during test cleanup/
  setup when the test tries to clean the folder.
* This PR makes the test directory unique to
  avoid locking the file handle after test cleanup.
ASHISH-RANJAN59 1 tuần trước cách đây
mục cha
commit
c476979dc8

+ 7 - 3
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/fair/converter/FSConfigConverterTestCommons.java

@@ -27,6 +27,7 @@ import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintStream;
 import java.io.PrintWriter;
+import java.util.UUID;
 
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
@@ -43,8 +44,7 @@ public class FSConfigConverterTestCommons {
       new File(TEST_DIR, "test-yarn-site.xml").getAbsolutePath();
   public final static String CONVERSION_RULES_FILE =
       new File(TEST_DIR, "test-conversion-rules.properties").getAbsolutePath();
-  public final static String OUTPUT_DIR =
-      new File(TEST_DIR, "conversion-output").getAbsolutePath();
+  public static String OUTPUT_DIR;
 
   private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
   private final ByteArrayOutputStream errContent = new ByteArrayOutputStream();
@@ -57,7 +57,11 @@ public class FSConfigConverterTestCommons {
   }
 
   public void setUp() throws IOException {
-    File d = new File(TEST_DIR, "conversion-output");
+    String uuid = UUID.randomUUID().toString().trim();
+    OUTPUT_DIR =
+            new File(TEST_DIR, "conversion-output" + uuid).getAbsolutePath();
+    File d = new File(TEST_DIR, "conversion-output" + uuid);
+
     if (d.exists()) {
       FileUtils.deleteDirectory(d);
     }