HDFS-4573. Fix TestINodeFile on Windows. Contributed by Arpit Agarwal.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1454616 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Suresh Srinivas 2013-03-08 22:54:50 +00:00
parent a4c20088b5
commit c1fabc5e91
2 changed files with 74 additions and 59 deletions

View File

@ -306,7 +306,7 @@ Trunk (Unreleased)
HDFS-4502. JsonUtil.toFileStatus(..) should check if the fileId property HDFS-4502. JsonUtil.toFileStatus(..) should check if the fileId property
exists. (Brandon Li via suresh) exists. (Brandon Li via suresh)
BREAKDOWN OF HADOOP-8562 SUBTASKS BREAKDOWN OF HADOOP-8562 SUBTASKS AND RELATED JIRAS
HDFS-4145. Merge hdfs cmd line scripts from branch-1-win. (David Lao, HDFS-4145. Merge hdfs cmd line scripts from branch-1-win. (David Lao,
Bikas Saha, Lauren Yang, Chuan Liu, Thejas M Nair and Ivan Mitic via suresh) Bikas Saha, Lauren Yang, Chuan Liu, Thejas M Nair and Ivan Mitic via suresh)
@ -320,6 +320,8 @@ Trunk (Unreleased)
HDFS-4297. Fix issues related to datanode concurrent reading and writing on HDFS-4297. Fix issues related to datanode concurrent reading and writing on
Windows. (Arpit Agarwal, Chuan Liu via suresh) Windows. (Arpit Agarwal, Chuan Liu via suresh)
HDFS-4573. Fix TestINodeFile on Windows. (Arpit Agarwal via suresh)
Release 2.0.5-beta - UNRELEASED Release 2.0.5-beta - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -184,34 +184,41 @@ public class TestINodeFile {
long fileLen = 1024; long fileLen = 1024;
replication = 3; replication = 3;
Configuration conf = new Configuration(); Configuration conf = new Configuration();
MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes( MiniDFSCluster cluster = null;
replication).build(); try {
cluster.waitActive(); cluster =
FSNamesystem fsn = cluster.getNamesystem(); new MiniDFSCluster.Builder(conf).numDataNodes(replication).build();
FSDirectory fsdir = fsn.getFSDirectory(); cluster.waitActive();
DistributedFileSystem dfs = cluster.getFileSystem(); FSNamesystem fsn = cluster.getNamesystem();
FSDirectory fsdir = fsn.getFSDirectory();
// Create a file for test DistributedFileSystem dfs = cluster.getFileSystem();
final Path dir = new Path("/dir");
final Path file = new Path(dir, "file"); // Create a file for test
DFSTestUtil.createFile(dfs, file, fileLen, replication, 0L); final Path dir = new Path("/dir");
final Path file = new Path(dir, "file");
// Check the full path name of the INode associating with the file DFSTestUtil.createFile(dfs, file, fileLen, replication, 0L);
INode fnode = fsdir.getINode(file.toString());
assertEquals(file.toString(), fnode.getFullPathName()); // Check the full path name of the INode associating with the file
INode fnode = fsdir.getINode(file.toString());
// Call FSDirectory#unprotectedSetQuota which calls assertEquals(file.toString(), fnode.getFullPathName());
// INodeDirectory#replaceChild
dfs.setQuota(dir, Long.MAX_VALUE - 1, replication * fileLen * 10); // Call FSDirectory#unprotectedSetQuota which calls
final Path newDir = new Path("/newdir"); // INodeDirectory#replaceChild
final Path newFile = new Path(newDir, "file"); dfs.setQuota(dir, Long.MAX_VALUE - 1, replication * fileLen * 10);
// Also rename dir final Path newDir = new Path("/newdir");
dfs.rename(dir, newDir, Options.Rename.OVERWRITE); final Path newFile = new Path(newDir, "file");
// /dir/file now should be renamed to /newdir/file // Also rename dir
fnode = fsdir.getINode(newFile.toString()); dfs.rename(dir, newDir, Options.Rename.OVERWRITE);
// getFullPathName can return correct result only if the parent field of // /dir/file now should be renamed to /newdir/file
// child node is set correctly fnode = fsdir.getINode(newFile.toString());
assertEquals(newFile.toString(), fnode.getFullPathName()); // getFullPathName can return correct result only if the parent field of
// child node is set correctly
assertEquals(newFile.toString(), fnode.getFullPathName());
} finally {
if (cluster != null) {
cluster.shutdown();
}
}
} }
@Test @Test
@ -385,41 +392,47 @@ public class TestINodeFile {
Configuration conf = new Configuration(); Configuration conf = new Configuration();
conf.setInt(DFSConfigKeys.DFS_BLOCK_SIZE_KEY, conf.setInt(DFSConfigKeys.DFS_BLOCK_SIZE_KEY,
DFSConfigKeys.DFS_BYTES_PER_CHECKSUM_DEFAULT); DFSConfigKeys.DFS_BYTES_PER_CHECKSUM_DEFAULT);
MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1) MiniDFSCluster cluster = null;
.build(); try {
cluster.waitActive(); cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
cluster.waitActive();
FSNamesystem fsn = cluster.getNamesystem();
long lastId = fsn.getLastInodeId();
assertTrue(lastId == 1001); FSNamesystem fsn = cluster.getNamesystem();
long lastId = fsn.getLastInodeId();
// Create one directory and the last inode id should increase to 1002 assertTrue(lastId == 1001);
FileSystem fs = cluster.getFileSystem();
Path path = new Path("/test1");
assertTrue(fs.mkdirs(path));
assertTrue(fsn.getLastInodeId() == 1002);
// Use namenode rpc to create a file // Create one directory and the last inode id should increase to 1002
NamenodeProtocols nnrpc = cluster.getNameNodeRpc(); FileSystem fs = cluster.getFileSystem();
HdfsFileStatus fileStatus = nnrpc.create("/test1/file", new FsPermission( Path path = new Path("/test1");
(short) 0755), "client", assertTrue(fs.mkdirs(path));
new EnumSetWritable<CreateFlag>(EnumSet.of(CreateFlag.CREATE)), true, assertTrue(fsn.getLastInodeId() == 1002);
(short) 1, 128 * 1024 * 1024L);
assertTrue(fsn.getLastInodeId() == 1003);
assertTrue(fileStatus.getFileId() == 1003);
// Rename doesn't increase inode id // Use namenode rpc to create a file
Path renamedPath = new Path("/test2"); NamenodeProtocols nnrpc = cluster.getNameNodeRpc();
fs.rename(path, renamedPath); HdfsFileStatus fileStatus = nnrpc.create("/test1/file", new FsPermission(
assertTrue(fsn.getLastInodeId() == 1003); (short) 0755), "client",
new EnumSetWritable<CreateFlag>(EnumSet.of(CreateFlag.CREATE)), true,
(short) 1, 128 * 1024 * 1024L);
assertTrue(fsn.getLastInodeId() == 1003);
assertTrue(fileStatus.getFileId() == 1003);
cluster.restartNameNode(); // Rename doesn't increase inode id
cluster.waitActive(); Path renamedPath = new Path("/test2");
// Make sure empty editlog can be handled fs.rename(path, renamedPath);
cluster.restartNameNode(); assertTrue(fsn.getLastInodeId() == 1003);
cluster.waitActive();
assertTrue(fsn.getLastInodeId() == 1003); cluster.restartNameNode();
cluster.waitActive();
// Make sure empty editlog can be handled
cluster.restartNameNode();
cluster.waitActive();
assertTrue(fsn.getLastInodeId() == 1003);
} finally {
if (cluster != null) {
cluster.shutdown();
}
}
} }
@Test @Test