vendor: update all dependencies to latest versions
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
||||
@upload
|
||||
Feature: the upload feature
|
||||
|
||||
Scenario: create the uploader
|
||||
When initialize uploader
|
||||
Then uploader is initialized
|
||||
|
||||
Scenario: upload large file
|
||||
When upload a large file
|
||||
Then the large file is uploaded
|
||||
+4
-1
@@ -42,10 +42,11 @@ func main() {
|
||||
ObjectFeatureContext(s)
|
||||
ObjectMultipartFeatureContext(s)
|
||||
ImageFeatureContext(s)
|
||||
UploadFeatureContext(s)
|
||||
}
|
||||
options := godog.Options{
|
||||
Format: "pretty",
|
||||
Paths: []string{"./features"},
|
||||
Paths: []string{"./features", "./local_features"},
|
||||
Tags: "",
|
||||
}
|
||||
status := godog.RunWithOptions("*", context, options)
|
||||
@@ -108,6 +109,8 @@ type testConfig struct {
|
||||
|
||||
RetryWaitTime int `json:"retry_wait_time" yaml:"retry_wait_time"`
|
||||
MaxRetries int `json:"max_retries" yaml:"max_retries"`
|
||||
|
||||
Concurrency int `json:"concurrency"`
|
||||
}
|
||||
|
||||
func loadTestConfig() {
|
||||
|
||||
+60
-52
@@ -67,9 +67,7 @@ func ObjectFeatureContext(s *godog.Suite) {
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
const concurrency = 16
|
||||
|
||||
var putObjectOutputs [concurrency]*qs.PutObjectOutput
|
||||
var putObjectOutputs []*qs.PutObjectOutput
|
||||
|
||||
func putObjectWithKey(objectKey string) error {
|
||||
_, err = exec.Command("dd", "if=/dev/zero", "of=/tmp/sdk_bin", "bs=1024", "count=1").Output()
|
||||
@@ -78,11 +76,12 @@ func putObjectWithKey(objectKey string) error {
|
||||
}
|
||||
defer os.Remove("/tmp/sdk_bin")
|
||||
|
||||
errChan := make(chan error, concurrency)
|
||||
errChan := make(chan error, tc.Concurrency)
|
||||
putObjectOutputs = make([]*qs.PutObjectOutput, tc.Concurrency)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(concurrency)
|
||||
for i := 0; i < concurrency; i++ {
|
||||
wg.Add(tc.Concurrency)
|
||||
for i := 0; i < tc.Concurrency; i++ {
|
||||
go func(index int, errChan chan<- error) {
|
||||
wg.Done()
|
||||
|
||||
@@ -126,7 +125,7 @@ func putObjectWithKey(objectKey string) error {
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
for i := 0; i < concurrency; i++ {
|
||||
for i := 0; i < tc.Concurrency; i++ {
|
||||
err = <-errChan
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -146,14 +145,15 @@ func putObjectStatusCodeIs(statusCode int) error {
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
var copyObjectOutputs [concurrency]*qs.PutObjectOutput
|
||||
var copyObjectOutputs []*qs.PutObjectOutput
|
||||
|
||||
func copyObjectWithKey(objectKey string) error {
|
||||
errChan := make(chan error, concurrency)
|
||||
errChan := make(chan error, tc.Concurrency)
|
||||
copyObjectOutputs = make([]*qs.PutObjectOutput, tc.Concurrency)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(concurrency)
|
||||
for i := 0; i < concurrency; i++ {
|
||||
wg.Add(tc.Concurrency)
|
||||
for i := 0; i < tc.Concurrency; i++ {
|
||||
go func(index int, errChan chan<- error) {
|
||||
wg.Done()
|
||||
|
||||
@@ -178,7 +178,7 @@ func copyObjectWithKey(objectKey string) error {
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
for i := 0; i < concurrency; i++ {
|
||||
for i := 0; i < tc.Concurrency; i++ {
|
||||
err = <-errChan
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -198,14 +198,15 @@ func copyObjectStatusCodeIs(statusCode int) error {
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
var moveObjectOutputs [concurrency]*qs.PutObjectOutput
|
||||
var moveObjectOutputs []*qs.PutObjectOutput
|
||||
|
||||
func moveObjectWithKey(objectKey string) error {
|
||||
errChan := make(chan error, concurrency)
|
||||
errChan := make(chan error, tc.Concurrency)
|
||||
moveObjectOutputs = make([]*qs.PutObjectOutput, tc.Concurrency)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(concurrency)
|
||||
for i := 0; i < concurrency; i++ {
|
||||
wg.Add(tc.Concurrency)
|
||||
for i := 0; i < tc.Concurrency; i++ {
|
||||
go func(index int, errChan chan<- error) {
|
||||
wg.Done()
|
||||
|
||||
@@ -230,7 +231,7 @@ func moveObjectWithKey(objectKey string) error {
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
for i := 0; i < concurrency; i++ {
|
||||
for i := 0; i < tc.Concurrency; i++ {
|
||||
err = <-errChan
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -251,14 +252,15 @@ func moveObjectStatusCodeIs(statusCode int) error {
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
var getObjectOutputs [concurrency]*qs.GetObjectOutput
|
||||
var getObjectOutputs []*qs.GetObjectOutput
|
||||
|
||||
func getObjectWithKey(objectKey string) error {
|
||||
errChan := make(chan error, concurrency)
|
||||
errChan := make(chan error, tc.Concurrency)
|
||||
getObjectOutputs = make([]*qs.GetObjectOutput, tc.Concurrency)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(concurrency)
|
||||
for i := 0; i < concurrency; i++ {
|
||||
wg.Add(tc.Concurrency)
|
||||
for i := 0; i < tc.Concurrency; i++ {
|
||||
go func(index int, errChan chan<- error) {
|
||||
wg.Done()
|
||||
|
||||
@@ -279,7 +281,7 @@ func getObjectWithKey(objectKey string) error {
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
for i := 0; i < concurrency; i++ {
|
||||
for i := 0; i < tc.Concurrency; i++ {
|
||||
err = <-errChan
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -313,14 +315,15 @@ func getObjectContentLengthIs(length int) error {
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
var getObjectWithContentTypeRequests [concurrency]*request.Request
|
||||
var getObjectWithContentTypeRequests []*request.Request
|
||||
|
||||
func getObjectWithContentType(objectKey, contentType string) error {
|
||||
errChan := make(chan error, concurrency)
|
||||
errChan := make(chan error, tc.Concurrency)
|
||||
getObjectWithContentTypeRequests = make([]*request.Request, tc.Concurrency)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(concurrency)
|
||||
for i := 0; i < concurrency; i++ {
|
||||
wg.Add(tc.Concurrency)
|
||||
for i := 0; i < tc.Concurrency; i++ {
|
||||
go func(index int, errChan chan<- error) {
|
||||
wg.Done()
|
||||
|
||||
@@ -354,7 +357,7 @@ func getObjectWithContentType(objectKey, contentType string) error {
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
for i := 0; i < concurrency; i++ {
|
||||
for i := 0; i < tc.Concurrency; i++ {
|
||||
err = <-errChan
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -375,14 +378,15 @@ func getObjectContentTypeIs(contentType string) error {
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
var getObjectWithQuerySignatureURLs [concurrency]string
|
||||
var getObjectWithQuerySignatureURLs []string
|
||||
|
||||
func getObjectWithQuerySignature(objectKey string) error {
|
||||
errChan := make(chan error, concurrency)
|
||||
errChan := make(chan error, tc.Concurrency)
|
||||
getObjectWithQuerySignatureURLs = make([]string, tc.Concurrency)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(concurrency)
|
||||
for i := 0; i < concurrency; i++ {
|
||||
wg.Add(tc.Concurrency)
|
||||
for i := 0; i < tc.Concurrency; i++ {
|
||||
go func(index int, errChan chan<- error) {
|
||||
wg.Done()
|
||||
|
||||
@@ -414,7 +418,7 @@ func getObjectWithQuerySignature(objectKey string) error {
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
for i := 0; i < concurrency; i++ {
|
||||
for i := 0; i < tc.Concurrency; i++ {
|
||||
err = <-errChan
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -443,14 +447,15 @@ func getObjectWithQuerySignatureContentLengthIs(length int) error {
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
var headObjectOutputs [concurrency]*qs.HeadObjectOutput
|
||||
var headObjectOutputs []*qs.HeadObjectOutput
|
||||
|
||||
func headObjectWithKey(objectKey string) error {
|
||||
errChan := make(chan error, concurrency)
|
||||
errChan := make(chan error, tc.Concurrency)
|
||||
headObjectOutputs = make([]*qs.HeadObjectOutput, tc.Concurrency)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(concurrency)
|
||||
for i := 0; i < concurrency; i++ {
|
||||
wg.Add(tc.Concurrency)
|
||||
for i := 0; i < tc.Concurrency; i++ {
|
||||
go func(index int, errChan chan<- error) {
|
||||
wg.Done()
|
||||
|
||||
@@ -471,7 +476,7 @@ func headObjectWithKey(objectKey string) error {
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
for i := 0; i < concurrency; i++ {
|
||||
for i := 0; i < tc.Concurrency; i++ {
|
||||
err = <-errChan
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -492,14 +497,15 @@ func headObjectStatusCodeIs(statusCode int) error {
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
var optionsObjectOutputs [concurrency]*qs.OptionsObjectOutput
|
||||
var optionsObjectOutputs []*qs.OptionsObjectOutput
|
||||
|
||||
func optionsObjectWithMethodAndOrigin(objectKey, method, origin string) error {
|
||||
errChan := make(chan error, concurrency)
|
||||
errChan := make(chan error, tc.Concurrency)
|
||||
optionsObjectOutputs = make([]*qs.OptionsObjectOutput, tc.Concurrency)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(concurrency)
|
||||
for i := 0; i < concurrency; i++ {
|
||||
wg.Add(tc.Concurrency)
|
||||
for i := 0; i < tc.Concurrency; i++ {
|
||||
go func(index int, errChan chan<- error) {
|
||||
wg.Done()
|
||||
|
||||
@@ -524,7 +530,7 @@ func optionsObjectWithMethodAndOrigin(objectKey, method, origin string) error {
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
for i := 0; i < concurrency; i++ {
|
||||
for i := 0; i < tc.Concurrency; i++ {
|
||||
err = <-errChan
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -545,15 +551,16 @@ func optionsObjectStatusCodeIs(statusCode int) error {
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
var deleteObjectOutputs [concurrency]*qs.DeleteObjectOutput
|
||||
var deleteTheMoveObjectOutputs [concurrency]*qs.DeleteObjectOutput
|
||||
var deleteObjectOutputs []*qs.DeleteObjectOutput
|
||||
var deleteTheMoveObjectOutputs []*qs.DeleteObjectOutput
|
||||
|
||||
func deleteObjectWithKey(objectKey string) error {
|
||||
errChan := make(chan error, concurrency)
|
||||
errChan := make(chan error, tc.Concurrency)
|
||||
deleteObjectOutputs = make([]*qs.DeleteObjectOutput, tc.Concurrency)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(concurrency)
|
||||
for i := 0; i < concurrency; i++ {
|
||||
wg.Add(tc.Concurrency)
|
||||
for i := 0; i < tc.Concurrency; i++ {
|
||||
go func(index int, errChan chan<- error) {
|
||||
wg.Done()
|
||||
|
||||
@@ -574,7 +581,7 @@ func deleteObjectWithKey(objectKey string) error {
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
for i := 0; i < concurrency; i++ {
|
||||
for i := 0; i < tc.Concurrency; i++ {
|
||||
err = <-errChan
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -594,11 +601,12 @@ func deleteObjectStatusCodeIs(statusCode int) error {
|
||||
}
|
||||
|
||||
func deleteTheMoveObjectWithKey(objectKey string) error {
|
||||
errChan := make(chan error, concurrency)
|
||||
errChan := make(chan error, tc.Concurrency)
|
||||
deleteTheMoveObjectOutputs = make([]*qs.DeleteObjectOutput, tc.Concurrency)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(concurrency)
|
||||
for i := 0; i < concurrency; i++ {
|
||||
wg.Add(tc.Concurrency)
|
||||
for i := 0; i < tc.Concurrency; i++ {
|
||||
go func(index int, errChan chan<- error) {
|
||||
wg.Done()
|
||||
|
||||
@@ -619,7 +627,7 @@ func deleteTheMoveObjectWithKey(objectKey string) error {
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
for i := 0; i < concurrency; i++ {
|
||||
for i := 0; i < tc.Concurrency; i++ {
|
||||
err = <-errChan
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
+2
@@ -5,3 +5,5 @@ bucket_name: access-key-id
|
||||
|
||||
retry_wait_time: 3 # seconds
|
||||
max_retries: 60
|
||||
|
||||
concurrency: 1
|
||||
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"errors"
|
||||
|
||||
"github.com/DATA-DOG/godog"
|
||||
"github.com/yunify/qingstor-sdk-go/client/upload"
|
||||
)
|
||||
|
||||
var uploader *upload.Uploader
|
||||
|
||||
// UploadFeatureContext provides feature context for upload.
|
||||
func UploadFeatureContext(s *godog.Suite) {
|
||||
s.Step("initialize uploader$", initializeUploader)
|
||||
s.Step("uploader is initialized$", uploaderIsInitialized)
|
||||
|
||||
s.Step("upload a large file$", uploadLargeFile)
|
||||
s.Step("the large file is uploaded$", largeFileIsUploaded)
|
||||
}
|
||||
|
||||
var fd *os.File
|
||||
|
||||
func initializeUploader() error {
|
||||
uploadSetup()
|
||||
PartSize := 4 * 1024 * 1024
|
||||
|
||||
fd, err = os.Open("test_file")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
uploader = upload.Init(bucket, PartSize)
|
||||
return nil
|
||||
}
|
||||
|
||||
func uploaderIsInitialized() error {
|
||||
if uploader == nil {
|
||||
return errors.New("uploader not initialized")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var objectKey string
|
||||
|
||||
func uploadLargeFile() error {
|
||||
objectKey = "test_multipart_upload"
|
||||
err := uploader.Upload(fd, objectKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func largeFileIsUploaded() error {
|
||||
defer uploadTearDown()
|
||||
return nil
|
||||
}
|
||||
|
||||
func uploadSetup() {
|
||||
exec.Command("dd", "if=/dev/zero", "of=test_file", "bs=1024", "count=20480").Output()
|
||||
}
|
||||
|
||||
func uploadTearDown() {
|
||||
exec.Command("rm", "", "test_file").Output()
|
||||
}
|
||||
Reference in New Issue
Block a user