hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject [26/50] [abbrv] hadoop git commit: HDDS-439. 'ozone oz volume create' should default to current logged in user. Contributed by Dinesh Chitlangia.
Date Tue, 16 Oct 2018 23:38:10 GMT
HDDS-439. 'ozone oz volume create' should default to current logged in user. Contributed by
Dinesh Chitlangia.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/0bf8a110
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/0bf8a110
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/0bf8a110

Branch: refs/heads/HDFS-12943
Commit: 0bf8a110a56539ee85de0fc24575dd9a4c66d01b
Parents: 2614078
Author: Arpit Agarwal <arp@apache.org>
Authored: Mon Oct 15 19:30:40 2018 -0700
Committer: Arpit Agarwal <arp@apache.org>
Committed: Mon Oct 15 19:30:40 2018 -0700

----------------------------------------------------------------------
 .../hadoop/ozone/ozShell/TestOzoneShell.java    | 22 ++++++++++++++++++++
 .../web/ozShell/volume/CreateVolumeHandler.java |  7 +++++--
 2 files changed, 27 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/0bf8a110/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/ozShell/TestOzoneShell.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/ozShell/TestOzoneShell.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/ozShell/TestOzoneShell.java
index d5f2554..03efa1c 100644
--- a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/ozShell/TestOzoneShell.java
+++ b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/ozShell/TestOzoneShell.java
@@ -32,6 +32,7 @@ import java.util.List;
 import java.util.Random;
 import java.util.UUID;
 import java.util.stream.Collectors;
+
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.hadoop.fs.FileUtil;
 import org.apache.hadoop.hdds.cli.MissingSubcommandException;
@@ -60,6 +61,7 @@ import org.apache.hadoop.ozone.web.response.BucketInfo;
 import org.apache.hadoop.ozone.web.response.KeyInfo;
 import org.apache.hadoop.ozone.web.response.VolumeInfo;
 import org.apache.hadoop.ozone.web.utils.JsonUtils;
+import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.junit.After;
 import org.junit.AfterClass;
@@ -258,6 +260,26 @@ public class TestOzoneShell {
         exceptionHandler, args);
   }
 
+  /**
+   * Test to create volume without specifying --user or -u.
+   * @throws Exception
+   */
+  @Test
+  public void testCreateVolumeWithoutUser() throws Exception {
+    String volumeName = "volume" + RandomStringUtils.randomNumeric(1);
+    String[] args = new String[] {"volume", "create", url + "/" + volumeName,
+        "--root"};
+
+    execute(shell, args);
+
+    String truncatedVolumeName =
+        volumeName.substring(volumeName.lastIndexOf('/') + 1);
+    OzoneVolume volumeInfo = client.getVolumeDetails(truncatedVolumeName);
+    assertEquals(truncatedVolumeName, volumeInfo.getName());
+    assertEquals(UserGroupInformation.getCurrentUser().getUserName(),
+        volumeInfo.getOwner());
+  }
+
   @Test
   public void testDeleteVolume() throws Exception {
     LOG.info("Running testDeleteVolume");

http://git-wip-us.apache.org/repos/asf/hadoop/blob/0bf8a110/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/CreateVolumeHandler.java
----------------------------------------------------------------------
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/CreateVolumeHandler.java
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/CreateVolumeHandler.java
index de0fbaa..84922a7 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/CreateVolumeHandler.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/web/ozShell/volume/CreateVolumeHandler.java
@@ -30,6 +30,7 @@ import org.apache.hadoop.ozone.web.ozShell.Handler;
 import org.apache.hadoop.ozone.web.ozShell.Shell;
 import org.apache.hadoop.ozone.web.utils.JsonUtils;
 
+import org.apache.hadoop.security.UserGroupInformation;
 import picocli.CommandLine.Command;
 import picocli.CommandLine.Option;
 import picocli.CommandLine.Parameters;
@@ -45,8 +46,7 @@ public class CreateVolumeHandler extends Handler {
   private String uri;
 
   @Option(names = {"--user", "-u"},
-      description = "Owner of of the volume", required =
-      true)
+      description = "Owner of of the volume")
   private String userName;
 
   @Option(names = {"--quota", "-q"},
@@ -64,6 +64,9 @@ public class CreateVolumeHandler extends Handler {
    */
   @Override
   public Void call() throws Exception {
+    if(userName == null) {
+      userName = UserGroupInformation.getCurrentUser().getUserName();
+    }
 
     URI ozoneURI = verifyURI(uri);
     Path path = Paths.get(ozoneURI.getPath());


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message