diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index dbc22b69..3dbf5326 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -46,11 +46,11 @@ }, { "ImportPath": "github.com/denverdino/aliyungo/oss", - "Rev": "cab34948f93584226cdaac45adb09f3bb3725875" + "Rev": "641bb4f0ddb552750324cb54c0140ca08865abd0" }, { "ImportPath": "github.com/denverdino/aliyungo/util", - "Rev": "cab34948f93584226cdaac45adb09f3bb3725875" + "Rev": "641bb4f0ddb552750324cb54c0140ca08865abd0" }, { "ImportPath": "github.com/docker/docker/pkg/tarsum", diff --git a/Godeps/_workspace/src/github.com/denverdino/aliyungo/util/util.go b/Godeps/_workspace/src/github.com/denverdino/aliyungo/util/util.go index 3e21abfc..daa6bb02 100644 --- a/Godeps/_workspace/src/github.com/denverdino/aliyungo/util/util.go +++ b/Godeps/_workspace/src/github.com/denverdino/aliyungo/util/util.go @@ -10,12 +10,6 @@ import ( "sort" "strconv" "time" - "errors" -) - - -const ( - StatusUnKnown = "NA" ) //CreateRandomString create random string @@ -138,24 +132,3 @@ func GenerateRandomECSPassword() string { return string(s) } - - -func LoopCall(attempts AttemptStrategy,api func() (bool,interface{},error))(interface{}, error){ - - for attempt := attempts.Start(); attempt.Next(); { - needStop,status,err := api() - - if(err != nil) { - return nil, errors.New("execution failed") - } - if(needStop){ - return status,nil; - } - - if attempt.HasNext() { - continue; - } - return nil,errors.New("timeout execution ") - } - panic("unreachable") -} diff --git a/Godeps/_workspace/src/github.com/denverdino/aliyungo/util/util_test.go b/Godeps/_workspace/src/github.com/denverdino/aliyungo/util/util_test.go index 354b95f1..87d2a0b8 100644 --- a/Godeps/_workspace/src/github.com/denverdino/aliyungo/util/util_test.go +++ b/Godeps/_workspace/src/github.com/denverdino/aliyungo/util/util_test.go @@ -2,8 +2,6 @@ package util import ( "testing" - "errors" - "time" ) func TestGenerateRandomECSPassword(t *testing.T) { @@ -43,56 +41,3 @@ func TestGenerateRandomECSPassword(t *testing.T) { } } } - -func TestWaitForSignalWithTimeout(t *testing.T) { - - attempts := AttemptStrategy{ - Min: 5, - Total: 5 * time.Second, - Delay: 200 * time.Millisecond, - } - - timeoutFunc := func() (bool,interface{},error) { - return false,"-1",nil - } - - begin := time.Now() - - _, timeoutError := LoopCall(attempts, timeoutFunc); - if(timeoutError != nil) { - t.Logf("timeout func complete successful") - } else { - t.Error("Expect timeout result") - } - - end := time.Now() - duration := end.Sub(begin).Seconds() - if( duration > (float64(attempts.Min) -1)) { - t.Logf("timeout func duration is enough") - } else { - t.Error("timeout func duration is not enough") - } - - errorFunc := func() (bool, interface{}, error) { - err := errors.New("execution failed"); - return false,"-1",err - } - - _, failedError := LoopCall(attempts, errorFunc); - if(failedError != nil) { - t.Logf("error func complete successful: " + failedError.Error()) - } else { - t.Error("Expect error result") - } - - successFunc := func() (bool,interface{}, error) { - return true,nil,nil - } - - _, successError := LoopCall(attempts, successFunc); - if(successError != nil) { - t.Error("Expect success result") - } else { - t.Logf("success func complete successful") - } -}