-
Notifications
You must be signed in to change notification settings - Fork 660
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
fix: Implement random reader for generating data. #780
Conversation
functional_tests.go
Outdated
currentReadBytes int | ||
} | ||
|
||
func (r *randomReader) Read(p []byte) (n int, err error) { |
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.
Can you add some comments in this function ? @harshavardhana, it is little complicated to read
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.
Sure.. will do.
functional_tests.go
Outdated
if err != nil { | ||
logger().Fatal("Error:", err, bucketName, objectName) | ||
} | ||
|
||
if n != int64(len(buf)) { | ||
logger().Fatalf("Error: number of bytes does not match, want %v, got %v\n", len(buf), n) | ||
if n != int64(MinPartSize) { |
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.
If we are not using a random data source, then we get our data from 'datafile-65-MB' which means 65MB and not MinPartSize (64MB)
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.
Yes you are right .. looks like it was an existing problem too @vadmeste
364f9b1
to
1a14df6
Compare
functional_tests.go
Outdated
return &randomReader{ | ||
TotalBytes: int64(size), | ||
RandomSeedChar: "a", | ||
} |
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 could remove code for counting bytes read by composing a simple random reader with io.LimitReader
.
E.g,
return io.LimitReader{R: randomReader{seed: "a"}, N: size}
where
type randomReader struct {
seed string
}
func (r *randomReader) Read (b []byte) (int, error) {
return copy(b, bytes.Repeat(r.seed, len(b))), nil
}
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
18b23a6
to
68ac3f7
Compare
functional_tests.go
Outdated
// Set base object name | ||
objectName := bucketName + "FPutObject" | ||
objectContentType := "testapplication/octet-stream" | ||
|
||
// Perform standard FPutObject with contentType provided (Expecting application/octet-stream) | ||
n, err := c.FPutObject(bucketName, objectName+"-standard", fileName, objectContentType) | ||
ny, err := c.FPutObject(bucketName, objectName+"-standard", fileName, objectContentType) |
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.
looks like a typo. s/ny/n
68ac3f7
to
b7bf994
Compare
@harshavardhana, it looks like functional tests are not passing
Minio server log:
|
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.
LGTM
@krisis any reviews? |
Fixes #742