fix `testListMultipartUpload` in aws-sdk-go (#11122)

Currently, the test doesn't complete nor abort the multipart upload
after tesing the list operation. It caused the `cleanup()` to fail since
the object can't not be deleted which causes the bucket deletion to
fail.

This PR adds a `CompleteMultipartUpload` call to commit the object so
the cleanup can successfully delete the object and bucket.
master
Yingrong Zhao 4 years ago committed by GitHub
parent 90158f1e33
commit cce5d7152a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      mint/run/core/aws-sdk-go/main.go

@ -921,15 +921,32 @@ func testListMultipartUploads(s3Client *s3.S3) {
return return
} }
completedParts := make([]*s3.CompletedPart, len(parts))
for _, part := range listParts.Parts { for _, part := range listParts.Parts {
if tag, ok := parts[part.PartNumber]; ok { if tag, ok := parts[part.PartNumber]; ok {
if tag != part.ETag { if tag != part.ETag {
failureLog(function, args, startTime, "", fmt.Sprintf("AWS SDK Go ListParts.Parts output mismatch want: %v got: %v", tag, part.ETag), err).Fatal() failureLog(function, args, startTime, "", fmt.Sprintf("AWS SDK Go ListParts.Parts output mismatch want: %v got: %v", tag, part.ETag), err).Fatal()
return return
} }
completedParts = append(completedParts, &s3.CompletedPart{
ETag: part.ETag,
PartNumber: part.PartNumber,
})
} }
} }
_, err = s3Client.CompleteMultipartUpload(&s3.CompleteMultipartUploadInput{
Bucket: aws.String(bucket),
Key: aws.String(object),
MultipartUpload: &s3.CompletedMultipartUpload{
Parts: completedParts},
UploadId: multipartUpload.UploadId,
})
if err != nil {
failureLog(function, args, startTime, "", fmt.Sprintf("AWS SDK Go CompleteMultipartUpload failed"), err).Fatal()
return
}
successLogger(function, args, startTime).Info() successLogger(function, args, startTime).Info()
} }

Loading…
Cancel
Save