diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 77446a1425..91434890e5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -311,6 +311,9 @@ Trunk (Unreleased) HDFS-4584. Skip TestNNWithQJM.testNewNamenodeTakesOverWriter() on Windows. (Arpit Agarwal via szetszwo) + HDFS-4741. TestStorageRestore#testStorageRestoreFailure fails on Windows. + (Arpit Agarwal via suresh) + BREAKDOWN OF HDFS-347 SUBTASKS AND RELATED JIRAS HDFS-4353. Encapsulate connections to peers in Peer and PeerServer classes. diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestStorageRestore.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestStorageRestore.java index 02c8816be9..905e3680e0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestStorageRestore.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestStorageRestore.java @@ -47,6 +47,7 @@ import org.apache.hadoop.hdfs.MiniDFSCluster; import org.apache.hadoop.hdfs.server.common.Storage.StorageDirectory; import org.apache.hadoop.hdfs.server.namenode.JournalSet.JournalAndStream; +import org.apache.hadoop.util.Shell; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; @@ -362,7 +363,7 @@ public void testMultipleSecondaryCheckpoint() throws IOException { } } } - + /** * 1. create DFS cluster with 3 storage directories * - 2 EDITS_IMAGE(name1, name2), 1 EDITS(name3) @@ -379,8 +380,16 @@ public void testMultipleSecondaryCheckpoint() throws IOException { */ @Test public void testStorageRestoreFailure() throws Exception { - SecondaryNameNode secondary = null; + + // On windows, revoking write+execute permission on name2 does not + // prevent us from creating files in name2\current. Hence we revoke + // permissions on name2\current for the test. + String nameDir2 = Shell.WINDOWS ? + (new File(path2, "current").getAbsolutePath()) : path2.toString(); + String nameDir3 = Shell.WINDOWS ? + (new File(path3, "current").getAbsolutePath()) : path3.toString(); + try { cluster = new MiniDFSCluster.Builder(config).numDataNodes(0) .manageNameDfsDirs(false).build(); @@ -394,8 +403,8 @@ public void testStorageRestoreFailure() throws Exception { assertTrue(fs.mkdirs(path)); // invalidate storage by removing rwx permission from name2 and name3 - FileUtil.chmod(path2.toString(), "000"); - FileUtil.chmod(path3.toString(), "000"); + assertTrue(FileUtil.chmod(nameDir2, "000") == 0); + assertTrue(FileUtil.chmod(nameDir3, "000") == 0); secondary.doCheckpoint(); // should remove name2 and name3 printStorages(cluster.getNameNode().getFSImage()); @@ -409,18 +418,18 @@ public void testStorageRestoreFailure() throws Exception { assert (cluster.getNameNode().getFSImage().getStorage() .getNumStorageDirs() == 1); - FileUtil.chmod(path2.toString(), "755"); - FileUtil.chmod(path3.toString(), "755"); + assertTrue(FileUtil.chmod(nameDir2, "755") == 0); + assertTrue(FileUtil.chmod(nameDir3, "755") == 0); secondary.doCheckpoint(); // should restore name 2 and 3 assert (cluster.getNameNode().getFSImage().getStorage() .getNumStorageDirs() == 3); } finally { if (path2.exists()) { - FileUtil.chmod(path2.toString(), "755"); + FileUtil.chmod(nameDir2, "755"); } if (path3.exists()) { - FileUtil.chmod(path3.toString(), "755"); + FileUtil.chmod(nameDir3, "755"); } if (cluster != null) { cluster.shutdown();