|
@@ -19,6 +19,7 @@ package org.apache.hadoop.hdfs.server.namenode.snapshot;
|
|
|
|
|
|
import static org.apache.hadoop.hdfs.server.namenode.snapshot.INodeDirectorySnapshottable.SNAPSHOT_LIMIT;
|
|
import static org.apache.hadoop.hdfs.server.namenode.snapshot.INodeDirectorySnapshottable.SNAPSHOT_LIMIT;
|
|
import static org.junit.Assert.assertTrue;
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
+import static org.junit.Assert.fail;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.util.Random;
|
|
import java.util.Random;
|
|
@@ -39,6 +40,7 @@ import org.apache.hadoop.hdfs.server.namenode.FSDirectory;
|
|
import org.apache.hadoop.hdfs.server.namenode.INode;
|
|
import org.apache.hadoop.hdfs.server.namenode.INode;
|
|
import org.apache.hadoop.hdfs.server.namenode.INodeDirectory;
|
|
import org.apache.hadoop.hdfs.server.namenode.INodeDirectory;
|
|
import org.apache.hadoop.ipc.RemoteException;
|
|
import org.apache.hadoop.ipc.RemoteException;
|
|
|
|
+import org.apache.hadoop.test.GenericTestUtils;
|
|
import org.junit.After;
|
|
import org.junit.After;
|
|
import org.junit.Assert;
|
|
import org.junit.Assert;
|
|
import org.junit.Before;
|
|
import org.junit.Before;
|
|
@@ -123,6 +125,13 @@ public class TestNestedSnapshots {
|
|
print("delete snapshot " + rootSnapshot);
|
|
print("delete snapshot " + rootSnapshot);
|
|
hdfs.disallowSnapshot(rootPath);
|
|
hdfs.disallowSnapshot(rootPath);
|
|
print("disallow snapshot " + rootStr);
|
|
print("disallow snapshot " + rootStr);
|
|
|
|
+ try {
|
|
|
|
+ hdfs.disallowSnapshot(rootPath);
|
|
|
|
+ fail("Expect snapshot exception when disallowing snapshot on root again");
|
|
|
|
+ } catch (SnapshotException e) {
|
|
|
|
+ GenericTestUtils.assertExceptionContains(
|
|
|
|
+ "Root is not a snapshottable directory", e);
|
|
|
|
+ }
|
|
|
|
|
|
//change foo to non-snapshottable
|
|
//change foo to non-snapshottable
|
|
hdfs.deleteSnapshot(foo, s1name);
|
|
hdfs.deleteSnapshot(foo, s1name);
|
|
@@ -134,13 +143,13 @@ public class TestNestedSnapshots {
|
|
hdfs.allowSnapshot(rootPath);
|
|
hdfs.allowSnapshot(rootPath);
|
|
Assert.fail();
|
|
Assert.fail();
|
|
} catch(SnapshotException se) {
|
|
} catch(SnapshotException se) {
|
|
- assertNestedSnapshotException(se, "ancestor");
|
|
|
|
|
|
+ assertNestedSnapshotException(se, "subdirectory");
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
hdfs.allowSnapshot(foo);
|
|
hdfs.allowSnapshot(foo);
|
|
Assert.fail();
|
|
Assert.fail();
|
|
} catch(SnapshotException se) {
|
|
} catch(SnapshotException se) {
|
|
- assertNestedSnapshotException(se, "ancestor");
|
|
|
|
|
|
+ assertNestedSnapshotException(se, "subdirectory");
|
|
}
|
|
}
|
|
|
|
|
|
final Path sub1Bar = new Path(bar, "sub1");
|
|
final Path sub1Bar = new Path(bar, "sub1");
|
|
@@ -150,13 +159,13 @@ public class TestNestedSnapshots {
|
|
hdfs.allowSnapshot(sub1Bar);
|
|
hdfs.allowSnapshot(sub1Bar);
|
|
Assert.fail();
|
|
Assert.fail();
|
|
} catch(SnapshotException se) {
|
|
} catch(SnapshotException se) {
|
|
- assertNestedSnapshotException(se, "subdirectory");
|
|
|
|
|
|
+ assertNestedSnapshotException(se, "ancestor");
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
hdfs.allowSnapshot(sub2Bar);
|
|
hdfs.allowSnapshot(sub2Bar);
|
|
Assert.fail();
|
|
Assert.fail();
|
|
} catch(SnapshotException se) {
|
|
} catch(SnapshotException se) {
|
|
- assertNestedSnapshotException(se, "subdirectory");
|
|
|
|
|
|
+ assertNestedSnapshotException(se, "ancestor");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|