-
Notifications
You must be signed in to change notification settings - Fork 647
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
Update logging to print json as per mint log format #812
Conversation
functional_tests.go
Outdated
if err = c.MakeBucket(bucketName, "eu-central-1"); err == nil { | ||
logger().Fatal("Error: make bucket should should fail for", bucketName) | ||
if err = c.MakeBucket(bucketName, region); err == nil { | ||
failureLog(function, args, startTime, "", "Same bucket created twice", err).Fatal() |
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.
"Same bucket created twice"
message sounds like as if the bucket is successfully created twice.
I think the message should simply say "Bucket already exists!"
@@ -283,57 +367,70 @@ func testPutObjectReadAt() { | |||
|
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.
args["reader"]
needs to be populated with reader
value, since reader
is one of the parameters for PutObject
function.
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.
done
functional_tests.go
Outdated
@@ -283,57 +367,70 @@ func testPutObjectReadAt() { | |||
|
|||
// Save the data | |||
objectName := randString(60, rand.NewSource(time.Now().UnixNano()), "") | |||
args["objectName"] = objectName | |||
|
|||
// Object content type | |||
objectContentType := "binary/octet-stream" | |||
|
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.
args["objectContentType"]
needs to be populated with objectContentType
value, since objectContentType
is one of the parameters for PutObject
function.
functional_tests.go
Outdated
} | ||
if st.Size != int64(sixtyFiveMiB) { | ||
logger().Fatalf("Error: number of bytes in stat does not match, want %v, got %v\n", | ||
sixtyFiveMiB, st.Size) | ||
failureLog(function, args, startTime, "", "Number of bytes returned by PutObject does not match, want "+string(sixtyFiveMiB)+" got "+string(st.Size), err).Fatal() |
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.
"Number of bytes returned by PutObject does not match, want ...
=> "Number of bytes returned by PutObject does not match GetObject. Expected ...
functional_tests.go
Outdated
} | ||
if st.ContentType != customContentType { | ||
logger().Fatalf("Error: Expected and found content types do not match, want %v, got %v\n", | ||
customContentType, st.ContentType) | ||
failureLog(function, args, startTime, "", "ContentType does not match, want "+customContentType+" got "+st.ContentType, err).Fatal() |
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.
... match, want ...
=> ... match. Expected ...
} | ||
if err := r.Close(); err == nil { | ||
logger().Fatal("Error: object is already closed, should return error") | ||
failureLog(function, args, startTime, "", "Object already closed, should respond with error", err).Fatal() |
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.
err
here is nil
. So, there is no point of printing it in the failure log.
failureLog(function, args, startTime, "", "Object already closed, should respond with error", err).Fatal()
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.
This comment has not been an answered yet.
_, err = c.PutObject(bucketName, objectName, reader, "application/octet-stream") | ||
if err == nil { | ||
logger().Fatal("Error: PutObject should fail.") | ||
failureLog(function, args, startTime, "", "PutObject should fail", err).Fatal() |
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.
err
is nil. No point in logging it in.
failureLog(function, args, startTime, "", "PutObject should fail"~~, err~~).Fatal()
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.
This comment has not been answered yet.
functional_tests.go
Outdated
} | ||
if !strings.Contains(err.Error(), "proactively closed to be verified later") { | ||
logger().Fatal("Error:", err) | ||
failureLog(function, args, startTime, "", "Error string not found in PutObject output", err).Fatal() |
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.
No need to say Error
. It is fatal log and it is obvious that there is a problem:
failureLog(function, args, startTime, "", "Error sString not found in PutObject output", err).Fatal()
functional_tests.go
Outdated
logger().Info() | ||
// initialize logging params | ||
startTime := time.Now() | ||
function := "PutObject(bucketName, objectName, reader, contentType)" |
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.
We test ListPartiallyUploaded
functionality here. So, the function
should be set to ListIncompleteUploads(bucketName, objectName, isRecursive, doneCh)
functional_tests.go
Outdated
} | ||
if st.Size != int64(bufSize) { | ||
logger().Fatalf("Error: number of bytes in stat does not match, want %v, got %v\n", | ||
bufSize, st.Size) | ||
failureLog(function, args, startTime, "", "Number of bytes read does not match, want "+string(int64(bufSize))+" got "+string(st.Size), err).Fatal() |
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.
... match, want ...
=> ... match. Expected ...
functional_tests.go
Outdated
} | ||
|
||
st, err := r.Stat() | ||
if err != nil { | ||
logger().Fatal("Error:", err, bucketName, objectName) | ||
failureLog(function, args, startTime, "", "GetObject failed", err).Fatal() |
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.
"GetObject failed"
=> "Stat failed"
functional_tests.go
Outdated
} | ||
if st.Size != int64(bufSize) { | ||
logger().Fatalf("Error: number of bytes in stat does not match, want %v, got %v\n", | ||
bufSize, st.Size) | ||
failureLog(function, args, startTime, "", "Number of bytes in stat does not match, want "+string(int64(bufSize))+", got "+string(st.Size), err).Fatal() |
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.
... match, want ...
=> ... match. Expected ...
functional_tests.go
Outdated
} | ||
if m != len(buf2) { | ||
logger().Fatalf("Error: ReadAt read shorter bytes before reaching EOF, want %v, got %v\n", m, len(buf2)) | ||
failureLog(function, args, startTime, "", "ReadAt read shorter bytes before reaching EOF, want "+string(len(buf2))+", got "+string(m), err).Fatal() |
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.
... match, want ...
=> ... match. Expected ...
functional_tests.go
Outdated
} | ||
if m != len(buf3) { | ||
logger().Fatalf("Error: ReadAt read shorter bytes before reaching EOF, want %v, got %v\n", m, len(buf3)) | ||
failureLog(function, args, startTime, "", "ReadAt read shorter bytes before reaching EOF, want "+string(len(buf3))+", got "+string(m), err).Fatal() |
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.
... match, want ...
=> ... match. Expected ...
functional_tests.go
Outdated
} | ||
if m != len(buf4) { | ||
logger().Fatalf("Error: ReadAt read shorter bytes before reaching EOF, want %v, got %v\n", m, len(buf4)) | ||
failureLog(function, args, startTime, "", "ReadAt read shorter bytes before reaching EOF, want "+string(len(buf4))+", got "+string(m), err).Fatal() |
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.
... match, want ...
=> ... match. Expected ...
functional_tests.go
Outdated
} | ||
} | ||
if m != len(buf5) { | ||
logger().Fatalf("Error: ReadAt read shorter bytes before reaching EOF, want %v, got %v\n", m, len(buf5)) | ||
failureLog(function, args, startTime, "", "ReadAt read shorter bytes before reaching EOF, want "+string(len(buf5))+", got "+string(m), err).Fatal() |
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.
... match, want ...
=> ... match. Expected ...
functional_tests.go
Outdated
} | ||
|
||
policy := minio.NewPostPolicy() | ||
|
||
if err := policy.SetBucket(""); err == nil { | ||
logger().Fatalf("Error: %s", err) | ||
failureLog(function, args, startTime, "", "SetBucket failed", err).Fatal() |
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.
The error message is wrong. SetBucket
is supposed to fail, but it did not return with an error message. So, this is a negative testing and "SetBucket failed"
message here is misleading. The failureLog is supposed to be something like:
failureLog(function, args, startTime, "", "SetBucket did not fail for invalid bucket name").Fatal()
The same comment is also valid for the following line numbers:
1714, 1717, 1720, 1723, 1726, 1832, 1836, 1840, 1844, 1849, 1907, 2687, 2944, 3723, 3727, 3731, 3735, and 3797
functional_tests.go
Outdated
} | ||
if err = c.MakeBucket(bucketName, "eu-west-1"); err == nil { | ||
logger().Fatal("Error: make bucket should should fail for", bucketName) | ||
failureLog(function, args, startTime, "", "Make bucket should should fail", err).Fatal() |
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.
Typo:
should should
=> should
But it is better to modify the error message since this is negative testing, probably like:
failureLog(function, args, startTime, "", "Bucket already exists").Fatal()
} | ||
if err := r.Close(); err == nil { | ||
logger().Fatal("Error: object is already closed, should return error") | ||
failureLog(function, args, startTime, "", "Object is already closed, should return error", err).Fatal() |
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.
No point of logging nill error message, err:
failureLog(function, args, startTime, "", "Object is already closed, should return error", err).Fatal()
_, err = c.PutObject(bucketName, objectName, reader, "application/octet-stream") | ||
if err == nil { | ||
logger().Fatal("Error: PutObject should fail.") | ||
failureLog(function, args, startTime, "", "PutObject should fail", err).Fatal() |
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.
No point of logging nill error message, err:
failureLog(function, args, startTime, "", "PutObject should fail", err).Fatal()
} | ||
_, err = r.Seek(offset, 2) | ||
if err == nil { | ||
logger().Fatal("Error: seek on positive offset for whence '2' should error out") | ||
failureLog(function, args, startTime, "", "Seek on positive offset for whence '2' should error out", err).Fatal() |
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.
No point of logging nill error message, err:
failureLog(function, args, startTime, "", "Seek on positive offset for whence '2' should error out", err).Fatal()
} | ||
|
||
if err := c.ComposeObject(dst, srcSlice); err == nil { | ||
logger().Fatal("Error was expected.") | ||
failureLog(function, args, startTime, "", "Expected error in ComposeObject", err).Fatal() |
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.
No point of logging nill error message, err:
failureLog(function, args, startTime, "", "Expected error in ComposeObject", err).Fatal()
} | ||
// 3. ComposeObject call should fail. | ||
if err := c.ComposeObject(dst, []minio.SourceInfo{badSrc}); err == nil { | ||
logger().Fatal("Error was expected.") | ||
failureLog(function, args, startTime, "", "ComposeObject expected to fail", err).Fatal() |
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.
No point of logging nill error message, err:
failureLog(function, args, startTime, "", "ComposeObject expected to fail", err).Fatal()
} | ||
err = c.RemoveBucket(bucketName) | ||
if err == nil { | ||
logger().Fatal("Error:") | ||
failureLog(function, args, startTime, "", "RemoveBucket should fail as bucket does not exist", err).Fatal() |
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.
No point of logging nill error message, err:
failureLog(function, args, startTime, "", "RemoveBucket should fail as bucket does not exist", err).Fatal()
} | ||
if err := r.Close(); err == nil { | ||
logger().Fatal("Error: object is already closed, should return error") | ||
failureLog(function, args, startTime, "", "Already closed object. No error returned", err).Fatal() |
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.
err
is nil. No point in logging it in.
failureLog(function, args, startTime, "", "Supposed to error out for the already closed object"~~, err~~).Fatal()
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.
This comment has not been answered yet.
_, err = c.PutObject(bucketName, objectName, reader, "application/octet-stream") | ||
if err == nil { | ||
logger().Fatal("Error: PutObject should fail.") | ||
failureLog(function, args, startTime, "", "PutObject should fail", err).Fatal() |
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.
err
is nil. No point in logging it in.
failureLog(function, args, startTime, "", "PutObject was supposed to fail"~~, err~~).Fatal()
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.
This comment has not been answered yet.
@ebozduman updated the PR with correct error messages for negative test cases. For cases related to your comment
I have updated the logging function to not log |
} | ||
if err := r.Close(); err == nil { | ||
logger().Fatal("Error: object is already closed, should return error") | ||
failureLog(function, args, startTime, "", "Object already closed, should respond with error", err).Fatal() |
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.
This comment has not been an answered yet.
_, err = c.PutObject(bucketName, objectName, reader, "application/octet-stream") | ||
if err == nil { | ||
logger().Fatal("Error: PutObject should fail.") | ||
failureLog(function, args, startTime, "", "PutObject should fail", err).Fatal() |
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.
This comment has not been answered yet.
} | ||
if err := r.Close(); err == nil { | ||
logger().Fatal("Error: object is already closed, should return error") | ||
failureLog(function, args, startTime, "", "Already closed object. No error returned", err).Fatal() |
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.
This comment has not been answered yet.
_, err = c.PutObject(bucketName, objectName, reader, "application/octet-stream") | ||
if err == nil { | ||
logger().Fatal("Error: PutObject should fail.") | ||
failureLog(function, args, startTime, "", "PutObject should fail", err).Fatal() |
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.
This comment has not been answered yet.
} | ||
|
||
policy := minio.NewPostPolicy() | ||
|
||
if err := policy.SetBucket(""); err == nil { | ||
logger().Fatalf("Error: %s", err) | ||
failureLog(function, args, startTime, "", "SetBucket did not fail for invalid conditions", err).Fatal() |
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.
How about these negative tests between lines 1711~1723?
The same err == nil
comment also applies here.
See #779