-
Notifications
You must be signed in to change notification settings - Fork 587
HDDS-12870. Fix listObjects corner cases #8307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
6f61f55
365c67b
7bd5677
19f7ba5
f283cc0
5035f36
7611798
228bacd
a4e074d
beffb26
c8d7db3
7e2d5d4
ab8092b
edcb530
93f6cb8
ff1408f
aaf2783
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,37 @@ | ||||||||||||||||||||||||||||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you should add this smoke test to
too
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure let me add in, thanks for remind. |
||||||||||||||||||||||||||||
| # contributor license agreements. See the NOTICE file distributed with | ||||||||||||||||||||||||||||
| # this work for additional information regarding copyright ownership. | ||||||||||||||||||||||||||||
| # The ASF licenses this file to You under the Apache License, Version 2.0 | ||||||||||||||||||||||||||||
| # (the "License"); you may not use this file except in compliance with | ||||||||||||||||||||||||||||
| # the License. You may obtain a copy of the License at | ||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||
| # Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||||||||||||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||||||||||||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||||||||||||||||
| # See the License for the specific language governing permissions and | ||||||||||||||||||||||||||||
| # limitations under the License. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| *** Settings *** | ||||||||||||||||||||||||||||
| Documentation S3 max-keys validation test for negative and zero values | ||||||||||||||||||||||||||||
| Library OperatingSystem | ||||||||||||||||||||||||||||
| Library String | ||||||||||||||||||||||||||||
| Resource ../commonlib.robot | ||||||||||||||||||||||||||||
| Resource commonawslib.robot | ||||||||||||||||||||||||||||
| Test Timeout 3 minutes | ||||||||||||||||||||||||||||
| Suite Setup Setup s3 tests | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| *** Variables *** | ||||||||||||||||||||||||||||
| ${ENDPOINT_URL} http://s3g:9878 | ||||||||||||||||||||||||||||
| ${BUCKET} generated | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| *** Test Cases *** | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| List objects with negative max-keys should fail | ||||||||||||||||||||||||||||
| ${result} = Execute AWSS3APICli and checkrc list-objects-v2 --bucket ${BUCKET} --max-keys -1 255 | ||||||||||||||||||||||||||||
| Should Contain ${result} InvalidArgument | ||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it send request to s3g, or just intercept by the awscli client similar to aws sdk?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s3g log path inside container: /var/log/hadoop/s3g-audit-${hostName}.log |
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| List objects with zero max-keys should fail | ||||||||||||||||||||||||||||
| ${result} = Execute AWSS3APICli and checkrc list-objects-v2 --bucket ${BUCKET} --max-keys 0 255 | ||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you make the server-side max configurable, you can set it low for this test and test server-side enforcement as well.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, just add two robot tests for testing max-keys is lower or higher than maxKeysLimit scenarios. |
||||||||||||||||||||||||||||
| Should Contain ${result} InvalidArgument | ||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,6 +142,8 @@ public Response get( | |
| return listMultipartUploads(bucketName, prefix, keyMarker, uploadIdMarker, maxUploads); | ||
| } | ||
|
|
||
| maxKeys = validateMaxKeys(maxKeys); | ||
|
|
||
| if (prefix == null) { | ||
| prefix = ""; | ||
| } | ||
|
|
@@ -292,6 +294,14 @@ public Response get( | |
| return Response.ok(response).build(); | ||
| } | ||
|
|
||
| private int validateMaxKeys(int maxKeys) throws OS3Exception { | ||
| if (maxKeys <= 0) { | ||
| throw newError(S3ErrorTable.INVALID_ARGUMENT, "maxKeys must be > 0"); | ||
| } | ||
|
|
||
| return Math.min(maxKeys, 1000); | ||
|
||
| } | ||
|
|
||
| @PUT | ||
| public Response put(@PathParam("bucket") String bucketName, | ||
| @QueryParam("acl") String aclMarker, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -521,6 +521,28 @@ public void testEncodingTypeException() throws IOException { | |
| assertEquals(S3ErrorTable.INVALID_ARGUMENT.getCode(), e.getCode()); | ||
| } | ||
|
|
||
| @Test | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should add another test case to check if the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@Jimmyweng006 Use setConfig of the builder to set the config with custom lower max key limit, then call
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the advice @peterxcli , I update the PR but local CI will take some time.
The new commit achieves above testing scenario with a lower max key limit, please help have a look later. Thank you. |
||
| public void testListObjectsWithInvalidMaxKeys() throws Exception { | ||
| OzoneClient client = createClientWithKeys("file1"); | ||
| BucketEndpoint bucketEndpoint = EndpointBuilder.newBucketEndpointBuilder() | ||
| .setClient(client) | ||
| .build(); | ||
|
|
||
| // maxKeys < 0 | ||
| OS3Exception e1 = assertThrows(OS3Exception.class, () -> | ||
| bucketEndpoint.get("bucket", null, null, null, -1, null, | ||
| null, null, null, null, null, null, 1000, null) | ||
| ); | ||
| assertEquals(S3ErrorTable.INVALID_ARGUMENT.getCode(), e1.getCode()); | ||
|
|
||
| // maxKeys == 0 | ||
| OS3Exception e2 = assertThrows(OS3Exception.class, () -> | ||
| bucketEndpoint.get("bucket", null, null, null, 0, null, | ||
| null, null, null, null, null, null, 1000, null) | ||
| ); | ||
| assertEquals(S3ErrorTable.INVALID_ARGUMENT.getCode(), e2.getCode()); | ||
| } | ||
|
|
||
| private void assertEncodingTypeObject( | ||
| String exceptName, String exceptEncodingType, EncodingTypeObject object) { | ||
| assertEquals(exceptName, object.getName()); | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this file should rename to
objectlist.robot,maxkeys_validation.robotis too specific.