Search in sources :

Example 1 with CreateEncryptionZoneFlag

use of org.apache.hadoop.hdfs.client.CreateEncryptionZoneFlag in project hadoop by apache.

the class TestViewFileSystemHdfs method testTrashRootsAfterEncryptionZoneDeletion.

@Test
public void testTrashRootsAfterEncryptionZoneDeletion() throws Exception {
    final Path zone = new Path("/EZ");
    fsTarget.mkdirs(zone);
    final Path zone1 = new Path("/EZ/zone1");
    fsTarget.mkdirs(zone1);
    DFSTestUtil.createKey("test_key", cluster, CONF);
    HdfsAdmin hdfsAdmin = new HdfsAdmin(cluster.getURI(0), CONF);
    final EnumSet<CreateEncryptionZoneFlag> provisionTrash = EnumSet.of(CreateEncryptionZoneFlag.PROVISION_TRASH);
    hdfsAdmin.createEncryptionZone(zone1, "test_key", provisionTrash);
    final Path encFile = new Path(zone1, "encFile");
    DFSTestUtil.createFile(fsTarget, encFile, 10240, (short) 1, 0xFEED);
    Configuration clientConf = new Configuration(CONF);
    clientConf.setLong(FS_TRASH_INTERVAL_KEY, 1);
    clientConf.set("fs.default.name", fsTarget.getUri().toString());
    FsShell shell = new FsShell(clientConf);
    //Verify file deletion within EZ
    DFSTestUtil.verifyDelete(shell, fsTarget, encFile, true);
    Assert.assertTrue("ViewFileSystem trash roots should include EZ file trash", (fsView.getTrashRoots(true).size() == 1));
    //Verify deletion of EZ
    DFSTestUtil.verifyDelete(shell, fsTarget, zone, true);
    Assert.assertTrue("ViewFileSystem trash roots should include EZ zone trash", (fsView.getTrashRoots(true).size() == 2));
}
Also used : Path(org.apache.hadoop.fs.Path) CreateEncryptionZoneFlag(org.apache.hadoop.hdfs.client.CreateEncryptionZoneFlag) FsShell(org.apache.hadoop.fs.FsShell) Configuration(org.apache.hadoop.conf.Configuration) HdfsAdmin(org.apache.hadoop.hdfs.client.HdfsAdmin) Test(org.junit.Test)

Aggregations

Configuration (org.apache.hadoop.conf.Configuration)1 FsShell (org.apache.hadoop.fs.FsShell)1 Path (org.apache.hadoop.fs.Path)1 CreateEncryptionZoneFlag (org.apache.hadoop.hdfs.client.CreateEncryptionZoneFlag)1 HdfsAdmin (org.apache.hadoop.hdfs.client.HdfsAdmin)1 Test (org.junit.Test)1