You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "0lai0 (via GitHub)" <gi...@apache.org> on 2025/12/07 13:42:52 UTC
[PR] HDDS-13081. Add S3 Object tagging tests [ozone]
0lai0 opened a new pull request, #9457:
URL: https://github.com/apache/ozone/pull/9457
## What changes were proposed in this pull request?
Adding PutObjectTagging, GetObjectTagging, DeleteObjectTagging SDK integration tests to validate.
## What is the link to the Apache JIRA
[https://issues.apache.org/jira/browse/HDDS-13081](https://issues.apache.org/jira/browse/HDDS-13081)
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "jojochuang (via GitHub)" <gi...@apache.org>.
jojochuang commented on PR #9457:
URL: https://github.com/apache/ozone/pull/9457#issuecomment-3793812417
Hi I see there's a lot of iterations on this test PR, which is great. To close the loop, since all comments are addressed I'd like to move it forward.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on PR #9457:
URL: https://github.com/apache/ozone/pull/9457#issuecomment-3823155847
> I notice some tests failed, I need to fix them.
https://github.com/0lai0/ozone/actions/runs/21510299989/job/61976509731#step:13:5994
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "0lai0 (via GitHub)" <gi...@apache.org>.
0lai0 commented on PR #9457:
URL: https://github.com/apache/ozone/pull/9457#issuecomment-3674286226
Thanks for all the feedback. I'll review and make changes based on the comments.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "Gargi-jais11 (via GitHub)" <gi...@apache.org>.
Gargi-jais11 commented on code in PR #9457:
URL: https://github.com/apache/ozone/pull/9457#discussion_r2626430995
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v1/AbstractS3SDKV1Tests.java:
##########
@@ -1384,6 +1387,86 @@ public void testPresignedUrlDelete() throws IOException {
}
}
+ @Nested
+ @TestInstance(TestInstance.Lifecycle.PER_CLASS)
+ static class BucketOwnershipLinkBucketTests {
+ private String nonS3VolumeName;
+ private String linkBucketName;
+ private String sourceBucketName;
+ private String danglingSourceBucketName;
+ private String danglingLinkBucketName;
+ private OzoneVolume nonS3Volume;
+ private OzoneVolume s3Volume;
+
+ @BeforeAll
+ public void setup() throws Exception {
+ nonS3VolumeName = randomName("link-vol");
+ linkBucketName = randomName("link-bucket");
+ sourceBucketName = randomName("source");
+ danglingSourceBucketName = randomName("link-source");
+ danglingLinkBucketName = randomName("link-bucket-dangling");
+ try (OzoneClient ozoneClient = cluster.newClient()) {
+ ObjectStore store = ozoneClient.getObjectStore();
+ store.createVolume(nonS3VolumeName);
+ nonS3Volume = store.getVolume(nonS3VolumeName);
+ s3Volume = store.getS3Volume();
+ }
+ }
+
+ @Test
+ public void setBucketVerificationOnLinkBucket() throws Exception {
+ nonS3Volume.createBucket(sourceBucketName);
+ BucketArgs.Builder bb = new BucketArgs.Builder()
+ .setStorageType(StorageType.DEFAULT)
+ .setVersioning(false)
+ .setSourceVolume(nonS3VolumeName)
+ .setSourceBucket(sourceBucketName);
+ s3Volume.createBucket(linkBucketName, bb.build());
+
+ GetBucketAclRequest wrongRequest = new GetBucketAclRequest(linkBucketName)
+ .withExpectedBucketOwner("wrong-owner");
+ AmazonServiceException wrongOwner = assertThrows(AmazonServiceException.class,
+ () -> s3Client.getBucketAcl(wrongRequest));
+ assertEquals(403, wrongOwner.getStatusCode());
+ assertEquals("AccessDenied", wrongOwner.getErrorCode());
+
+ Owner owner = s3Client.getBucketAcl(linkBucketName).getOwner();
+ GetBucketAclRequest correctRequest = new GetBucketAclRequest(linkBucketName)
+ .withExpectedBucketOwner(owner.getDisplayName());
+ assertDoesNotThrow(() -> s3Client.getBucketAcl(correctRequest));
+ }
+
+ @Test
+ public void testDanglingBucket() throws Exception {
+ nonS3Volume.createBucket(danglingSourceBucketName);
+ BucketArgs.Builder bb = new BucketArgs.Builder()
+ .setStorageType(StorageType.DEFAULT)
+ .setVersioning(false)
+ .setSourceVolume(nonS3VolumeName)
+ .setSourceBucket(danglingSourceBucketName);
+ s3Volume.createBucket(danglingLinkBucketName, bb.build());
+
+ nonS3Volume.deleteBucket(danglingSourceBucketName);
+
+ GetBucketAclRequest wrongRequest = new GetBucketAclRequest(danglingLinkBucketName)
+ .withExpectedBucketOwner("wrong-owner");
+ AmazonServiceException wrongOwner = assertThrows(AmazonServiceException.class,
+ () -> s3Client.getBucketAcl(wrongRequest));
+ assertEquals(403, wrongOwner.getStatusCode());
Review Comment:
use `HttpURLConnection.HTTP_FORBIDDEN`
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java:
##########
@@ -383,6 +387,215 @@ public void testCopyObject() {
assertEquals("\"37b51d194a7513e45b56f6524f2d51f2\"", copyObjectResponse.copyObjectResult().eTag());
}
+ @Test
+ public void testPutAndGetObjectTagging() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ final String content = "test content";
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ s3Client.putObject(b -> b
+ .bucket(bucketName)
+ .key(keyName),
+ RequestBody.fromString(content));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("env").value("test").build(),
+ Tag.builder().key("project").value("ozone").build()
+ );
+
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build()));
+
+ GetObjectTaggingResponse getResponse = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+
+ assertEquals(tags.size(), getResponse.tagSet().size());
+ Map<String, String> tagMap = getResponse.tagSet().stream()
+ .collect(Collectors.toMap(Tag::key, Tag::value));
+ assertEquals("test", tagMap.get("env"));
+ assertEquals("ozone", tagMap.get("project"));
+ }
+
+ @Test
+ public void testDeleteObjectTagging() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ final String content = "test content";
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ s3Client.putObject(b -> b
+ .bucket(bucketName)
+ .key(keyName),
+ RequestBody.fromString(content));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("temp").value("data").build()
+ );
+
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build()));
+
+ GetObjectTaggingResponse beforeDelete = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertEquals(1, beforeDelete.tagSet().size());
+
+ s3Client.deleteObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+
+ GetObjectTaggingResponse afterDelete = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertTrue(afterDelete.tagSet().isEmpty());
+ }
+
+ @Test
+ public void testPutObjectTaggingExceedsLimit() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+ s3Client.putObject(b -> b.bucket(bucketName).key(keyName),
+ RequestBody.fromString("content"));
+
+ List<Tag> tags = new ArrayList<>();
+ for (int i = 1; i <= 11; i++) {
+ tags.add(Tag.builder().key("key" + i).value("value" + i).build());
+ }
+
+ S3Exception exception = assertThrows(S3Exception.class, () ->
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build())));
+ assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, exception.statusCode());
+ }
+
+ @Test
+ public void testPutObjectTaggingReplacesExistingTags() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+ s3Client.putObject(b -> b.bucket(bucketName).key(keyName),
+ RequestBody.fromString("content"));
+
+ List<Tag> initialTags = Arrays.asList(
+ Tag.builder().key("tag1").value("value1").build(),
+ Tag.builder().key("tag2").value("value2").build()
+ );
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(initialTags).build()));
+
+ List<Tag> replacementTags = Arrays.asList(
+ Tag.builder().key("tag3").value("value3").build()
+ );
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(replacementTags).build()));
+
+ GetObjectTaggingResponse response = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertEquals(1, response.tagSet().size());
+ Map<String, String> tagMap = response.tagSet().stream()
+ .collect(Collectors.toMap(Tag::key, Tag::value));
+ assertEquals("value3", tagMap.get("tag3"));
+ assertFalse(tagMap.containsKey("tag1"));
+ assertFalse(tagMap.containsKey("tag2"));
+ }
+
+ private static String repeatChar(char c, int count) {
+ StringBuilder sb = new StringBuilder(count);
+ for (int i = 0; i < count; i++) {
+ sb.append(c);
+ }
+ return sb.toString();
+ }
+
+ private static Stream<Arguments> invalidTagConstraintsProvider() {
+ return Stream.of(
+ Arguments.of(
+ Arrays.asList(Tag.builder().key(repeatChar('a', 129)).value("value").build()),
+ 400
+ ),
+ Arguments.of(
+ Arrays.asList(Tag.builder().key("valid-key").value(repeatChar('b', 257)).build()),
+ 400
+ ),
+ Arguments.of(
+ Arrays.asList(Tag.builder().key("t$ag@#invalid").value("value").build()),
+ 400
+ ),
+ Arguments.of(
+ Arrays.asList(Tag.builder().key("aws:test").value("value").build()),
+ 400
Review Comment:
Use `HTTP_BAD_REQUEST` in this Parameterised test.
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v1/AbstractS3SDKV1Tests.java:
##########
@@ -1384,6 +1387,86 @@ public void testPresignedUrlDelete() throws IOException {
}
}
+ @Nested
+ @TestInstance(TestInstance.Lifecycle.PER_CLASS)
+ static class BucketOwnershipLinkBucketTests {
+ private String nonS3VolumeName;
+ private String linkBucketName;
+ private String sourceBucketName;
+ private String danglingSourceBucketName;
+ private String danglingLinkBucketName;
+ private OzoneVolume nonS3Volume;
+ private OzoneVolume s3Volume;
+
+ @BeforeAll
+ public void setup() throws Exception {
+ nonS3VolumeName = randomName("link-vol");
+ linkBucketName = randomName("link-bucket");
+ sourceBucketName = randomName("source");
+ danglingSourceBucketName = randomName("link-source");
+ danglingLinkBucketName = randomName("link-bucket-dangling");
+ try (OzoneClient ozoneClient = cluster.newClient()) {
+ ObjectStore store = ozoneClient.getObjectStore();
+ store.createVolume(nonS3VolumeName);
+ nonS3Volume = store.getVolume(nonS3VolumeName);
+ s3Volume = store.getS3Volume();
+ }
+ }
+
+ @Test
+ public void setBucketVerificationOnLinkBucket() throws Exception {
+ nonS3Volume.createBucket(sourceBucketName);
+ BucketArgs.Builder bb = new BucketArgs.Builder()
+ .setStorageType(StorageType.DEFAULT)
+ .setVersioning(false)
+ .setSourceVolume(nonS3VolumeName)
+ .setSourceBucket(sourceBucketName);
+ s3Volume.createBucket(linkBucketName, bb.build());
+
+ GetBucketAclRequest wrongRequest = new GetBucketAclRequest(linkBucketName)
+ .withExpectedBucketOwner("wrong-owner");
+ AmazonServiceException wrongOwner = assertThrows(AmazonServiceException.class,
+ () -> s3Client.getBucketAcl(wrongRequest));
+ assertEquals(403, wrongOwner.getStatusCode());
Review Comment:
Use `HttpURLConnection.HTTP_FORBIDDEN`
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "0lai0 (via GitHub)" <gi...@apache.org>.
0lai0 commented on code in PR #9457:
URL: https://github.com/apache/ozone/pull/9457#discussion_r2715723090
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/s3/tagging/S3PutObjectTaggingRequest.java:
##########
@@ -56,6 +58,59 @@ public class S3PutObjectTaggingRequest extends OMKeyRequest {
private static final Logger LOG =
LoggerFactory.getLogger(S3PutObjectTaggingRequest.class);
+ // NOTE: These limits must be kept in sync with
+ // org.apache.hadoop.ozone.s3.util.S3Consts (S3 Gateway side),
+ // but OM cannot depend on s3gateway, so we define them here as well.
+ private static final int TAG_NUM_LIMIT = 10;
+ private static final int TAG_KEY_LENGTH_LIMIT = 128;
+ private static final int TAG_VALUE_LENGTH_LIMIT = 256;
+ private static final String AWS_TAG_PREFIX = "aws:";
+ private static final Pattern TAG_REGEX_PATTERN =
+ Pattern.compile("^([\\p{L}\\p{Z}\\p{N}_.:/=+\\-]*)$");
+
+ private static void validateTags(Map<String, String> tags) throws OMException {
Review Comment:
Got it. I've removed this part since the PR focuses on integration tests. Thanks for pointing that out.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "0lai0 (via GitHub)" <gi...@apache.org>.
0lai0 commented on PR #9457:
URL: https://github.com/apache/ozone/pull/9457#issuecomment-3783034746
Thanks @chungen0126 for review.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on PR #9457:
URL: https://github.com/apache/ozone/pull/9457#issuecomment-3682766268
Thanks @0lai0 for updating the patch. There are some test failures:
```
Error: Tests run: 31, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.045 s <<< FAILURE! -- in org.apache.hadoop.ozone.s3.awssdk.v1.AbstractS3SDKV1Tests$LinkBucketTests
Error: org.apache.hadoop.ozone.s3.awssdk.v1.AbstractS3SDKV1Tests$LinkBucketTests.testDanglingBucket -- Time elapsed: 0.016 s <<< FAILURE!
org.opentest4j.AssertionFailedError: expected: <AccessDenied> but was: <Access Denied>
...
at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1145)
at org.apache.hadoop.ozone.s3.awssdk.v1.AbstractS3SDKV1Tests$LinkBucketTests.testDanglingBucket(AbstractS3SDKV1Tests.java:1432)
...
Error: org.apache.hadoop.ozone.s3.awssdk.v1.AbstractS3SDKV1Tests$LinkBucketTests.setBucketVerificationOnLinkBucket -- Time elapsed: 0.020 s <<< FAILURE!
org.opentest4j.AssertionFailedError: expected: <AccessDenied> but was: <Access Denied>
...
at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1145)
at org.apache.hadoop.ozone.s3.awssdk.v1.AbstractS3SDKV1Tests$LinkBucketTests.setBucketVerificationOnLinkBucket(AbstractS3SDKV1Tests.java:1407)
```
https://github.com/0lai0/ozone/actions/runs/20396880835/job/58614335876#step:13:6020
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "Gargi-jais11 (via GitHub)" <gi...@apache.org>.
Gargi-jais11 commented on code in PR #9457:
URL: https://github.com/apache/ozone/pull/9457#discussion_r2626479350
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v1/AbstractS3SDKV1Tests.java:
##########
@@ -143,7 +146,7 @@
*
*/
@TestMethodOrder(MethodOrderer.MethodName.class)
-public abstract class AbstractS3SDKV1Tests extends OzoneTestBase {
Review Comment:
I believe `AbstractS3SDKV1Tests` should extend `OzoneTestBase` .
`OzoneTestBase.getTestName()` returns the actual test method name (e.g., `"testCreateBucket"`), ensuring unique resource names per test
- Without it, tests may interfere with each other and debugging becomes difficult
- This is a standard pattern used across all Ozone test classes
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "Gargi-jais11 (via GitHub)" <gi...@apache.org>.
Gargi-jais11 commented on PR #9457:
URL: https://github.com/apache/ozone/pull/9457#issuecomment-3664761783
@0lai0 After addressing the review comments please mark it as resolved.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #9457:
URL: https://github.com/apache/ozone/pull/9457#discussion_r2634368552
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v1/AbstractS3SDKV1Tests.java:
##########
@@ -143,7 +146,7 @@
*
*/
@TestMethodOrder(MethodOrderer.MethodName.class)
-public abstract class AbstractS3SDKV1Tests extends OzoneTestBase {
Review Comment:
@0lai0 HDDS-14197 is merged, now you can keep `extends OzoneTestBase` here and don't need to implement custom `getTestName()`.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "chungen0126 (via GitHub)" <gi...@apache.org>.
chungen0126 commented on code in PR #9457:
URL: https://github.com/apache/ozone/pull/9457#discussion_r2702397574
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/s3/tagging/S3PutObjectTaggingRequest.java:
##########
@@ -56,6 +58,59 @@ public class S3PutObjectTaggingRequest extends OMKeyRequest {
private static final Logger LOG =
LoggerFactory.getLogger(S3PutObjectTaggingRequest.class);
+ // NOTE: These limits must be kept in sync with
+ // org.apache.hadoop.ozone.s3.util.S3Consts (S3 Gateway side),
+ // but OM cannot depend on s3gateway, so we define them here as well.
+ private static final int TAG_NUM_LIMIT = 10;
+ private static final int TAG_KEY_LENGTH_LIMIT = 128;
+ private static final int TAG_VALUE_LENGTH_LIMIT = 256;
+ private static final String AWS_TAG_PREFIX = "aws:";
+ private static final Pattern TAG_REGEX_PATTERN =
+ Pattern.compile("^([\\p{L}\\p{Z}\\p{N}_.:/=+\\-]*)$");
+
+ private static void validateTags(Map<String, String> tags) throws OMException {
Review Comment:
What I meant was, why do we need tag verification here? My understanding is that the issue is about adding integration tests. Since this is a unit test, I don't think we need to make any changes here.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "Gargi-jais11 (via GitHub)" <gi...@apache.org>.
Gargi-jais11 commented on PR #9457:
URL: https://github.com/apache/ozone/pull/9457#issuecomment-3632144443
> Thanks for working on this @0lai0 , I second the suggestion of @Gargi-jais11 , the tests added mostly look good, but they are mainly the positive cases. Can we add tests for the error cases?
>
> Also, multiple related test cases could be put in one test method to avoid duplication.
Yes correct @Tejaskriya above test cases can be added to check for error cases.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "0lai0 (via GitHub)" <gi...@apache.org>.
0lai0 commented on code in PR #9457:
URL: https://github.com/apache/ozone/pull/9457#discussion_r2702061153
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/s3/tagging/S3PutObjectTaggingRequest.java:
##########
@@ -56,6 +58,59 @@ public class S3PutObjectTaggingRequest extends OMKeyRequest {
private static final Logger LOG =
LoggerFactory.getLogger(S3PutObjectTaggingRequest.class);
+ // NOTE: These limits must be kept in sync with
+ // org.apache.hadoop.ozone.s3.util.S3Consts (S3 Gateway side),
+ // but OM cannot depend on s3gateway, so we define them here as well.
+ private static final int TAG_NUM_LIMIT = 10;
+ private static final int TAG_KEY_LENGTH_LIMIT = 128;
+ private static final int TAG_VALUE_LENGTH_LIMIT = 256;
+ private static final String AWS_TAG_PREFIX = "aws:";
+ private static final Pattern TAG_REGEX_PATTERN =
+ Pattern.compile("^([\\p{L}\\p{Z}\\p{N}_.:/=+\\-]*)$");
+
+ private static void validateTags(Map<String, String> tags) throws OMException {
Review Comment:
My mistake regarding the TAG_REGEX_PATTERN. S3 specs only enforce length limits, not character constraints.I'll remove the regex check and push the fix right away. Thanks @chungen0126 .
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #9457:
URL: https://github.com/apache/ozone/pull/9457#issuecomment-3978671820
Thank you for your contribution. This PR is being closed due to inactivity. Please contact a maintainer if you would like to reopen it.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "0lai0 (via GitHub)" <gi...@apache.org>.
0lai0 commented on PR #9457:
URL: https://github.com/apache/ozone/pull/9457#issuecomment-3654428984
Thanks @ivandika3, @Gargi-jais11 and @echonesis for review.I'll push a fix right away.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "0lai0 (via GitHub)" <gi...@apache.org>.
0lai0 commented on code in PR #9457:
URL: https://github.com/apache/ozone/pull/9457#discussion_r2652144991
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java:
##########
@@ -370,6 +377,215 @@ public void testCopyObject() {
assertEquals("\"37b51d194a7513e45b56f6524f2d51f2\"", copyObjectResponse.copyObjectResult().eTag());
}
+ @Test
+ public void testPutAndGetObjectTagging() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ final String content = "test content";
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ s3Client.putObject(b -> b
+ .bucket(bucketName)
+ .key(keyName),
+ RequestBody.fromString(content));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("env").value("test").build(),
+ Tag.builder().key("project").value("ozone").build()
+ );
+
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build()));
+
+ GetObjectTaggingResponse getResponse = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+
+ assertEquals(tags.size(), getResponse.tagSet().size());
+ Map<String, String> tagMap = getResponse.tagSet().stream()
+ .collect(Collectors.toMap(Tag::key, Tag::value));
+ assertEquals("test", tagMap.get("env"));
+ assertEquals("ozone", tagMap.get("project"));
+ }
+
+ @Test
+ public void testDeleteObjectTagging() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ final String content = "test content";
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ s3Client.putObject(b -> b
+ .bucket(bucketName)
+ .key(keyName),
+ RequestBody.fromString(content));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("temp").value("data").build()
+ );
+
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build()));
+
+ GetObjectTaggingResponse beforeDelete = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertEquals(1, beforeDelete.tagSet().size());
+
+ s3Client.deleteObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+
+ GetObjectTaggingResponse afterDelete = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertTrue(afterDelete.tagSet().isEmpty());
+ }
+
+ @Test
+ public void testPutObjectTaggingExceedsLimit() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+ s3Client.putObject(b -> b.bucket(bucketName).key(keyName),
+ RequestBody.fromString("content"));
+
+ List<Tag> tags = new ArrayList<>();
+ for (int i = 1; i <= 11; i++) {
Review Comment:
My apologies, I'll replace hardcoded values with constants
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "0lai0 (via GitHub)" <gi...@apache.org>.
0lai0 commented on PR #9457:
URL: https://github.com/apache/ozone/pull/9457#issuecomment-3635570896
Thanks @Gargi-jais11 and @Tejaskriya review, I'll add error cases.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #9457: HDDS-13081. Add S3 Object tagging tests
URL: https://github.com/apache/ozone/pull/9457
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on code in PR #9457:
URL: https://github.com/apache/ozone/pull/9457#discussion_r2626833693
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v1/AbstractS3SDKV1Tests.java:
##########
@@ -143,7 +146,7 @@
*
*/
@TestMethodOrder(MethodOrderer.MethodName.class)
-public abstract class AbstractS3SDKV1Tests extends OzoneTestBase {
Review Comment:
The problem is test name may not be unique (e.g. for parameterized test). #9517 adds a method in `OzoneTestBase` to help with that, and changes these S3 tests to use `uniqueObjectName()` instead of just `getTestName()`.
+1 for keeping `OzoneTestBase`.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "chungen0126 (via GitHub)" <gi...@apache.org>.
chungen0126 commented on code in PR #9457:
URL: https://github.com/apache/ozone/pull/9457#discussion_r2701948658
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/s3/tagging/S3PutObjectTaggingRequest.java:
##########
@@ -56,6 +58,59 @@ public class S3PutObjectTaggingRequest extends OMKeyRequest {
private static final Logger LOG =
LoggerFactory.getLogger(S3PutObjectTaggingRequest.class);
+ // NOTE: These limits must be kept in sync with
+ // org.apache.hadoop.ozone.s3.util.S3Consts (S3 Gateway side),
+ // but OM cannot depend on s3gateway, so we define them here as well.
+ private static final int TAG_NUM_LIMIT = 10;
+ private static final int TAG_KEY_LENGTH_LIMIT = 128;
+ private static final int TAG_VALUE_LENGTH_LIMIT = 256;
+ private static final String AWS_TAG_PREFIX = "aws:";
+ private static final Pattern TAG_REGEX_PATTERN =
+ Pattern.compile("^([\\p{L}\\p{Z}\\p{N}_.:/=+\\-]*)$");
+
+ private static void validateTags(Map<String, String> tags) throws OMException {
Review Comment:
Could you please explain why we need this here?
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "0lai0 (via GitHub)" <gi...@apache.org>.
0lai0 commented on PR #9457:
URL: https://github.com/apache/ozone/pull/9457#issuecomment-3794792143
I notice some tests failed, I need to fix them. Thanks @jojochuang .
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "Gargi-jais11 (via GitHub)" <gi...@apache.org>.
Gargi-jais11 commented on code in PR #9457:
URL: https://github.com/apache/ozone/pull/9457#discussion_r2596997260
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java:
##########
@@ -383,6 +384,108 @@ public void testCopyObject() {
assertEquals("\"37b51d194a7513e45b56f6524f2d51f2\"", copyObjectResponse.copyObjectResult().eTag());
}
+ @Test
+ public void testPutObjectTagging() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ final String content = "test content";
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ s3Client.putObject(b -> b
+ .bucket(bucketName)
+ .key(keyName),
+ RequestBody.fromString(content));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("env").value("test").build(),
+ Tag.builder().key("project").value("ozone").build()
+ );
+
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build()));
+
+ GetObjectTaggingResponse response = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+
+ assertEquals(tags.size(), response.tagSet().size());
+ Map<String, String> tagMap = response.tagSet().stream()
+ .collect(Collectors.toMap(Tag::key, Tag::value));
+ assertEquals("test", tagMap.get("env"));
+ assertEquals("ozone", tagMap.get("project"));
+ }
+
+ @Test
+ public void testGetObjectTagging() {
Review Comment:
`testPutObjectTagging()`and `testGetObjectTagging()`, are functionally very similar and could be merged into a single test named as `testPutAndGetObjectTagging()`.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "echonesis (via GitHub)" <gi...@apache.org>.
echonesis commented on PR #9457:
URL: https://github.com/apache/ozone/pull/9457#issuecomment-3654448844
Thanks @0lai0 , left some comments.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "Gargi-jais11 (via GitHub)" <gi...@apache.org>.
Gargi-jais11 commented on PR #9457:
URL: https://github.com/apache/ozone/pull/9457#issuecomment-3649555330
@0lai0 Thanks for updating the patch. It LGTM.
> Could you also add similar tests to the AbstractS3SDKV1Tests as well?
Once this is done the patch will be good to go.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "ivandika3 (via GitHub)" <gi...@apache.org>.
ivandika3 commented on PR #9457:
URL: https://github.com/apache/ozone/pull/9457#issuecomment-3667899611
> @0lai0 After addressing the review comments please mark it as resolved.
@Gargi-jais11 IMO the responsibility of resolving comments are in the reviewer since it signals that that the comment is already addressed to the reviewer's satisfaction.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #9457:
URL: https://github.com/apache/ozone/pull/9457#issuecomment-3937719713
This PR has been marked as stale due to 21 days of inactivity. Please comment or remove the stale label to keep it open. Otherwise, it will be automatically closed in 7 days.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "0lai0 (via GitHub)" <gi...@apache.org>.
0lai0 commented on code in PR #9457:
URL: https://github.com/apache/ozone/pull/9457#discussion_r2637192245
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v1/AbstractS3SDKV1Tests.java:
##########
@@ -143,7 +146,7 @@
*
*/
@TestMethodOrder(MethodOrderer.MethodName.class)
-public abstract class AbstractS3SDKV1Tests extends OzoneTestBase {
Review Comment:
Thanks everyone for the discussion, and thanks @adoroszlai for the update on [HDDS-14197.](https://issues.apache.org/jira/browse/HDDS-14197) I'll keep OzoneTestBase and remove the custom getTestName() implementation.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "0lai0 (via GitHub)" <gi...@apache.org>.
0lai0 commented on code in PR #9457:
URL: https://github.com/apache/ozone/pull/9457#discussion_r2637191886
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v1/AbstractS3SDKV1Tests.java:
##########
@@ -1384,6 +1387,86 @@ public void testPresignedUrlDelete() throws IOException {
}
}
+ @Nested
+ @TestInstance(TestInstance.Lifecycle.PER_CLASS)
+ class BucketOwnershipLinkBucketTests {
Review Comment:
Sure, I'll get on this.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "0lai0 (via GitHub)" <gi...@apache.org>.
0lai0 commented on PR #9457:
URL: https://github.com/apache/ozone/pull/9457#issuecomment-3696018241
Thanks @adoroszlai for review. I've pushed a commit to address test failures by AssertionFailedError.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "echonesis (via GitHub)" <gi...@apache.org>.
echonesis commented on code in PR #9457:
URL: https://github.com/apache/ozone/pull/9457#discussion_r2626219460
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v1/AbstractS3SDKV1Tests.java:
##########
@@ -143,7 +146,7 @@
*
*/
@TestMethodOrder(MethodOrderer.MethodName.class)
-public abstract class AbstractS3SDKV1Tests extends OzoneTestBase {
Review Comment:
Removal of `OzoneTestBase` should be consistent between `V1` and `V2`.
The `V2` version still extends `OzoneTestBase`, so `getTestName()` returns a fixed test method name instead of a random string. This could cause naming conflicts in parallel test execution.
Consider removing `OzoneTestBase` from V2 as well and adding the same random-based `getTestName()` method.
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v1/AbstractS3SDKV1Tests.java:
##########
@@ -1384,6 +1387,86 @@ public void testPresignedUrlDelete() throws IOException {
}
}
+ @Nested
+ @TestInstance(TestInstance.Lifecycle.PER_CLASS)
+ class BucketOwnershipLinkBucketTests {
Review Comment:
Maybe we could keep it consistent with [the V2 class](https://github.com/apache/ozone/blob/2029b59898a737a9c5d4a1ee54195fa16e7ed369/hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java#L1673)
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "Gargi-jais11 (via GitHub)" <gi...@apache.org>.
Gargi-jais11 commented on PR #9457:
URL: https://github.com/apache/ozone/pull/9457#issuecomment-3624770967
More Edge Cases which can be tested:
1. `testPutObjectTaggingExceedsLimit()` — Test 11 tags and validate it throws error there is 10-tag limit.
2. `testPutObjectTaggingReplacesExistingTags()` — verifies replacement behavior (Initially put 2 tags then replace it with 1 tag and check the last replcaed tag is only applied)
3. `testPutObjectTaggingInvalidConstraints` - This can be a **parameterised test** like below:
```
private static Stream<Arguments> invalidTagConstraintsProvider() {
return Stream.of(
// Test 1: Tag key exceeds maximum length (128 bytes)
Arguments.of(
"Tag key exceeding 128 bytes should be rejected",
Arrays.asList(Tag.builder().key("a".repeat(129)).value("value").build()),
400,
"exceeds the maximum length"
),
// Test 2: Tag value exceeds maximum length (256 bytes)
Arguments.of(
"Tag value exceeding 256 bytes should be rejected",
Arrays.asList(Tag.builder().key("valid-key").value("b".repeat(257)).build()),
400,
"exceeds the maximum length"
),
// Test 3: Tag key with invalid characters (@, #, $, (, {, ....)
Arguments.of(
"Tag key with invalid characters should be rejected",
Arrays.asList(Tag.builder().key("t$ag@#invalid").value("value").build()),
400,
"does not have a valid pattern"
),
// Test 4: Tag key starting with "aws:" prefix
Arguments.of(
"Tag key starting with 'aws:' prefix should be rejected",
Arrays.asList(Tag.builder().key("aws:test").value("value").build()),
400,
"cannot start with \"aws:\""
)
);
}
@ParameterizedTest
@MethodSource("invalidTagConstraintsProvider")
public void testPutObjectTaggingInvalidConstraints(
String testCaseName,
List<Tag> invalidTags,
int expectedStatusCode,
String expectedErrorMessage) {
// your code
}
```
4. `testPutAndGetObjectTaggingOnNonExistentObject()` - Verify `NoSuchKeyException` occurs and **404 status code**.
5. `testDeleteObjectTaggingOnNonExistentObject()` - Verify `NoSuchKeyException` occurs and **404 status code**.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "Gargi-jais11 (via GitHub)" <gi...@apache.org>.
Gargi-jais11 commented on code in PR #9457:
URL: https://github.com/apache/ozone/pull/9457#discussion_r2626534309
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v1/AbstractS3SDKV1Tests.java:
##########
@@ -1384,6 +1387,86 @@ public void testPresignedUrlDelete() throws IOException {
}
}
+ @Nested
+ @TestInstance(TestInstance.Lifecycle.PER_CLASS)
+ class BucketOwnershipLinkBucketTests {
Review Comment:
Yes we should keep the name consistent with [the V2 class](https://github.com/apache/ozone/blob/2029b59898a737a9c5d4a1ee54195fa16e7ed369/hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java#L1673) as `LinkBucketTests`
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "Gargi-jais11 (via GitHub)" <gi...@apache.org>.
Gargi-jais11 commented on code in PR #9457:
URL: https://github.com/apache/ozone/pull/9457#discussion_r2626495288
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v1/AbstractS3SDKV1Tests.java:
##########
@@ -1461,6 +1544,10 @@ private String getKeyName(String suffix) {
return (getTestName() + "key" + suffix).toLowerCase(Locale.ROOT);
}
+ private String getTestName() {
+ return RandomStringUtils.secure().nextAlphanumeric(8).toLowerCase(Locale.ROOT);
+ }
+
Review Comment:
@0lai0 is there any specific purpose because of which you are creating `getTestName` explicity over here and not using `OzoneTestBase#getTestName`?
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "0lai0 (via GitHub)" <gi...@apache.org>.
0lai0 commented on code in PR #9457:
URL: https://github.com/apache/ozone/pull/9457#discussion_r2637192897
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v1/AbstractS3SDKV1Tests.java:
##########
@@ -1461,6 +1544,10 @@ private String getKeyName(String suffix) {
return (getTestName() + "key" + suffix).toLowerCase(Locale.ROOT);
}
+ private String getTestName() {
+ return RandomStringUtils.secure().nextAlphanumeric(8).toLowerCase(Locale.ROOT);
+ }
+
Review Comment:
Thanks for point this out , I'll remove it.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "ivandika3 (via GitHub)" <gi...@apache.org>.
ivandika3 commented on PR #9457:
URL: https://github.com/apache/ozone/pull/9457#issuecomment-3704315489
@0lai0 Thanks for the update. Overall LGTM.
Please kindly check the failing test https://github.com/0lai0/ozone/actions/runs/20588433897/job/59131635706
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "echonesis (via GitHub)" <gi...@apache.org>.
echonesis commented on code in PR #9457:
URL: https://github.com/apache/ozone/pull/9457#discussion_r2617768975
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java:
##########
@@ -383,6 +388,215 @@ public void testCopyObject() {
assertEquals("\"37b51d194a7513e45b56f6524f2d51f2\"", copyObjectResponse.copyObjectResult().eTag());
}
+ @Test
+ public void testPutAndGetObjectTagging() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ final String content = "test content";
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ s3Client.putObject(b -> b
+ .bucket(bucketName)
+ .key(keyName),
+ RequestBody.fromString(content));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("env").value("test").build(),
+ Tag.builder().key("project").value("ozone").build()
+ );
+
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build()));
+
+ GetObjectTaggingResponse getResponse = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+
+ assertEquals(tags.size(), getResponse.tagSet().size());
+ Map<String, String> tagMap = getResponse.tagSet().stream()
+ .collect(Collectors.toMap(Tag::key, Tag::value));
+ assertEquals("test", tagMap.get("env"));
+ assertEquals("ozone", tagMap.get("project"));
+ }
+
+ @Test
+ public void testDeleteObjectTagging() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ final String content = "test content";
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ s3Client.putObject(b -> b
+ .bucket(bucketName)
+ .key(keyName),
+ RequestBody.fromString(content));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("temp").value("data").build()
+ );
+
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build()));
+
+ GetObjectTaggingResponse beforeDelete = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertEquals(1, beforeDelete.tagSet().size());
+
+ s3Client.deleteObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+
+ GetObjectTaggingResponse afterDelete = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertTrue(afterDelete.tagSet().isEmpty());
+ }
+
+ @Test
+ public void testPutObjectTaggingExceedsLimit() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+ s3Client.putObject(b -> b.bucket(bucketName).key(keyName),
+ RequestBody.fromString("content"));
+
+ List<Tag> tags = new ArrayList<>();
+ for (int i = 1; i <= 11; i++) {
+ tags.add(Tag.builder().key("key" + i).value("value" + i).build());
+ }
+
+ S3Exception exception = assertThrows(S3Exception.class, () ->
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build())));
+ assertEquals(400, exception.statusCode());
+ }
+
+ @Test
+ public void testPutObjectTaggingReplacesExistingTags() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+ s3Client.putObject(b -> b.bucket(bucketName).key(keyName),
+ RequestBody.fromString("content"));
+
+ List<Tag> initialTags = Arrays.asList(
+ Tag.builder().key("tag1").value("value1").build(),
+ Tag.builder().key("tag2").value("value2").build()
+ );
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(initialTags).build()));
+
+ List<Tag> replacementTags = Arrays.asList(
+ Tag.builder().key("tag3").value("value3").build()
+ );
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(replacementTags).build()));
+
+ GetObjectTaggingResponse response = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertEquals(1, response.tagSet().size());
+ Map<String, String> tagMap = response.tagSet().stream()
+ .collect(Collectors.toMap(Tag::key, Tag::value));
+ assertEquals("value3", tagMap.get("tag3"));
+ assertFalse(tagMap.containsKey("tag1"));
+ assertFalse(tagMap.containsKey("tag2"));
+ }
+
+ private static String repeatChar(char c, int count) {
+ StringBuilder sb = new StringBuilder(count);
+ for (int i = 0; i < count; i++) {
+ sb.append(c);
+ }
+ return sb.toString();
+ }
+
+ private static Stream<Arguments> invalidTagConstraintsProvider() {
+ return Stream.of(
+ Arguments.of(
+ Arrays.asList(Tag.builder().key(repeatChar('a', 129)).value("value").build()),
+ 400
+ ),
+ Arguments.of(
+ Arrays.asList(Tag.builder().key("valid-key").value(repeatChar('b', 257)).build()),
+ 400
+ ),
+ Arguments.of(
+ Arrays.asList(Tag.builder().key("t$ag@#invalid").value("value").build()),
+ 400
+ ),
+ Arguments.of(
+ Arrays.asList(Tag.builder().key("aws:test").value("value").build()),
+ 400
+ )
+ );
+ }
+
+ @ParameterizedTest
+ @MethodSource("invalidTagConstraintsProvider")
+ public void testPutObjectTaggingInvalidConstraints(List<Tag> invalidTags, int expectedStatusCode) {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+ s3Client.putObject(b -> b.bucket(bucketName).key(keyName),
+ RequestBody.fromString("content"));
+
+ S3Exception exception = assertThrows(S3Exception.class, () ->
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(invalidTags).build())));
+ assertEquals(expectedStatusCode, exception.statusCode());
+ }
+
+ @Test
+ public void testPutAndGetObjectTaggingOnNonExistentObject() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("env").value("test").build()
+ );
+
+ NoSuchKeyException exception = assertThrows(NoSuchKeyException.class, () ->
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build())));
+ assertEquals(404, exception.statusCode());
+
+ exception = assertThrows(NoSuchKeyException.class, () ->
+ s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)));
+ assertEquals(404, exception.statusCode());
Review Comment:
Same as https://github.com/apache/ozone/pull/9457/changes#r2617768342
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java:
##########
@@ -383,6 +388,215 @@ public void testCopyObject() {
assertEquals("\"37b51d194a7513e45b56f6524f2d51f2\"", copyObjectResponse.copyObjectResult().eTag());
}
+ @Test
+ public void testPutAndGetObjectTagging() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ final String content = "test content";
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ s3Client.putObject(b -> b
+ .bucket(bucketName)
+ .key(keyName),
+ RequestBody.fromString(content));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("env").value("test").build(),
+ Tag.builder().key("project").value("ozone").build()
+ );
+
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build()));
+
+ GetObjectTaggingResponse getResponse = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+
+ assertEquals(tags.size(), getResponse.tagSet().size());
+ Map<String, String> tagMap = getResponse.tagSet().stream()
+ .collect(Collectors.toMap(Tag::key, Tag::value));
+ assertEquals("test", tagMap.get("env"));
+ assertEquals("ozone", tagMap.get("project"));
+ }
+
+ @Test
+ public void testDeleteObjectTagging() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ final String content = "test content";
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ s3Client.putObject(b -> b
+ .bucket(bucketName)
+ .key(keyName),
+ RequestBody.fromString(content));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("temp").value("data").build()
+ );
+
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build()));
+
+ GetObjectTaggingResponse beforeDelete = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertEquals(1, beforeDelete.tagSet().size());
+
+ s3Client.deleteObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+
+ GetObjectTaggingResponse afterDelete = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertTrue(afterDelete.tagSet().isEmpty());
+ }
+
+ @Test
+ public void testPutObjectTaggingExceedsLimit() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+ s3Client.putObject(b -> b.bucket(bucketName).key(keyName),
+ RequestBody.fromString("content"));
+
+ List<Tag> tags = new ArrayList<>();
+ for (int i = 1; i <= 11; i++) {
+ tags.add(Tag.builder().key("key" + i).value("value" + i).build());
+ }
+
+ S3Exception exception = assertThrows(S3Exception.class, () ->
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build())));
+ assertEquals(400, exception.statusCode());
+ }
+
+ @Test
+ public void testPutObjectTaggingReplacesExistingTags() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+ s3Client.putObject(b -> b.bucket(bucketName).key(keyName),
+ RequestBody.fromString("content"));
+
+ List<Tag> initialTags = Arrays.asList(
+ Tag.builder().key("tag1").value("value1").build(),
+ Tag.builder().key("tag2").value("value2").build()
+ );
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(initialTags).build()));
+
+ List<Tag> replacementTags = Arrays.asList(
+ Tag.builder().key("tag3").value("value3").build()
+ );
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(replacementTags).build()));
+
+ GetObjectTaggingResponse response = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertEquals(1, response.tagSet().size());
+ Map<String, String> tagMap = response.tagSet().stream()
+ .collect(Collectors.toMap(Tag::key, Tag::value));
+ assertEquals("value3", tagMap.get("tag3"));
+ assertFalse(tagMap.containsKey("tag1"));
+ assertFalse(tagMap.containsKey("tag2"));
+ }
+
+ private static String repeatChar(char c, int count) {
+ StringBuilder sb = new StringBuilder(count);
+ for (int i = 0; i < count; i++) {
+ sb.append(c);
+ }
+ return sb.toString();
+ }
+
+ private static Stream<Arguments> invalidTagConstraintsProvider() {
+ return Stream.of(
+ Arguments.of(
+ Arrays.asList(Tag.builder().key(repeatChar('a', 129)).value("value").build()),
+ 400
+ ),
+ Arguments.of(
+ Arrays.asList(Tag.builder().key("valid-key").value(repeatChar('b', 257)).build()),
+ 400
+ ),
+ Arguments.of(
+ Arrays.asList(Tag.builder().key("t$ag@#invalid").value("value").build()),
+ 400
+ ),
+ Arguments.of(
+ Arrays.asList(Tag.builder().key("aws:test").value("value").build()),
+ 400
+ )
+ );
+ }
+
+ @ParameterizedTest
+ @MethodSource("invalidTagConstraintsProvider")
+ public void testPutObjectTaggingInvalidConstraints(List<Tag> invalidTags, int expectedStatusCode) {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+ s3Client.putObject(b -> b.bucket(bucketName).key(keyName),
+ RequestBody.fromString("content"));
+
+ S3Exception exception = assertThrows(S3Exception.class, () ->
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(invalidTags).build())));
+ assertEquals(expectedStatusCode, exception.statusCode());
+ }
+
+ @Test
+ public void testPutAndGetObjectTaggingOnNonExistentObject() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("env").value("test").build()
+ );
+
+ NoSuchKeyException exception = assertThrows(NoSuchKeyException.class, () ->
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build())));
+ assertEquals(404, exception.statusCode());
Review Comment:
```suggestion
assertEquals(HTTP_NOT_FOUND, exception.statusCode());
```
USE `HTTP_NOT_FOUND` to replace `404`.
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java:
##########
@@ -383,6 +388,215 @@ public void testCopyObject() {
assertEquals("\"37b51d194a7513e45b56f6524f2d51f2\"", copyObjectResponse.copyObjectResult().eTag());
}
+ @Test
+ public void testPutAndGetObjectTagging() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ final String content = "test content";
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ s3Client.putObject(b -> b
+ .bucket(bucketName)
+ .key(keyName),
+ RequestBody.fromString(content));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("env").value("test").build(),
+ Tag.builder().key("project").value("ozone").build()
+ );
+
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build()));
+
+ GetObjectTaggingResponse getResponse = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+
+ assertEquals(tags.size(), getResponse.tagSet().size());
+ Map<String, String> tagMap = getResponse.tagSet().stream()
+ .collect(Collectors.toMap(Tag::key, Tag::value));
+ assertEquals("test", tagMap.get("env"));
+ assertEquals("ozone", tagMap.get("project"));
+ }
+
+ @Test
+ public void testDeleteObjectTagging() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ final String content = "test content";
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ s3Client.putObject(b -> b
+ .bucket(bucketName)
+ .key(keyName),
+ RequestBody.fromString(content));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("temp").value("data").build()
+ );
+
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build()));
+
+ GetObjectTaggingResponse beforeDelete = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertEquals(1, beforeDelete.tagSet().size());
+
+ s3Client.deleteObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+
+ GetObjectTaggingResponse afterDelete = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertTrue(afterDelete.tagSet().isEmpty());
+ }
+
+ @Test
+ public void testPutObjectTaggingExceedsLimit() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+ s3Client.putObject(b -> b.bucket(bucketName).key(keyName),
+ RequestBody.fromString("content"));
+
+ List<Tag> tags = new ArrayList<>();
+ for (int i = 1; i <= 11; i++) {
+ tags.add(Tag.builder().key("key" + i).value("value" + i).build());
+ }
+
+ S3Exception exception = assertThrows(S3Exception.class, () ->
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build())));
+ assertEquals(400, exception.statusCode());
Review Comment:
```suggestion
assertEquals(HTTP_BAD_REQUEST, exception.statusCode());
```
Use `HTTP_BAD_REQUEST` to replace `400`.
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java:
##########
@@ -383,6 +388,215 @@ public void testCopyObject() {
assertEquals("\"37b51d194a7513e45b56f6524f2d51f2\"", copyObjectResponse.copyObjectResult().eTag());
}
+ @Test
+ public void testPutAndGetObjectTagging() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ final String content = "test content";
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ s3Client.putObject(b -> b
+ .bucket(bucketName)
+ .key(keyName),
+ RequestBody.fromString(content));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("env").value("test").build(),
+ Tag.builder().key("project").value("ozone").build()
+ );
+
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build()));
+
+ GetObjectTaggingResponse getResponse = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+
+ assertEquals(tags.size(), getResponse.tagSet().size());
+ Map<String, String> tagMap = getResponse.tagSet().stream()
+ .collect(Collectors.toMap(Tag::key, Tag::value));
+ assertEquals("test", tagMap.get("env"));
+ assertEquals("ozone", tagMap.get("project"));
+ }
+
+ @Test
+ public void testDeleteObjectTagging() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ final String content = "test content";
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ s3Client.putObject(b -> b
+ .bucket(bucketName)
+ .key(keyName),
+ RequestBody.fromString(content));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("temp").value("data").build()
+ );
+
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build()));
+
+ GetObjectTaggingResponse beforeDelete = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertEquals(1, beforeDelete.tagSet().size());
+
+ s3Client.deleteObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+
+ GetObjectTaggingResponse afterDelete = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertTrue(afterDelete.tagSet().isEmpty());
+ }
+
+ @Test
+ public void testPutObjectTaggingExceedsLimit() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+ s3Client.putObject(b -> b.bucket(bucketName).key(keyName),
+ RequestBody.fromString("content"));
+
+ List<Tag> tags = new ArrayList<>();
+ for (int i = 1; i <= 11; i++) {
+ tags.add(Tag.builder().key("key" + i).value("value" + i).build());
+ }
+
+ S3Exception exception = assertThrows(S3Exception.class, () ->
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build())));
+ assertEquals(400, exception.statusCode());
+ }
+
+ @Test
+ public void testPutObjectTaggingReplacesExistingTags() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+ s3Client.putObject(b -> b.bucket(bucketName).key(keyName),
+ RequestBody.fromString("content"));
+
+ List<Tag> initialTags = Arrays.asList(
+ Tag.builder().key("tag1").value("value1").build(),
+ Tag.builder().key("tag2").value("value2").build()
+ );
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(initialTags).build()));
+
+ List<Tag> replacementTags = Arrays.asList(
+ Tag.builder().key("tag3").value("value3").build()
+ );
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(replacementTags).build()));
+
+ GetObjectTaggingResponse response = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertEquals(1, response.tagSet().size());
+ Map<String, String> tagMap = response.tagSet().stream()
+ .collect(Collectors.toMap(Tag::key, Tag::value));
+ assertEquals("value3", tagMap.get("tag3"));
+ assertFalse(tagMap.containsKey("tag1"));
+ assertFalse(tagMap.containsKey("tag2"));
+ }
+
+ private static String repeatChar(char c, int count) {
+ StringBuilder sb = new StringBuilder(count);
+ for (int i = 0; i < count; i++) {
+ sb.append(c);
+ }
+ return sb.toString();
+ }
+
+ private static Stream<Arguments> invalidTagConstraintsProvider() {
+ return Stream.of(
+ Arguments.of(
+ Arrays.asList(Tag.builder().key(repeatChar('a', 129)).value("value").build()),
+ 400
+ ),
+ Arguments.of(
+ Arrays.asList(Tag.builder().key("valid-key").value(repeatChar('b', 257)).build()),
+ 400
+ ),
+ Arguments.of(
+ Arrays.asList(Tag.builder().key("t$ag@#invalid").value("value").build()),
+ 400
+ ),
+ Arguments.of(
+ Arrays.asList(Tag.builder().key("aws:test").value("value").build()),
+ 400
+ )
+ );
+ }
+
+ @ParameterizedTest
+ @MethodSource("invalidTagConstraintsProvider")
+ public void testPutObjectTaggingInvalidConstraints(List<Tag> invalidTags, int expectedStatusCode) {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+ s3Client.putObject(b -> b.bucket(bucketName).key(keyName),
+ RequestBody.fromString("content"));
+
+ S3Exception exception = assertThrows(S3Exception.class, () ->
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(invalidTags).build())));
+ assertEquals(expectedStatusCode, exception.statusCode());
+ }
+
+ @Test
+ public void testPutAndGetObjectTaggingOnNonExistentObject() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("env").value("test").build()
+ );
+
+ NoSuchKeyException exception = assertThrows(NoSuchKeyException.class, () ->
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build())));
+ assertEquals(404, exception.statusCode());
+
+ exception = assertThrows(NoSuchKeyException.class, () ->
+ s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)));
+ assertEquals(404, exception.statusCode());
+ }
+
+ @Test
+ public void testDeleteObjectTaggingOnNonExistentObject() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ NoSuchKeyException exception = assertThrows(NoSuchKeyException.class, () ->
+ s3Client.deleteObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)));
+ assertEquals(404, exception.statusCode());
Review Comment:
Same as https://github.com/apache/ozone/pull/9457/changes#r2617768342
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
Re: [PR] HDDS-13081. Add S3 Object tagging tests [ozone]
Posted by "echonesis (via GitHub)" <gi...@apache.org>.
echonesis commented on code in PR #9457:
URL: https://github.com/apache/ozone/pull/9457#discussion_r2652066456
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java:
##########
@@ -370,6 +377,215 @@ public void testCopyObject() {
assertEquals("\"37b51d194a7513e45b56f6524f2d51f2\"", copyObjectResponse.copyObjectResult().eTag());
}
+ @Test
+ public void testPutAndGetObjectTagging() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ final String content = "test content";
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ s3Client.putObject(b -> b
+ .bucket(bucketName)
+ .key(keyName),
+ RequestBody.fromString(content));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("env").value("test").build(),
+ Tag.builder().key("project").value("ozone").build()
+ );
+
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build()));
+
+ GetObjectTaggingResponse getResponse = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+
+ assertEquals(tags.size(), getResponse.tagSet().size());
+ Map<String, String> tagMap = getResponse.tagSet().stream()
+ .collect(Collectors.toMap(Tag::key, Tag::value));
+ assertEquals("test", tagMap.get("env"));
+ assertEquals("ozone", tagMap.get("project"));
+ }
+
+ @Test
+ public void testDeleteObjectTagging() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ final String content = "test content";
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ s3Client.putObject(b -> b
+ .bucket(bucketName)
+ .key(keyName),
+ RequestBody.fromString(content));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("temp").value("data").build()
+ );
+
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build()));
+
+ GetObjectTaggingResponse beforeDelete = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertEquals(1, beforeDelete.tagSet().size());
+
+ s3Client.deleteObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+
+ GetObjectTaggingResponse afterDelete = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertTrue(afterDelete.tagSet().isEmpty());
+ }
+
+ @Test
+ public void testPutObjectTaggingExceedsLimit() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+ s3Client.putObject(b -> b.bucket(bucketName).key(keyName),
+ RequestBody.fromString("content"));
+
+ List<Tag> tags = new ArrayList<>();
+ for (int i = 1; i <= 11; i++) {
Review Comment:
Could you please explain what `11` is?
We could use `TAG_NUM_LIMIT + 1` to make it clear.
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java:
##########
@@ -370,6 +377,215 @@ public void testCopyObject() {
assertEquals("\"37b51d194a7513e45b56f6524f2d51f2\"", copyObjectResponse.copyObjectResult().eTag());
}
+ @Test
+ public void testPutAndGetObjectTagging() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ final String content = "test content";
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ s3Client.putObject(b -> b
+ .bucket(bucketName)
+ .key(keyName),
+ RequestBody.fromString(content));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("env").value("test").build(),
+ Tag.builder().key("project").value("ozone").build()
+ );
+
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build()));
+
+ GetObjectTaggingResponse getResponse = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+
+ assertEquals(tags.size(), getResponse.tagSet().size());
+ Map<String, String> tagMap = getResponse.tagSet().stream()
+ .collect(Collectors.toMap(Tag::key, Tag::value));
+ assertEquals("test", tagMap.get("env"));
+ assertEquals("ozone", tagMap.get("project"));
+ }
+
+ @Test
+ public void testDeleteObjectTagging() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ final String content = "test content";
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ s3Client.putObject(b -> b
+ .bucket(bucketName)
+ .key(keyName),
+ RequestBody.fromString(content));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("temp").value("data").build()
+ );
+
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build()));
+
+ GetObjectTaggingResponse beforeDelete = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertEquals(1, beforeDelete.tagSet().size());
+
+ s3Client.deleteObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+
+ GetObjectTaggingResponse afterDelete = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertTrue(afterDelete.tagSet().isEmpty());
+ }
+
+ @Test
+ public void testPutObjectTaggingExceedsLimit() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+ s3Client.putObject(b -> b.bucket(bucketName).key(keyName),
+ RequestBody.fromString("content"));
+
+ List<Tag> tags = new ArrayList<>();
+ for (int i = 1; i <= 11; i++) {
+ tags.add(Tag.builder().key("key" + i).value("value" + i).build());
+ }
+
+ S3Exception exception = assertThrows(S3Exception.class, () ->
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build())));
+ assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, exception.statusCode());
+ }
+
+ @Test
+ public void testPutObjectTaggingReplacesExistingTags() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+ s3Client.putObject(b -> b.bucket(bucketName).key(keyName),
+ RequestBody.fromString("content"));
+
+ List<Tag> initialTags = Arrays.asList(
+ Tag.builder().key("tag1").value("value1").build(),
+ Tag.builder().key("tag2").value("value2").build()
+ );
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(initialTags).build()));
+
+ List<Tag> replacementTags = Arrays.asList(
+ Tag.builder().key("tag3").value("value3").build()
+ );
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(replacementTags).build()));
+
+ GetObjectTaggingResponse response = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertEquals(1, response.tagSet().size());
+ Map<String, String> tagMap = response.tagSet().stream()
+ .collect(Collectors.toMap(Tag::key, Tag::value));
+ assertEquals("value3", tagMap.get("tag3"));
+ assertFalse(tagMap.containsKey("tag1"));
+ assertFalse(tagMap.containsKey("tag2"));
+ }
+
+ private static String repeatChar(char c, int count) {
+ StringBuilder sb = new StringBuilder(count);
+ for (int i = 0; i < count; i++) {
+ sb.append(c);
+ }
+ return sb.toString();
+ }
+
+ private static Stream<Arguments> invalidTagConstraintsProvider() {
+ return Stream.of(
+ Arguments.of(
+ Arrays.asList(Tag.builder().key(repeatChar('a', 129)).value("value").build()),
Review Comment:
We could use `TAG_KEY_LENGTH_LIMIT + 1` instead of `129`.
##########
hadoop-ozone/integration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java:
##########
@@ -370,6 +377,215 @@ public void testCopyObject() {
assertEquals("\"37b51d194a7513e45b56f6524f2d51f2\"", copyObjectResponse.copyObjectResult().eTag());
}
+ @Test
+ public void testPutAndGetObjectTagging() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ final String content = "test content";
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ s3Client.putObject(b -> b
+ .bucket(bucketName)
+ .key(keyName),
+ RequestBody.fromString(content));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("env").value("test").build(),
+ Tag.builder().key("project").value("ozone").build()
+ );
+
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build()));
+
+ GetObjectTaggingResponse getResponse = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+
+ assertEquals(tags.size(), getResponse.tagSet().size());
+ Map<String, String> tagMap = getResponse.tagSet().stream()
+ .collect(Collectors.toMap(Tag::key, Tag::value));
+ assertEquals("test", tagMap.get("env"));
+ assertEquals("ozone", tagMap.get("project"));
+ }
+
+ @Test
+ public void testDeleteObjectTagging() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ final String content = "test content";
+ s3Client.createBucket(b -> b.bucket(bucketName));
+
+ s3Client.putObject(b -> b
+ .bucket(bucketName)
+ .key(keyName),
+ RequestBody.fromString(content));
+
+ List<Tag> tags = Arrays.asList(
+ Tag.builder().key("temp").value("data").build()
+ );
+
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build()));
+
+ GetObjectTaggingResponse beforeDelete = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertEquals(1, beforeDelete.tagSet().size());
+
+ s3Client.deleteObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+
+ GetObjectTaggingResponse afterDelete = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertTrue(afterDelete.tagSet().isEmpty());
+ }
+
+ @Test
+ public void testPutObjectTaggingExceedsLimit() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+ s3Client.putObject(b -> b.bucket(bucketName).key(keyName),
+ RequestBody.fromString("content"));
+
+ List<Tag> tags = new ArrayList<>();
+ for (int i = 1; i <= 11; i++) {
+ tags.add(Tag.builder().key("key" + i).value("value" + i).build());
+ }
+
+ S3Exception exception = assertThrows(S3Exception.class, () ->
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(tags).build())));
+ assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, exception.statusCode());
+ }
+
+ @Test
+ public void testPutObjectTaggingReplacesExistingTags() {
+ final String bucketName = getBucketName();
+ final String keyName = getKeyName();
+ s3Client.createBucket(b -> b.bucket(bucketName));
+ s3Client.putObject(b -> b.bucket(bucketName).key(keyName),
+ RequestBody.fromString("content"));
+
+ List<Tag> initialTags = Arrays.asList(
+ Tag.builder().key("tag1").value("value1").build(),
+ Tag.builder().key("tag2").value("value2").build()
+ );
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(initialTags).build()));
+
+ List<Tag> replacementTags = Arrays.asList(
+ Tag.builder().key("tag3").value("value3").build()
+ );
+ s3Client.putObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName)
+ .tagging(Tagging.builder().tagSet(replacementTags).build()));
+
+ GetObjectTaggingResponse response = s3Client.getObjectTagging(b -> b
+ .bucket(bucketName)
+ .key(keyName));
+ assertEquals(1, response.tagSet().size());
+ Map<String, String> tagMap = response.tagSet().stream()
+ .collect(Collectors.toMap(Tag::key, Tag::value));
+ assertEquals("value3", tagMap.get("tag3"));
+ assertFalse(tagMap.containsKey("tag1"));
+ assertFalse(tagMap.containsKey("tag2"));
+ }
+
+ private static String repeatChar(char c, int count) {
+ StringBuilder sb = new StringBuilder(count);
+ for (int i = 0; i < count; i++) {
+ sb.append(c);
+ }
+ return sb.toString();
+ }
+
+ private static Stream<Arguments> invalidTagConstraintsProvider() {
+ return Stream.of(
+ Arguments.of(
+ Arrays.asList(Tag.builder().key(repeatChar('a', 129)).value("value").build()),
+ HTTP_BAD_REQUEST
+ ),
+ Arguments.of(
+ Arrays.asList(Tag.builder().key("valid-key").value(repeatChar('b', 257)).build()),
Review Comment:
We could use `TAG_VALUE_LENGTH_LIMIT + 1` instead of `257`.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org