|
@@ -75,6 +75,8 @@ import org.apache.hadoop.hdfs.protocol.EncryptionZone;
|
|
|
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
|
|
|
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
|
|
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants.SafeModeAction;
|
|
|
+import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffReportEntry;
|
|
|
+import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport.DiffType;
|
|
|
import org.apache.hadoop.hdfs.server.namenode.EncryptionFaultInjector;
|
|
|
import org.apache.hadoop.hdfs.server.namenode.EncryptionZoneManager;
|
|
|
import org.apache.hadoop.hdfs.server.namenode.FSImageTestUtil;
|
|
@@ -148,6 +150,7 @@ import javax.xml.parsers.SAXParser;
|
|
|
import javax.xml.parsers.SAXParserFactory;
|
|
|
|
|
|
public class TestEncryptionZones {
|
|
|
+ static final Logger LOG = Logger.getLogger(TestEncryptionZones.class);
|
|
|
|
|
|
protected Configuration conf;
|
|
|
private FileSystemTestHelper fsHelper;
|
|
@@ -1495,6 +1498,44 @@ public class TestEncryptionZones {
|
|
|
contents, DFSTestUtil.readFile(fs, snapshottedZoneFile));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Check the correctness of the diff reports.
|
|
|
+ */
|
|
|
+ private void verifyDiffReport(Path dir, String from, String to,
|
|
|
+ DiffReportEntry... entries) throws IOException {
|
|
|
+ DFSTestUtil.verifySnapshotDiffReport(fs, dir, from, to, entries);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Test correctness of snapshotDiff for encryption zone.
|
|
|
+ * snapshtoDiff should work when the path parameter is prefixed with
|
|
|
+ * /.reserved/raw for path that's both snapshottable and encryption zone.
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void testSnapshotDiffOnEncryptionZones() throws Exception {
|
|
|
+ final String TEST_KEY2 = "testkey2";
|
|
|
+ DFSTestUtil.createKey(TEST_KEY2, cluster, conf);
|
|
|
+
|
|
|
+ final int len = 8196;
|
|
|
+ final Path zone = new Path("/zone");
|
|
|
+ final Path rawZone = new Path("/.reserved/raw/zone");
|
|
|
+ final Path zoneFile = new Path(zone, "zoneFile");
|
|
|
+ fsWrapper.mkdir(zone, FsPermission.getDirDefault(), true);
|
|
|
+ dfsAdmin.allowSnapshot(zone);
|
|
|
+ dfsAdmin.createEncryptionZone(zone, TEST_KEY, NO_TRASH);
|
|
|
+ DFSTestUtil.createFile(fs, zoneFile, len, (short) 1, 0xFEED);
|
|
|
+ fs.createSnapshot(zone, "snap1");
|
|
|
+ fsWrapper.delete(zoneFile, true);
|
|
|
+ fs.createSnapshot(zone, "snap2");
|
|
|
+ verifyDiffReport(zone, "snap1", "snap2",
|
|
|
+ new DiffReportEntry(DiffType.MODIFY, DFSUtil.string2Bytes("")),
|
|
|
+ new DiffReportEntry(DiffType.DELETE, DFSUtil.string2Bytes("zoneFile")));
|
|
|
+
|
|
|
+ verifyDiffReport(rawZone, "snap1", "snap2",
|
|
|
+ new DiffReportEntry(DiffType.MODIFY, DFSUtil.string2Bytes("")),
|
|
|
+ new DiffReportEntry(DiffType.DELETE, DFSUtil.string2Bytes("zoneFile")));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Verify symlinks can be created in encryption zones and that
|
|
|
* they function properly when the target is in the same
|