Gargi-jais11 commented on code in PR #11020:
URL: https://github.com/apache/ozone/pull/11020#discussion_r3912519638
##########
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:
extented the test case assertions.
--
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]