|
@@ -36,6 +36,7 @@ import org.apache.hadoop.hdfs.server.namenode.snapshot.INodeFileWithSnapshot;
|
|
|
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;
|
|
|
|
|
@@ -58,7 +59,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)
|
|
@@ -69,12 +70,16 @@ public class TestSnapshotPathINodes {
|
|
|
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();
|
|
|
}
|
|
@@ -252,6 +257,8 @@ public class TestSnapshotPathINodes {
|
|
|
System.out.println("The exception is expected: " + fnfe);
|
|
|
}
|
|
|
}
|
|
|
+ hdfs.deleteSnapshot(sub1, "s1");
|
|
|
+ hdfs.disallowSnapshot(sub1);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -309,6 +316,8 @@ public class TestSnapshotPathINodes {
|
|
|
sub1.toString());
|
|
|
assertEquals(inodes[components.length - 3].getFullPathName(),
|
|
|
dir.toString());
|
|
|
+ hdfs.deleteSnapshot(sub1, "s2");
|
|
|
+ hdfs.disallowSnapshot(sub1);
|
|
|
}
|
|
|
|
|
|
static private Snapshot s4;
|
|
@@ -368,6 +377,8 @@ public class TestSnapshotPathINodes {
|
|
|
sub1.toString());
|
|
|
assertEquals(inodes[components.length - 3].getFullPathName(),
|
|
|
dir.toString());
|
|
|
+ hdfs.deleteSnapshot(sub1, "s4");
|
|
|
+ hdfs.disallowSnapshot(sub1);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -376,9 +387,6 @@ public class TestSnapshotPathINodes {
|
|
|
*/
|
|
|
@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);
|
|
@@ -386,7 +394,6 @@ public class TestSnapshotPathINodes {
|
|
|
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 class TestSnapshotPathINodes {
|
|
|
// The modification time of the INode for file3 should have been changed
|
|
|
Assert.assertFalse(inodes[last].getModificationTime()
|
|
|
== newInodes[last].getModificationTime());
|
|
|
+ hdfs.deleteSnapshot(sub1, "s3");
|
|
|
+ hdfs.disallowSnapshot(sub1);
|
|
|
}
|
|
|
}
|