HDDS-13081. Add S3 Object tagging tests#9457
Conversation
Gargi-jais11
left a comment
There was a problem hiding this comment.
Thanks @0lai0 for the patch.
I have few more test case suggestions which could be added.
...gration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java
Outdated
Show resolved
Hide resolved
|
More Edge Cases which can be tested:
|
Tejaskriya
left a comment
There was a problem hiding this comment.
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. |
|
Thanks @Gargi-jais11 and @Tejaskriya review, I'll add error cases. |
ivandika3
left a comment
There was a problem hiding this comment.
Thanks for adding the tests. Overall LGTM. Could you also add similar tests to the AbstractS3SDKV1Tests as well?
Please also help to check this failure in your latest test run https://github.com/0lai0/ozone/actions/runs/20160679799/job/57874354964
(org.apache.hadoop.ozone.s3.awssdk.v2.AbstractS3SDKV2Tests$S3BucketOwnershipVerificationConditionsTests$LinkBucketTests)
|
@0lai0 Thanks for updating the patch. It LGTM.
Once this is done the patch will be good to go. |
...gration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java
Outdated
Show resolved
Hide resolved
...gration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java
Outdated
Show resolved
Hide resolved
...gration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java
Outdated
Show resolved
Hide resolved
...gration-test-s3/src/test/java/org/apache/hadoop/ozone/s3/awssdk/v2/AbstractS3SDKV2Tests.java
Outdated
Show resolved
Hide resolved
|
Thanks @ivandika3, @Gargi-jais11 and @echonesis for review.I'll push a fix right away. |
|
Thanks @0lai0 , left some comments. |
|
|
||
| @Nested | ||
| @TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
| class BucketOwnershipLinkBucketTests { |
There was a problem hiding this comment.
Maybe we could keep it consistent with the V2 class
There was a problem hiding this comment.
Yes we should keep the name consistent with the V2 class as LinkBucketTests
There was a problem hiding this comment.
Sure, I'll get on this.
| * | ||
| */ | ||
| @TestMethodOrder(MethodOrderer.MethodName.class) | ||
| public abstract class AbstractS3SDKV1Tests extends OzoneTestBase { |
There was a problem hiding this 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.
There was a problem hiding this 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
There was a problem hiding this 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.
There was a problem hiding this comment.
@0lai0 HDDS-14197 is merged, now you can keep extends OzoneTestBase here and don't need to implement custom getTestName().
There was a problem hiding this comment.
Thanks everyone for the discussion, and thanks @adoroszlai for the update on HDDS-14197. I'll keep OzoneTestBase and remove the custom getTestName() implementation.
Gargi-jais11
left a comment
There was a problem hiding this comment.
Left some comments below.
| .withExpectedBucketOwner("wrong-owner"); | ||
| AmazonServiceException wrongOwner = assertThrows(AmazonServiceException.class, | ||
| () -> s3Client.getBucketAcl(wrongRequest)); | ||
| assertEquals(403, wrongOwner.getStatusCode()); |
There was a problem hiding this comment.
Use HttpURLConnection.HTTP_FORBIDDEN
| .withExpectedBucketOwner("wrong-owner"); | ||
| AmazonServiceException wrongOwner = assertThrows(AmazonServiceException.class, | ||
| () -> s3Client.getBucketAcl(wrongRequest)); | ||
| assertEquals(403, wrongOwner.getStatusCode()); |
There was a problem hiding this comment.
use HttpURLConnection.HTTP_FORBIDDEN
| 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 |
There was a problem hiding this comment.
Use HTTP_BAD_REQUEST in this Parameterised test.
@Gargi-jais11 IMO the responsibility of resolving comments is in the reviewer since it signals that that the comments are already addressed to the reviewer's satisfaction. |
|
Thanks for all the feedback. I'll review and make changes based on the comments. |
|
Thanks @0lai0 for updating the patch. There are some test failures: https://github.com/0lai0/ozone/actions/runs/20396880835/job/58614335876#step:13:6020 |
|
Thanks @adoroszlai for review. I've pushed a commit to address test failures by AssertionFailedError. |
| RequestBody.fromString("content")); | ||
|
|
||
| List<Tag> tags = new ArrayList<>(); | ||
| for (int i = 1; i <= 11; i++) { |
There was a problem hiding this comment.
Could you please explain what 11 is?
We could use TAG_NUM_LIMIT + 1 to make it clear.
There was a problem hiding this comment.
My apologies, I'll replace hardcoded values with constants
| private static Stream<Arguments> invalidTagConstraintsProvider() { | ||
| return Stream.of( | ||
| Arguments.of( | ||
| Arrays.asList(Tag.builder().key(repeatChar('a', 129)).value("value").build()), |
There was a problem hiding this comment.
We could use TAG_KEY_LENGTH_LIMIT + 1 instead of 129.
| HTTP_BAD_REQUEST | ||
| ), | ||
| Arguments.of( | ||
| Arrays.asList(Tag.builder().key("valid-key").value(repeatChar('b', 257)).build()), |
There was a problem hiding this comment.
We could use TAG_VALUE_LENGTH_LIMIT + 1 instead of 257.
Gargi-jais11
left a comment
There was a problem hiding this comment.
Thanks @0lai0 for updating the patch. LGTM!
|
@0lai0 Thanks for the update. Overall LGTM. Please kindly check the failing test https://github.com/0lai0/ozone/actions/runs/20588433897/job/59131635706 |
chungen0126
left a comment
There was a problem hiding this comment.
Thanks @0lai0 for the patch.
| 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 { |
There was a problem hiding this comment.
Could you please explain why we need this here?
There was a problem hiding this 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 .
There was a problem hiding this 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.
There was a problem hiding this comment.
Got it. I've removed this part since the PR focuses on integration tests. Thanks for pointing that out.
|
Thanks @chungen0126 for review. |
|
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. |
|
I notice some tests failed, I need to fix them. Thanks @jojochuang . |
https://github.com/0lai0/ozone/actions/runs/21510299989/job/61976509731#step:13:5994 |
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