|
|
|
@ -95,12 +95,12 @@ func TestStoreLockTrans(t *testing.T) { |
|
|
|
|
|
|
|
func TestStoreResetCronTime(t *testing.T) { |
|
|
|
s := registry.GetStore() |
|
|
|
testStoreResetCronTime(t, dtmimp.GetFuncName(), func(timeout int64, limit int64) error { |
|
|
|
testStoreResetCronTime(t, dtmimp.GetFuncName(), func(timeout int64, limit int64) (int64, bool, error) { |
|
|
|
return s.ResetCronTime(time.Duration(timeout)*time.Second, limit) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
func testStoreResetCronTime(t *testing.T, funcName string, restCronHandler func(expire int64, limit int64) error) { |
|
|
|
func testStoreResetCronTime(t *testing.T, funcName string, restCronHandler func(expire int64, limit int64) (int64, bool, error)) { |
|
|
|
s := registry.GetStore() |
|
|
|
var restTimeTimeout, lockExpireIn, limit, i int64 |
|
|
|
restTimeTimeout = 100 //The time that will be ResetCronTime
|
|
|
|
@ -122,7 +122,9 @@ func testStoreResetCronTime(t *testing.T, funcName string, restCronHandler func( |
|
|
|
assert.Nil(t, g) |
|
|
|
|
|
|
|
// Rest limit-1 count
|
|
|
|
err := restCronHandler(restTimeTimeout, limit-1) |
|
|
|
succeedCount, hasRemaining, err := restCronHandler(restTimeTimeout, limit-1) |
|
|
|
assert.Equal(t, hasRemaining, true) |
|
|
|
assert.Equal(t, succeedCount, limit-1) |
|
|
|
assert.Nil(t, err) |
|
|
|
// Fount limit-1 count
|
|
|
|
for i = 0; i < limit-1; i++ { |
|
|
|
@ -136,8 +138,10 @@ func testStoreResetCronTime(t *testing.T, funcName string, restCronHandler func( |
|
|
|
assert.Nil(t, g) |
|
|
|
|
|
|
|
// Rest 1 count
|
|
|
|
err1 := restCronHandler(restTimeTimeout, limit) |
|
|
|
assert.Nil(t, err1) |
|
|
|
succeedCount, hasRemaining, err = restCronHandler(restTimeTimeout, limit) |
|
|
|
assert.Equal(t, hasRemaining, false) |
|
|
|
assert.Equal(t, succeedCount, int64(1)) |
|
|
|
assert.Nil(t, err) |
|
|
|
// Fount 1 count
|
|
|
|
g = s.LockOneGlobalTrans(time.Duration(lockExpireIn) * time.Second) |
|
|
|
assert.NotNil(t, g) |
|
|
|
@ -148,8 +152,10 @@ func testStoreResetCronTime(t *testing.T, funcName string, restCronHandler func( |
|
|
|
assert.Nil(t, g) |
|
|
|
|
|
|
|
// reduce the restTimeTimeout, Rest 1 count
|
|
|
|
err2 := restCronHandler(restTimeTimeout-12, limit) |
|
|
|
assert.Nil(t, err2) |
|
|
|
succeedCount, hasRemaining, err = restCronHandler(restTimeTimeout-12, limit) |
|
|
|
assert.Equal(t, hasRemaining, false) |
|
|
|
assert.Equal(t, succeedCount, int64(1)) |
|
|
|
assert.Nil(t, err) |
|
|
|
// Fount 1 count
|
|
|
|
g = s.LockOneGlobalTrans(time.Duration(lockExpireIn) * time.Second) |
|
|
|
assert.NotNil(t, g) |
|
|
|
@ -159,6 +165,11 @@ func testStoreResetCronTime(t *testing.T, funcName string, restCronHandler func( |
|
|
|
g = s.LockOneGlobalTrans(time.Duration(lockExpireIn) * time.Second) |
|
|
|
assert.Nil(t, g) |
|
|
|
|
|
|
|
// Not Fount
|
|
|
|
succeedCount, hasRemaining, err = restCronHandler(restTimeTimeout-12, limit) |
|
|
|
assert.Equal(t, hasRemaining, false) |
|
|
|
assert.Equal(t, succeedCount, int64(0)) |
|
|
|
assert.Nil(t, err) |
|
|
|
} |
|
|
|
|
|
|
|
func TestUpdateBranches(t *testing.T) { |
|
|
|
|