This is an automated email from the ASF dual-hosted git repository.

sumitagrawal pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new f1aca0055a HDDS-9143. [Linked Bucket] Ozone bucket Info command output 
does not have key "link" (#5181)
f1aca0055a is described below

commit f1aca0055a7b30fd24b0897301d60682da7c683b
Author: devmadhuu <[email protected]>
AuthorDate: Wed Aug 16 10:39:05 2023 +0530

    HDDS-9143. [Linked Bucket] Ozone bucket Info command output does not have 
key "link" (#5181)
---
 .../hadoop/ozone/shell/TestOzoneShellHA.java       | 61 ++++++++++++++++++++++
 .../ozone/shell/bucket/InfoBucketHandler.java      |  6 +++
 2 files changed, 67 insertions(+)

diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
index df202cb507..ffb67ba38f 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
@@ -85,6 +85,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
 
+import org.junit.Assert;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
@@ -1660,4 +1661,64 @@ public class TestOzoneShellHA {
         () -> client.getObjectStore().getVolume(volume1));
     assertEquals(VOLUME_NOT_FOUND, omExecution.getResult());
   }
+
+  @Test
+  public void testLinkedAndNonLinkedBucketMetaData()
+      throws Exception {
+    String volumeName = "volume1";
+    // Create volume volume1
+    String[] args = new String[] {
+        "volume", "create", "o3://" + omServiceId +
+          OZONE_URI_DELIMITER + volumeName};
+    execute(ozoneShell, args);
+    out.reset();
+
+    // Create bucket bucket1
+    args = new String[] {"bucket", "create", "o3://" + omServiceId +
+          OZONE_URI_DELIMITER + volumeName + "/bucket1"};
+    execute(ozoneShell, args);
+    out.reset();
+
+    // ozone sh bucket list
+    out.reset();
+    execute(ozoneShell, new String[] {"bucket", "list", "/volume1"});
+
+    // Expect valid JSON array
+    final ArrayList<LinkedTreeMap<String, String>> bucketListOut =
+        parseOutputIntoArrayList();
+
+    Assert.assertTrue(bucketListOut.size() == 1);
+    boolean link =
+        String.valueOf(bucketListOut.get(0).get("link")).equals("false");
+    assertTrue(link);
+
+    // Create linked bucket under volume1
+    out.reset();
+    execute(ozoneShell, new String[]{"bucket", "link", "/volume1/bucket1",
+        "/volume1/link-to-bucket1"});
+
+    // ozone sh bucket list under volume1 and this should give both linked
+    // and non-linked buckets
+    out.reset();
+    execute(ozoneShell, new String[] {"bucket", "list", "/volume1"});
+
+    // Expect valid JSON array
+    final ArrayList<LinkedTreeMap<String, String>> bucketListLinked =
+        parseOutputIntoArrayList();
+
+    Assert.assertTrue(bucketListLinked.size() == 2);
+    link = String.valueOf(bucketListLinked.get(1).get("link")).equals("true");
+    assertTrue(link);
+
+    // Clean up
+    out.reset();
+    execute(ozoneShell, new String[] {"bucket", "delete", "/volume1/bucket1"});
+    out.reset();
+    execute(ozoneShell,
+        new String[]{"bucket", "delete", "/volume1/link-to-bucket1"});
+    out.reset();
+    execute(ozoneShell,
+        new String[]{"volume", "delete", "/volume1"});
+    out.reset();
+  }
 }
diff --git 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/InfoBucketHandler.java
 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/InfoBucketHandler.java
index ac70ddb75f..39044db797 100644
--- 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/InfoBucketHandler.java
+++ 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/InfoBucketHandler.java
@@ -59,6 +59,7 @@ public class InfoBucketHandler extends BucketHandler {
     private Instant creationTime;
     private Instant modificationTime;
     private String owner;
+    private Boolean link;
 
     LinkBucket(OzoneBucket ozoneBucket) {
       this.volumeName = ozoneBucket.getVolumeName();
@@ -68,6 +69,7 @@ public class InfoBucketHandler extends BucketHandler {
       this.creationTime = ozoneBucket.getCreationTime();
       this.modificationTime = ozoneBucket.getModificationTime();
       this.owner = ozoneBucket.getOwner();
+      this.link = ozoneBucket.isLink();
     }
 
     public String getVolumeName() {
@@ -97,6 +99,10 @@ public class InfoBucketHandler extends BucketHandler {
     public String getOwner() {
       return owner;
     }
+
+    public Boolean getLink() {
+      return link;
+    }
   }
 
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to