[27/50] [abbrv] hadoop git commit: HDFS-10906. Add unit tests for Trash with HDFS encryption zones. Contributed by Hanisha Koneru.
HDFS-10906. Add unit tests for Trash with HDFS encryption zones. Contributed by Hanisha Koneru. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/c62ae710 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/c62ae710 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/c62ae710 Branch: refs/heads/HDFS-7240 Commit: c62ae7107f025091652e79db3edfca5c4dc84e4a Parents: 6c348c5 Author: Xiaoyu YaoAuthored: Mon Oct 17 15:25:24 2016 -0700 Committer: Xiaoyu Yao Committed: Tue Oct 18 14:05:43 2016 -0700 -- .../org/apache/hadoop/hdfs/DFSTestUtil.java | 32 +- .../hdfs/TestTrashWithEncryptionZones.java | 188 .../TestTrashWithSecureEncryptionZones.java | 443 +++ 3 files changed, 662 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/c62ae710/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java -- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java index 963aaa6..7f26b03 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java @@ -27,6 +27,7 @@ import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_RPC_ADDRESS_KEY; import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; import java.io.BufferedOutputStream; @@ -114,7 +115,6 @@ import org.apache.hadoop.hdfs.protocol.HdfsConstants; import org.apache.hadoop.hdfs.protocol.LayoutVersion; import org.apache.hadoop.hdfs.protocol.LocatedBlock; import org.apache.hadoop.hdfs.protocol.LocatedBlocks; -import org.apache.hadoop.hdfs.protocol.LocatedStripedBlock; import org.apache.hadoop.hdfs.protocol.datatransfer.Sender; import org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.BlockOpResponseProto; import org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier; @@ -167,6 +167,7 @@ import org.apache.hadoop.util.VersionInfo; import org.apache.log4j.Level; import org.junit.Assume; import org.mockito.internal.util.reflection.Whitebox; +import org.apache.hadoop.util.ToolRunner; import com.google.common.annotations.VisibleForTesting; import static org.apache.hadoop.hdfs.StripedFileTestUtil.BLOCK_STRIPED_CELL_SIZE; @@ -2054,4 +2055,33 @@ public class DFSTestUtil { } } } + + public static void verifyDelete(FsShell shell, FileSystem fs, Path path, + boolean shouldExistInTrash) throws Exception { +Path trashPath = Path.mergePaths(shell.getCurrentTrashDir(path), path); + +verifyDelete(shell, fs, path, trashPath, shouldExistInTrash); + } + + public static void verifyDelete(FsShell shell, FileSystem fs, Path path, + Path trashPath, boolean shouldExistInTrash) throws Exception { +assertTrue(path + " file does not exist", fs.exists(path)); + +// Verify that trashPath has a path component named ".Trash" +Path checkTrash = trashPath; +while (!checkTrash.isRoot() && !checkTrash.getName().equals(".Trash")) { + checkTrash = checkTrash.getParent(); +} +assertEquals("No .Trash component found in trash path " + trashPath, +".Trash", checkTrash.getName()); + +String[] argv = new String[]{"-rm", "-r", path.toString()}; +int res = ToolRunner.run(shell, argv); +assertEquals("rm failed", 0, res); +if (shouldExistInTrash) { + assertTrue("File not in trash : " + trashPath, fs.exists(trashPath)); +} else { + assertFalse("File in trash : " + trashPath, fs.exists(trashPath)); +} + } } http://git-wip-us.apache.org/repos/asf/hadoop/blob/c62ae710/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithEncryptionZones.java -- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithEncryptionZones.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithEncryptionZones.java new file mode 100644 index 000..2a8d493 --- /dev/null +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithEncryptionZones.java @@ -0,0 +1,188 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with
[49/50] [abbrv] hadoop git commit: HDFS-10906. Add unit tests for Trash with HDFS encryption zones. Contributed by Hanisha Koneru.
HDFS-10906. Add unit tests for Trash with HDFS encryption zones. Contributed by Hanisha Koneru. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/c62ae710 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/c62ae710 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/c62ae710 Branch: refs/heads/HADOOP-13070 Commit: c62ae7107f025091652e79db3edfca5c4dc84e4a Parents: 6c348c5 Author: Xiaoyu YaoAuthored: Mon Oct 17 15:25:24 2016 -0700 Committer: Xiaoyu Yao Committed: Tue Oct 18 14:05:43 2016 -0700 -- .../org/apache/hadoop/hdfs/DFSTestUtil.java | 32 +- .../hdfs/TestTrashWithEncryptionZones.java | 188 .../TestTrashWithSecureEncryptionZones.java | 443 +++ 3 files changed, 662 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/c62ae710/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java -- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java index 963aaa6..7f26b03 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java @@ -27,6 +27,7 @@ import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_RPC_ADDRESS_KEY; import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; import java.io.BufferedOutputStream; @@ -114,7 +115,6 @@ import org.apache.hadoop.hdfs.protocol.HdfsConstants; import org.apache.hadoop.hdfs.protocol.LayoutVersion; import org.apache.hadoop.hdfs.protocol.LocatedBlock; import org.apache.hadoop.hdfs.protocol.LocatedBlocks; -import org.apache.hadoop.hdfs.protocol.LocatedStripedBlock; import org.apache.hadoop.hdfs.protocol.datatransfer.Sender; import org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.BlockOpResponseProto; import org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier; @@ -167,6 +167,7 @@ import org.apache.hadoop.util.VersionInfo; import org.apache.log4j.Level; import org.junit.Assume; import org.mockito.internal.util.reflection.Whitebox; +import org.apache.hadoop.util.ToolRunner; import com.google.common.annotations.VisibleForTesting; import static org.apache.hadoop.hdfs.StripedFileTestUtil.BLOCK_STRIPED_CELL_SIZE; @@ -2054,4 +2055,33 @@ public class DFSTestUtil { } } } + + public static void verifyDelete(FsShell shell, FileSystem fs, Path path, + boolean shouldExistInTrash) throws Exception { +Path trashPath = Path.mergePaths(shell.getCurrentTrashDir(path), path); + +verifyDelete(shell, fs, path, trashPath, shouldExistInTrash); + } + + public static void verifyDelete(FsShell shell, FileSystem fs, Path path, + Path trashPath, boolean shouldExistInTrash) throws Exception { +assertTrue(path + " file does not exist", fs.exists(path)); + +// Verify that trashPath has a path component named ".Trash" +Path checkTrash = trashPath; +while (!checkTrash.isRoot() && !checkTrash.getName().equals(".Trash")) { + checkTrash = checkTrash.getParent(); +} +assertEquals("No .Trash component found in trash path " + trashPath, +".Trash", checkTrash.getName()); + +String[] argv = new String[]{"-rm", "-r", path.toString()}; +int res = ToolRunner.run(shell, argv); +assertEquals("rm failed", 0, res); +if (shouldExistInTrash) { + assertTrue("File not in trash : " + trashPath, fs.exists(trashPath)); +} else { + assertFalse("File in trash : " + trashPath, fs.exists(trashPath)); +} + } } http://git-wip-us.apache.org/repos/asf/hadoop/blob/c62ae710/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithEncryptionZones.java -- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithEncryptionZones.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithEncryptionZones.java new file mode 100644 index 000..2a8d493 --- /dev/null +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithEncryptionZones.java @@ -0,0 +1,188 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with
hadoop git commit: HDFS-10906. Add unit tests for Trash with HDFS encryption zones. Contributed by Hanisha Koneru.
Repository: hadoop Updated Branches: refs/heads/branch-2.8 1ecbf323b -> 190a53b89 HDFS-10906. Add unit tests for Trash with HDFS encryption zones. Contributed by Hanisha Koneru. (cherry picked from commit 0c79d5af74944363f3d04f7e1702411db564bbfd) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/190a53b8 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/190a53b8 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/190a53b8 Branch: refs/heads/branch-2.8 Commit: 190a53b898cb9432cb70a915b30ec47049107433 Parents: 1ecbf32 Author: Xiaoyu YaoAuthored: Mon Oct 17 15:25:24 2016 -0700 Committer: Xiaoyu Yao Committed: Tue Oct 18 14:09:03 2016 -0700 -- .../org/apache/hadoop/hdfs/DFSTestUtil.java | 31 ++ .../hdfs/TestTrashWithEncryptionZones.java | 188 .../TestTrashWithSecureEncryptionZones.java | 443 +++ 3 files changed, 662 insertions(+) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/190a53b8/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java -- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java index 67e9e54..b9aa1e7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java @@ -27,6 +27,7 @@ import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_RPC_ADDRESS_KEY; import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; import java.io.BufferedOutputStream; @@ -157,6 +158,7 @@ import org.apache.hadoop.util.VersionInfo; import org.apache.log4j.Level; import org.junit.Assume; import org.mockito.internal.util.reflection.Whitebox; +import org.apache.hadoop.util.ToolRunner; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Charsets; @@ -1970,4 +1972,33 @@ public class DFSTestUtil { } } } + + public static void verifyDelete(FsShell shell, FileSystem fs, Path path, + boolean shouldExistInTrash) throws Exception { +Path trashPath = Path.mergePaths(shell.getCurrentTrashDir(path), path); + +verifyDelete(shell, fs, path, trashPath, shouldExistInTrash); + } + + public static void verifyDelete(FsShell shell, FileSystem fs, Path path, + Path trashPath, boolean shouldExistInTrash) throws Exception { +assertTrue(path + " file does not exist", fs.exists(path)); + +// Verify that trashPath has a path component named ".Trash" +Path checkTrash = trashPath; +while (!checkTrash.isRoot() && !checkTrash.getName().equals(".Trash")) { + checkTrash = checkTrash.getParent(); +} +assertEquals("No .Trash component found in trash path " + trashPath, +".Trash", checkTrash.getName()); + +String[] argv = new String[]{"-rm", "-r", path.toString()}; +int res = ToolRunner.run(shell, argv); +assertEquals("rm failed", 0, res); +if (shouldExistInTrash) { + assertTrue("File not in trash : " + trashPath, fs.exists(trashPath)); +} else { + assertFalse("File in trash : " + trashPath, fs.exists(trashPath)); +} + } } http://git-wip-us.apache.org/repos/asf/hadoop/blob/190a53b8/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithEncryptionZones.java -- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithEncryptionZones.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithEncryptionZones.java new file mode 100644 index 000..2a8d493 --- /dev/null +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithEncryptionZones.java @@ -0,0 +1,188 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + *
hadoop git commit: HDFS-10906. Add unit tests for Trash with HDFS encryption zones. Contributed by Hanisha Koneru.
Repository: hadoop Updated Branches: refs/heads/branch-2 bc176961e -> 74f1c49d7 HDFS-10906. Add unit tests for Trash with HDFS encryption zones. Contributed by Hanisha Koneru. (cherry picked from commit 0c79d5af74944363f3d04f7e1702411db564bbfd) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/74f1c49d Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/74f1c49d Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/74f1c49d Branch: refs/heads/branch-2 Commit: 74f1c49d76f24694b827f33f492718abb56a902b Parents: bc17696 Author: Xiaoyu YaoAuthored: Mon Oct 17 15:25:24 2016 -0700 Committer: Xiaoyu Yao Committed: Tue Oct 18 14:07:57 2016 -0700 -- .../org/apache/hadoop/hdfs/DFSTestUtil.java | 31 ++ .../hdfs/TestTrashWithEncryptionZones.java | 188 .../TestTrashWithSecureEncryptionZones.java | 443 +++ 3 files changed, 662 insertions(+) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/74f1c49d/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java -- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java index bb8b2d3..3eda008 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java @@ -27,6 +27,7 @@ import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_RPC_ADDRESS_KEY; import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; import java.io.BufferedOutputStream; @@ -157,6 +158,7 @@ import org.apache.hadoop.util.VersionInfo; import org.apache.log4j.Level; import org.junit.Assume; import org.mockito.internal.util.reflection.Whitebox; +import org.apache.hadoop.util.ToolRunner; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Charsets; @@ -1973,4 +1975,33 @@ public class DFSTestUtil { } } } + + public static void verifyDelete(FsShell shell, FileSystem fs, Path path, + boolean shouldExistInTrash) throws Exception { +Path trashPath = Path.mergePaths(shell.getCurrentTrashDir(path), path); + +verifyDelete(shell, fs, path, trashPath, shouldExistInTrash); + } + + public static void verifyDelete(FsShell shell, FileSystem fs, Path path, + Path trashPath, boolean shouldExistInTrash) throws Exception { +assertTrue(path + " file does not exist", fs.exists(path)); + +// Verify that trashPath has a path component named ".Trash" +Path checkTrash = trashPath; +while (!checkTrash.isRoot() && !checkTrash.getName().equals(".Trash")) { + checkTrash = checkTrash.getParent(); +} +assertEquals("No .Trash component found in trash path " + trashPath, +".Trash", checkTrash.getName()); + +String[] argv = new String[]{"-rm", "-r", path.toString()}; +int res = ToolRunner.run(shell, argv); +assertEquals("rm failed", 0, res); +if (shouldExistInTrash) { + assertTrue("File not in trash : " + trashPath, fs.exists(trashPath)); +} else { + assertFalse("File in trash : " + trashPath, fs.exists(trashPath)); +} + } } http://git-wip-us.apache.org/repos/asf/hadoop/blob/74f1c49d/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithEncryptionZones.java -- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithEncryptionZones.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithEncryptionZones.java new file mode 100644 index 000..2a8d493 --- /dev/null +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithEncryptionZones.java @@ -0,0 +1,188 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed
hadoop git commit: HDFS-10906. Add unit tests for Trash with HDFS encryption zones. Contributed by Hanisha Koneru.
Repository: hadoop Updated Branches: refs/heads/trunk 6c348c569 -> c62ae7107 HDFS-10906. Add unit tests for Trash with HDFS encryption zones. Contributed by Hanisha Koneru. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/c62ae710 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/c62ae710 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/c62ae710 Branch: refs/heads/trunk Commit: c62ae7107f025091652e79db3edfca5c4dc84e4a Parents: 6c348c5 Author: Xiaoyu YaoAuthored: Mon Oct 17 15:25:24 2016 -0700 Committer: Xiaoyu Yao Committed: Tue Oct 18 14:05:43 2016 -0700 -- .../org/apache/hadoop/hdfs/DFSTestUtil.java | 32 +- .../hdfs/TestTrashWithEncryptionZones.java | 188 .../TestTrashWithSecureEncryptionZones.java | 443 +++ 3 files changed, 662 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/c62ae710/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java -- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java index 963aaa6..7f26b03 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/DFSTestUtil.java @@ -27,6 +27,7 @@ import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_RPC_ADDRESS_KEY; import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; import java.io.BufferedOutputStream; @@ -114,7 +115,6 @@ import org.apache.hadoop.hdfs.protocol.HdfsConstants; import org.apache.hadoop.hdfs.protocol.LayoutVersion; import org.apache.hadoop.hdfs.protocol.LocatedBlock; import org.apache.hadoop.hdfs.protocol.LocatedBlocks; -import org.apache.hadoop.hdfs.protocol.LocatedStripedBlock; import org.apache.hadoop.hdfs.protocol.datatransfer.Sender; import org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.BlockOpResponseProto; import org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier; @@ -167,6 +167,7 @@ import org.apache.hadoop.util.VersionInfo; import org.apache.log4j.Level; import org.junit.Assume; import org.mockito.internal.util.reflection.Whitebox; +import org.apache.hadoop.util.ToolRunner; import com.google.common.annotations.VisibleForTesting; import static org.apache.hadoop.hdfs.StripedFileTestUtil.BLOCK_STRIPED_CELL_SIZE; @@ -2054,4 +2055,33 @@ public class DFSTestUtil { } } } + + public static void verifyDelete(FsShell shell, FileSystem fs, Path path, + boolean shouldExistInTrash) throws Exception { +Path trashPath = Path.mergePaths(shell.getCurrentTrashDir(path), path); + +verifyDelete(shell, fs, path, trashPath, shouldExistInTrash); + } + + public static void verifyDelete(FsShell shell, FileSystem fs, Path path, + Path trashPath, boolean shouldExistInTrash) throws Exception { +assertTrue(path + " file does not exist", fs.exists(path)); + +// Verify that trashPath has a path component named ".Trash" +Path checkTrash = trashPath; +while (!checkTrash.isRoot() && !checkTrash.getName().equals(".Trash")) { + checkTrash = checkTrash.getParent(); +} +assertEquals("No .Trash component found in trash path " + trashPath, +".Trash", checkTrash.getName()); + +String[] argv = new String[]{"-rm", "-r", path.toString()}; +int res = ToolRunner.run(shell, argv); +assertEquals("rm failed", 0, res); +if (shouldExistInTrash) { + assertTrue("File not in trash : " + trashPath, fs.exists(trashPath)); +} else { + assertFalse("File in trash : " + trashPath, fs.exists(trashPath)); +} + } } http://git-wip-us.apache.org/repos/asf/hadoop/blob/c62ae710/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithEncryptionZones.java -- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithEncryptionZones.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithEncryptionZones.java new file mode 100644 index 000..2a8d493 --- /dev/null +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestTrashWithEncryptionZones.java @@ -0,0 +1,188 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more