diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index b38694626f..eb3dcade88 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -346,6 +346,9 @@ Trunk (Unreleased) HDFS-4604. TestJournalNode fails on Windows. (Ivan Mitic via suresh) + HDFS-4625. Make TestNNWithQJM#testNewNamenodeTakesOverWriter work on + Windows. (Ivan Mitic via suresh) + Release 2.0.5-beta - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/TestNNWithQJM.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/TestNNWithQJM.java index 9ce2ae3c7c..cfe463c435 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/TestNNWithQJM.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/TestNNWithQJM.java @@ -98,9 +98,6 @@ public void testLogAndRestart() throws IOException { @Test (timeout = 30000) public void testNewNamenodeTakesOverWriter() throws Exception { - // Skip the test on Windows. See HDFS-4584. - assumeTrue(!Path.WINDOWS); - File nn1Dir = new File( MiniDFSCluster.getBaseDirectory() + "/TestNNWithQJM/image-nn1"); File nn2Dir = new File( @@ -110,23 +107,37 @@ public void testNewNamenodeTakesOverWriter() throws Exception { nn1Dir.getAbsolutePath()); conf.set(DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_KEY, mjc.getQuorumJournalURI("myjournal").toString()); - + + // Start the cluster once to generate the dfs dirs MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf) .numDataNodes(0) .manageNameDfsDirs(false) .checkExitOnShutdown(false) .build(); + // Shutdown the cluster before making a copy of the namenode dir + // to release all file locks, otherwise, the copy will fail on + // some platforms. + cluster.shutdown(); + try { - cluster.getFileSystem().mkdirs(TEST_PATH); - // Start a second NN pointed to the same quorum. // We need to copy the image dir from the first NN -- or else // the new NN will just be rejected because of Namespace mismatch. FileUtil.fullyDelete(nn2Dir); FileUtil.copy(nn1Dir, FileSystem.getLocal(conf).getRaw(), new Path(nn2Dir.getAbsolutePath()), false, conf); - + + // Start the cluster again + cluster = new MiniDFSCluster.Builder(conf) + .numDataNodes(0) + .format(false) + .manageNameDfsDirs(false) + .checkExitOnShutdown(false) + .build(); + + cluster.getFileSystem().mkdirs(TEST_PATH); + Configuration conf2 = new Configuration(); conf2.set(DFSConfigKeys.DFS_NAMENODE_NAME_DIR_KEY, nn2Dir.getAbsolutePath());