- category sync almost ok.
- refactor tasksch (isContinueWhenError)
This commit is contained in:
@@ -13,7 +13,10 @@ func TestRunTask(t *testing.T) {
|
||||
for k := range itemList {
|
||||
itemList[k] = k
|
||||
}
|
||||
task := RunTask("test", func(batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
task := RunTask("test", false, func(taskName string, result []interface{}, err error) {
|
||||
// t.Log("finished here")
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
}, 100, 7, "autotest", func(batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
sleepSecond := rand.Intn(5)
|
||||
t.Logf("sleep %d seconds", sleepSecond)
|
||||
time.Sleep(time.Duration(sleepSecond) * time.Second)
|
||||
@@ -22,10 +25,7 @@ func TestRunTask(t *testing.T) {
|
||||
retSlice[k] = "hello:" + utils.Int2Str(batchItemList[k].(int)*2)
|
||||
}
|
||||
return retSlice, nil
|
||||
}, func(taskName string, result []interface{}, err error) {
|
||||
// t.Log("finished here")
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
}, 100, 7, "autotest", itemList, "a", "b", 1, 2)
|
||||
}, itemList, "a", "b", 1, 2)
|
||||
result, err := task.GetResult(1 * time.Microsecond)
|
||||
if err == nil || task.GetStatus() != TaskStatusWorking {
|
||||
t.Fatal("task can not be done in 1 microsecond")
|
||||
@@ -46,7 +46,10 @@ func TestCancelTask(t *testing.T) {
|
||||
for k := range itemList {
|
||||
itemList[k] = k
|
||||
}
|
||||
task := RunTask("test", func(batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
task := RunTask("test", false, func(taskName string, result []interface{}, err error) {
|
||||
// t.Log("finished here")
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
}, 100, 7, "autotest", func(batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
sleepSecond := rand.Intn(5)
|
||||
t.Logf("sleep %d seconds", sleepSecond)
|
||||
time.Sleep(time.Duration(sleepSecond) * time.Second)
|
||||
@@ -55,10 +58,7 @@ func TestCancelTask(t *testing.T) {
|
||||
retSlice[k] = "hello:" + utils.Int2Str(batchItemList[k].(int)*2)
|
||||
}
|
||||
return retSlice, nil
|
||||
}, func(taskName string, result []interface{}, err error) {
|
||||
// t.Log("finished here")
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
}, 100, 7, "autotest", itemList, "a", "b", 1, 2)
|
||||
}, itemList, "a", "b", 1, 2)
|
||||
// time.Sleep(time.Second * 6)
|
||||
t.Logf("finishedItemCount:%d, finishedJobCount:%d", task.GetFinishedItemCount(), task.GetFinishedJobCount())
|
||||
task.Cancel()
|
||||
|
||||
Reference in New Issue
Block a user