From e22f124c1b16ac65b283cc669c6933cfa442aab8 Mon Sep 17 00:00:00 2001 From: pacoc2 Date: Wed, 12 Nov 2025 21:48:38 -0600 Subject: [PATCH] YARN-11894 clean up file system before and after each state to address order dependency if other tests are run in between test class. --- .../yarn/server/timeline/TestLogInfo.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/test/java/org/apache/hadoop/yarn/server/timeline/TestLogInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/test/java/org/apache/hadoop/yarn/server/timeline/TestLogInfo.java index 6a4527c13c9d5..b21b3eb27a73e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/test/java/org/apache/hadoop/yarn/server/timeline/TestLogInfo.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/test/java/org/apache/hadoop/yarn/server/timeline/TestLogInfo.java @@ -77,6 +77,7 @@ public class TestLogInfo { @BeforeEach public void setup() throws Exception { + prepareCleanTestRootDir(); config.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, TEST_ROOT_DIR.toString()); HdfsConfiguration hdfsConfig = new HdfsConfiguration(); hdfsCluster = new MiniDFSCluster.Builder(hdfsConfig).numDataNodes(1).build(); @@ -106,7 +107,25 @@ public void tearDown() throws Exception { jsonGenerator.close(); outStream.close(); outStreamDomain.close(); + + FileSystem hdfsFs = hdfsCluster.getFileSystem(); + if (hdfsFs.exists(TEST_ROOT_DIR)) { + hdfsFs.delete(TEST_ROOT_DIR, true); + } hdfsCluster.shutdown(); + + FileSystem localFs = FileSystem.getLocal(config); + if (localFs.exists(TEST_ROOT_DIR)) { + localFs.delete(TEST_ROOT_DIR, true); + } + } + + /** + * Creates a fresh test root directory after cleanup. + */ + private void prepareCleanTestRootDir() throws IOException { + FileSystem localFs = FileSystem.getLocal(config); + localFs.mkdirs(TEST_ROOT_DIR); } @Test @@ -246,4 +265,4 @@ private Path getTestRootPath(String pathString) { return fileContextTestHelper.getTestRootPath(fc, pathString); } -} +} \ No newline at end of file