Skip to content

Commit

Permalink
Enhanced multipart upload test by matching uploaded content (#1061)
Browse files Browse the repository at this point in the history
* enhanced multipart upload test to match uploaded
content

* used 'Equals' method instead of 'True' in
multipart upload test

* varied the size of randomly by a few bytes
to test out padding problems

* tested multipart upload by varying size by upto 20
bytes
  • Loading branch information
Sufiyan1997 authored Dec 20, 2020
1 parent cbb37fc commit 76d88de
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions nessie/multipart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

const (
multipartNumberOfParts = 5
multipartNumberOfParts = 20
multipartPartSize = 6 * 1024 * 1024
)

Expand All @@ -33,7 +33,14 @@ func TestMultipartUpload(t *testing.T) {
require.NoError(t, err, "failed to create multipart upload")
logger.Info("Created multipart upload request")

completedParts := uploadMultipartParts(t, logger, resp)
parts := make([][]byte, multipartNumberOfParts)
var partsConcat []byte
for i := 0; i < multipartNumberOfParts; i++ {
parts[i] = randstr.Bytes(multipartPartSize + i)
partsConcat = append(partsConcat, parts[i]...)
}

completedParts := uploadMultipartParts(t, logger, resp, parts)

completeResponse, err := uploadMultipartComplete(svc, resp, completedParts)
require.NoError(t, err, "failed to complete multipart upload")
Expand All @@ -47,9 +54,10 @@ func TestMultipartUpload(t *testing.T) {
WithRef(masterBranch).
WithPath(file), nil, &b)
require.NoError(t, err, "failed to get object")
require.Equal(t, b.Bytes(), partsConcat, "uploaded object did not match")
}

func uploadMultipartParts(t *testing.T, logger logging.Logger, resp *s3.CreateMultipartUploadOutput) []*s3.CompletedPart {
func uploadMultipartParts(t *testing.T, logger logging.Logger, resp *s3.CreateMultipartUploadOutput, parts [][]byte) []*s3.CompletedPart {
completedParts := make([]*s3.CompletedPart, multipartNumberOfParts)
errs := make([]error, multipartNumberOfParts)
var wg sync.WaitGroup
Expand All @@ -58,7 +66,7 @@ func uploadMultipartParts(t *testing.T, logger logging.Logger, resp *s3.CreateMu
go func(i int) {
defer wg.Done()
partNumber := i + 1
completedParts[i], errs[i] = uploadMultipartPart(logger, svc, resp, randstr.Bytes(multipartPartSize), partNumber)
completedParts[i], errs[i] = uploadMultipartPart(logger, svc, resp, parts[i], partNumber)
}(i)
}
wg.Wait()
Expand Down

0 comments on commit 76d88de

Please sign in to comment.