Skip to content
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

add mint test for metadata size restrictions #816

Merged
merged 1 commit into from Sep 24, 2017

Conversation

aead
Copy link
Member

@aead aead commented Sep 20, 2017

This change adds a test for the metadata size restriction of AWS.
AWS allows user-defined metadata of 2KB and a total HTTP header
size of 8KB.

Fixes minio/mint#119

@poornas
Copy link
Contributor

poornas commented Sep 20, 2017

@aead, you will need to use refactored PutObject call because #811 was merged.

@aead aead force-pushed the restirct_metadata_mint_tests branch from 4ad5494 to f4aa544 Compare September 20, 2017 17:12
@aead
Copy link
Member Author

aead commented Sep 20, 2017

Thanks @poornas

@@ -262,6 +262,59 @@ func testMakeBucketError() {
successLogger(function, args, startTime).Info()
}

func testMetadataSizeLimit() {
startTime := time.Now()
function := "PutObjectWithMetadata(bucketName, objectName, reader, metadata)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the signature of the function needs to change.

args["metadata"] = fmt.Sprint(metadata)
_, err = c.PutObject(bucketName, objectName, bytes.NewReader(nil), 0, &minio.PutObjectOptions{UserMetadata: metadata})
if err == nil {
failureLog(function, args, startTime, "", "Created object with too much user-defined metadata successfully", nil).Fatal()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the message could be worded as
Created object with user-defined metadata exceeding metadata size limits.

args["metadata"] = fmt.Sprint(metadata)
_, err = c.PutObject(bucketName, objectName, bytes.NewReader(nil), 0, &minio.PutObjectOptions{UserMetadata: metadata})
if err == nil {
failureLog(function, args, startTime, "", "Created object with too much metadata successfully", nil).Fatal()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar suggestion for "Created object with too much metadata successfully" as previous comment.

@@ -262,6 +262,59 @@ func testMakeBucketError() {
successLogger(function, args, startTime).Info()
}

func testMetadataSizeLimit() {
startTime := time.Now()
function := "PutObjectWithMetadata(bucketName, objectName, reader, metadata)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excerpt from the documentation:

API methods PutObjectWithSize, PutObjectWithMetadata, PutObjectStreaming, and
PutObjectWithProgress available in minio-go SDK release v3.0.2 are replaced by the
new PutObject call variant that accepts a pointer to PutObjectOptions struct.

So:
function := "PutObjectWithMetadata(bucketName, objectName, reader, metadata)"
=>
function := "PutObject(bucketName, objectName, reader, objectSize, opts)"


metadata := make(map[string]string)
metadata["X-Amz-Meta-Mint-Test"] = string(bytes.Repeat([]byte("m"), 1+UserMetadataLimit-len("X-Amz-Meta-Mint-Test")))
args["metadata"] = fmt.Sprint(metadata)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no "metadata" argument for PutObject api. So, it needs to be replaced with args["opts"]. However, since "opts" argument is a pointer, we have to show somehow the real metadata value we are passing into the test for meaningful logging purposes, instead of having a pointer value/memory address logged as part of the PutObject api arguments.
You may need to discuss how to handle this case with Nitish, Bala and the team.
I guess the same comment is valid for any arguments which is a pointer or anything like "reader".

const UserMetadataLimit = 2 * 1024

metadata := make(map[string]string)
metadata["X-Amz-Meta-Mint-Test"] = string(bytes.Repeat([]byte("m"), 1+UserMetadataLimit-len("X-Amz-Meta-Mint-Test")))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment here would be good to explain that this is a negative test and hence a metadata will be created with 1 + <allowed_metadata_limit_bytes> - len("X-Amz-Meta-Mint-Test").

args["metadata"] = fmt.Sprint(metadata)
_, err = c.PutObject(bucketName, objectName, bytes.NewReader(nil), 0, &minio.PutObjectOptions{UserMetadata: metadata})
if err == nil {
failureLog(function, args, startTime, "", "Created object with too much user-defined metadata successfully", nil).Fatal()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

too much = > too many if the message wording is going to have some kind of a quantification.

_, err = c.PutObject(bucketName, objectName, bytes.NewReader(nil), 0, &minio.PutObjectOptions{UserMetadata: metadata})
if err == nil {
failureLog(function, args, startTime, "", "Created object with headers exceeding header size limits", nil).Fatal()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you pls call successLogger() as well when the test passes? Otherwise looks good.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, thanks.

@aead aead force-pushed the restirct_metadata_mint_tests branch 2 times, most recently from 5538615 to 4ae64e9 Compare September 21, 2017 18:05
This change adds a test for the metadata size restriction of AWS.
AWS allows user-defined metadata of 2KB and a total HTTP header
size of 8KB.

Fixes minio/mint#119
@aead aead force-pushed the restirct_metadata_mint_tests branch from cc00d4a to e44c57f Compare September 22, 2017 21:27
@aead
Copy link
Member Author

aead commented Sep 22, 2017

Sorry, Github's 'update branch' does a merge commit not a rebase -.-

@deekoder deekoder merged commit 463b3f6 into minio:master Sep 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants