ArafatKhan2198 commented on code in PR #11020:
URL: https://github.com/apache/ozone/pull/11020#discussion_r3912158303


##########
hadoop-ozone/s3gateway/src/test/java/org/apache/hadoop/ozone/s3/endpoint/TestObjectAttributesGet.java:
##########
@@ -173,4 +182,100 @@ public void 
testWhenKeyIsDirectoryAndKeyPathEndsWithASlash() throws Exception {
 
     assertEquals(HTTP_OK, response.getStatus());
   }
+
+  @Test
+  public void testGetObjectAttributesMultipartObjectPartsListsAllParts() 
throws IOException, OS3Exception {
+    final String key = "mpu-key";
+    completeMultipartUploadWithParts(key, "part-one", "part-two", 
"part-three");
+
+    Response response = getObjectAttributes(rest, BUCKET_NAME, key, 
"ObjectParts");
+
+    assertEquals(HTTP_OK, response.getStatus());
+    GetObjectAttributesResponse attributes = (GetObjectAttributesResponse) 
response.getEntity();
+    GetObjectAttributesResponse.ObjectParts objectParts = 
attributes.getObjectParts();
+    assertNotNull(objectParts);
+    assertEquals(3, objectParts.getPartsCount().intValue());
+    assertFalse(objectParts.isTruncated());
+    assertEquals(S3Consts.GET_OBJECT_ATTRIBUTES_MAX_PARTS_LIMIT, 
objectParts.getMaxParts().intValue());
+    assertNull(objectParts.getPartNumberMarker());
+    assertNull(objectParts.getNextPartNumberMarker());
+    assertTrue(objectParts.getParts().isEmpty());
+  }
+
+  @Test
+  public void 
testGetObjectAttributesMultipartObjectPartsReturnsPartsWhenChecksumStored()
+      throws IOException, OS3Exception {
+    final String key = "mpu-with-checksum";
+    completeMultipartUploadWithParts(key, "part-one", "part-two");
+    ((OzoneBucketStub) bucket).putKeyMetadataForTest(key, 
"x-amz-checksum-crc32", "dummy");
+
+    Response response = getObjectAttributes(rest, BUCKET_NAME, key, 
"ObjectParts");
+
+    assertEquals(HTTP_OK, response.getStatus());
+    GetObjectAttributesResponse.ObjectParts objectParts =
+        ((GetObjectAttributesResponse) response.getEntity()).getObjectParts();
+    assertEquals(2, objectParts.getPartsCount().intValue());
+    assertEquals(2, objectParts.getParts().size());
+    assertEquals(1, objectParts.getParts().get(0).getPartNumber());
+    assertEquals("part-one".length(), objectParts.getParts().get(0).getSize());
+    assertEquals(2, objectParts.getParts().get(1).getPartNumber());
+    assertEquals("part-two".length(), objectParts.getParts().get(1).getSize());
+  }
+
+  @Test
+  public void testGetObjectAttributesMultipartObjectPartsPagination() throws 
IOException, OS3Exception {
+    final String key = "mpu-paginated";
+    completeMultipartUploadWithParts(key, "part-one", "part-two", 
"part-three");
+
+    Response response = getObjectAttributes(rest, BUCKET_NAME, key, 
"ObjectParts", 2, 0);
+
+    assertEquals(HTTP_OK, response.getStatus());
+    GetObjectAttributesResponse.ObjectParts objectParts =
+        ((GetObjectAttributesResponse) response.getEntity()).getObjectParts();
+    assertEquals(3, objectParts.getPartsCount().intValue());
+    assertTrue(objectParts.isTruncated());
+    assertEquals(2, objectParts.getMaxParts().intValue());
+    assertEquals(0, objectParts.getPartNumberMarker().intValue());
+    assertEquals(2, objectParts.getNextPartNumberMarker().intValue());
+    assertTrue(objectParts.getParts().isEmpty());
+  }
+
+  @Test
+  public void testGetObjectAttributesInvalidMaxParts() throws IOException, 
OS3Exception {
+    final String key = "mpu-invalid-max-parts";
+    completeMultipartUploadWithParts(key, "part-one", "part-two");
+
+    assertErrorResponse(INVALID_ARGUMENT,
+        () -> getObjectAttributes(rest, BUCKET_NAME, key, "ObjectParts",
+            S3Consts.GET_OBJECT_ATTRIBUTES_MAX_PARTS_LIMIT + 1, null));
+  }
+
+  @Test
+  public void testGetObjectAttributesNonContiguousMultipartParts() throws 
IOException, OS3Exception {

Review Comment:
   This test verifies the total count for non-contiguous parts, but it does not 
verify the actual `PartNumber` and `Size` values.
   
   Please add checksum metadata to this object and assert that the response 
contains parts `1` and `3` with their correct sizes. Also test pagination with 
marker `1` to confirm that part `3` is returned and part `2` is not assumed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to