forked from TrueCloudLab/distribution
godep update oss sdk
Signed-off-by: tgic <farmer1992@gmail.com>
This commit is contained in:
parent
813543d6e3
commit
9627c6c5a5
3 changed files with 2 additions and 84 deletions
4
Godeps/Godeps.json
generated
4
Godeps/Godeps.json
generated
|
@ -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",
|
||||
|
|
27
Godeps/_workspace/src/github.com/denverdino/aliyungo/util/util.go
generated
vendored
27
Godeps/_workspace/src/github.com/denverdino/aliyungo/util/util.go
generated
vendored
|
@ -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")
|
||||
}
|
||||
|
|
55
Godeps/_workspace/src/github.com/denverdino/aliyungo/util/util_test.go
generated
vendored
55
Godeps/_workspace/src/github.com/denverdino/aliyungo/util/util_test.go
generated
vendored
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue