From ed4d318d681eaa59bf4e9048c13175260da5a719 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Eagles Date: Wed, 11 Dec 2013 21:16:48 +0000 Subject: [PATCH] HDFS-5023. TestSnapshotPathINodes.testAllowSnapshot is failing with jdk7 (Mit Desai via jeagles) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1550261 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../namenode/TestSnapshotPathINodes.java | 21 +++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 6090ef78e4..2a97b9a11d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -587,6 +587,9 @@ Release 2.4.0 - UNRELEASED HDFS-5633. Improve OfflineImageViewer to use less memory. (jing9) + HDFS-5023. TestSnapshotPathINodes.testAllowSnapshot is failing with jdk7 + (Mit Desai via jeagles) + OPTIMIZATIONS HDFS-5239. Allow FSNamesystem lock fairness to be configurable (daryn) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSnapshotPathINodes.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSnapshotPathINodes.java index fbfbf679f0..5c5ff443c4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSnapshotPathINodes.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestSnapshotPathINodes.java @@ -35,6 +35,7 @@ import org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot; import org.junit.AfterClass; import org.junit.Assert; +import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -57,7 +58,7 @@ public class TestSnapshotPathINodes { static private DistributedFileSystem hdfs; @BeforeClass - static public void setUp() throws Exception { + public static void setUp() throws Exception { conf = new Configuration(); cluster = new MiniDFSCluster.Builder(conf) .numDataNodes(REPLICATION) @@ -68,12 +69,16 @@ static public void setUp() throws Exception { fsdir = fsn.getFSDirectory(); hdfs = cluster.getFileSystem(); + } + + @Before + public void reset() throws Exception { DFSTestUtil.createFile(hdfs, file1, 1024, REPLICATION, seed); DFSTestUtil.createFile(hdfs, file2, 1024, REPLICATION, seed); } @AfterClass - static public void tearDown() throws Exception { + public static void tearDown() throws Exception { if (cluster != null) { cluster.shutdown(); } @@ -251,6 +256,8 @@ public void testSnapshotPathINodes() throws Exception { System.out.println("The exception is expected: " + fnfe); } } + hdfs.deleteSnapshot(sub1, "s1"); + hdfs.disallowSnapshot(sub1); } /** @@ -308,6 +315,8 @@ public void testSnapshotPathINodesAfterDeletion() throws Exception { sub1.toString()); assertEquals(inodes[components.length - 3].getFullPathName(), dir.toString()); + hdfs.deleteSnapshot(sub1, "s2"); + hdfs.disallowSnapshot(sub1); } static private Snapshot s4; @@ -367,6 +376,8 @@ public void testSnapshotPathINodesWithAddedFile() throws Exception { sub1.toString()); assertEquals(inodes[components.length - 3].getFullPathName(), dir.toString()); + hdfs.deleteSnapshot(sub1, "s4"); + hdfs.disallowSnapshot(sub1); } /** @@ -375,9 +386,6 @@ public void testSnapshotPathINodesWithAddedFile() throws Exception { */ @Test (timeout=15000) public void testSnapshotPathINodesAfterModification() throws Exception { - //file1 was deleted, create it again. - DFSTestUtil.createFile(hdfs, file1, 1024, REPLICATION, seed); - // First check the INode for /TestSnapshot/sub1/file1 String[] names = INode.getPathNames(file1.toString()); byte[][] components = INode.getPathComponents(names); @@ -385,7 +393,6 @@ public void testSnapshotPathINodesAfterModification() throws Exception { INode[] inodes = nodesInPath.getINodes(); // The number of inodes should be equal to components.length assertEquals(inodes.length, components.length); - assertSnapshot(nodesInPath, false, s4, -1); // The last INode should be associated with file1 assertEquals(inodes[components.length - 1].getFullPathName(), @@ -434,5 +441,7 @@ public void testSnapshotPathINodesAfterModification() throws Exception { assertEquals(newInodes[last].getFullPathName(), file1.toString()); // The modification time of the INode for file3 should have been changed Assert.assertFalse(modTime == newInodes[last].getModificationTime()); + hdfs.deleteSnapshot(sub1, "s3"); + hdfs.disallowSnapshot(sub1); } }