HDFS-4741. TestStorageRestore#testStorageRestoreFailure fails on Windows. Contributed by Arpit Agarwal.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1476585 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Suresh Srinivas 2013-04-27 14:16:32 +00:00
parent 4e21c347d2
commit b7afde6d52
2 changed files with 20 additions and 8 deletions

View File

@ -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.

View File

@ -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;
@ -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();