HDFS-4741. Merge r1476585 from trunk

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1486151 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Suresh Srinivas 2013-05-24 18:29:50 +00:00
parent 0af2735024
commit 0610d2d2d3
2 changed files with 20 additions and 8 deletions

View File

@ -385,6 +385,9 @@ Release 2.0.5-beta - UNRELEASED
failure to unpack old image tarball that contains hard links.
(Chris Nauroth via szetszwo)
HDFS-4741. TestStorageRestore#testStorageRestoreFailure fails on Windows.
(Arpit Agarwal via suresh)
Release 2.0.4-alpha - 2013-04-25
INCOMPATIBLE CHANGES

View File

@ -47,6 +47,7 @@ import org.apache.hadoop.hdfs.HdfsConfiguration;
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 class TestStorageRestore {
}
}
}
/**
* 1. create DFS cluster with 3 storage directories
* - 2 EDITS_IMAGE(name1, name2), 1 EDITS(name3)
@ -379,8 +380,16 @@ public class TestStorageRestore {
*/
@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 class TestStorageRestore {
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 class TestStorageRestore {
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();