diff --git a/src/replication/dao/execution.go b/src/replication/dao/execution.go index 1833d7e3e..796dbd403 100644 --- a/src/replication/dao/execution.go +++ b/src/replication/dao/execution.go @@ -228,7 +228,7 @@ func UpdateExecution(execution *models.Execution, props ...string) (int64, error func AddTask(task *models.Task) (int64, error) { o := dao.GetOrmer() now := time.Now() - task.StartTime = &now + task.StartTime = now return o.Insert(task) } diff --git a/src/replication/dao/execution_test.go b/src/replication/dao/execution_test.go index 5d41efb9e..95940dcd1 100644 --- a/src/replication/dao/execution_test.go +++ b/src/replication/dao/execution_test.go @@ -100,7 +100,7 @@ func TestMethodOfTask(t *testing.T) { JobID: "jobID1", Status: "Initialized", StatusRevision: 1, - StartTime: &now, + StartTime: now, } task2 := &models.Task{ ExecutionID: 112200, @@ -110,8 +110,8 @@ func TestMethodOfTask(t *testing.T) { JobID: "jobID2", Status: "Stopped", StatusRevision: 1, - StartTime: &now, - EndTime: &now, + StartTime: now, + EndTime: now, } // test add @@ -146,7 +146,7 @@ func TestMethodOfTask(t *testing.T) { taskNew := &models.Task{ ID: id1, Status: "Failed", - EndTime: &now, + EndTime: now, } n, err := UpdateTask(taskNew, models.TaskPropsName.Status, models.TaskPropsName.EndTime) require.Nil(t, err) @@ -195,8 +195,8 @@ func TestExecutionFill(t *testing.T) { DstResource: "dstResource1", JobID: "jobID1", Status: "Succeed", - StartTime: &now, - EndTime: &et1, + StartTime: now, + EndTime: et1, } task2 := &models.Task{ ID: 20192, @@ -206,8 +206,8 @@ func TestExecutionFill(t *testing.T) { DstResource: "dstResource2", JobID: "jobID2", Status: "Stopped", - StartTime: &now, - EndTime: &et2, + StartTime: now, + EndTime: et2, } AddTask(task1) AddTask(task2) @@ -248,7 +248,7 @@ func TestExecutionFill2(t *testing.T) { JobID: "jobID1", Status: models.TaskStatusInProgress, StatusRevision: 1, - StartTime: &now, + StartTime: now, } task2 := &models.Task{ ID: 20192, @@ -259,8 +259,8 @@ func TestExecutionFill2(t *testing.T) { JobID: "jobID2", Status: "Stopped", StatusRevision: 1, - StartTime: &now, - EndTime: &now, + StartTime: now, + EndTime: now, } taskID1, _ := AddTask(task1) AddTask(task2) diff --git a/src/replication/dao/models/execution.go b/src/replication/dao/models/execution.go index 95c5386ba..d0dbce87f 100644 --- a/src/replication/dao/models/execution.go +++ b/src/replication/dao/models/execution.go @@ -109,17 +109,17 @@ type TaskFieldsName struct { // Task represent the tasks in one execution. type Task struct { - ID int64 `orm:"pk;auto;column(id)" json:"id"` - ExecutionID int64 `orm:"column(execution_id)" json:"execution_id"` - ResourceType string `orm:"column(resource_type)" json:"resource_type"` - SrcResource string `orm:"column(src_resource)" json:"src_resource"` - DstResource string `orm:"column(dst_resource)" json:"dst_resource"` - Operation string `orm:"column(operation)" json:"operation"` - JobID string `orm:"column(job_id)" json:"job_id"` - Status string `orm:"column(status)" json:"status"` - StatusRevision int64 `orm:"column(status_revision)"` - StartTime *time.Time `orm:"column(start_time)" json:"start_time"` - EndTime *time.Time `orm:"column(end_time)" json:"end_time,omitempty"` + ID int64 `orm:"pk;auto;column(id)" json:"id"` + ExecutionID int64 `orm:"column(execution_id)" json:"execution_id"` + ResourceType string `orm:"column(resource_type)" json:"resource_type"` + SrcResource string `orm:"column(src_resource)" json:"src_resource"` + DstResource string `orm:"column(dst_resource)" json:"dst_resource"` + Operation string `orm:"column(operation)" json:"operation"` + JobID string `orm:"column(job_id)" json:"job_id"` + Status string `orm:"column(status)" json:"status"` + StatusRevision int64 `orm:"column(status_revision)"` + StartTime time.Time `orm:"column(start_time)" json:"start_time"` + EndTime time.Time `orm:"column(end_time)" json:"end_time,omitempty"` } // TableName is required by by beego orm to map Execution to table replication_execution diff --git a/src/replication/operation/execution/execution_test.go b/src/replication/operation/execution/execution_test.go index 7262186da..ba1d8f1f8 100644 --- a/src/replication/operation/execution/execution_test.go +++ b/src/replication/operation/execution/execution_test.go @@ -83,7 +83,7 @@ func TestMethodOfTaskManager(t *testing.T) { JobID: "jobID1", Status: "Initialized", StatusRevision: 1, - StartTime: &now, + StartTime: now, } defer func() { diff --git a/src/replication/operation/flow/stage.go b/src/replication/operation/flow/stage.go index 5048662e1..0e49f4820 100644 --- a/src/replication/operation/flow/stage.go +++ b/src/replication/operation/flow/stage.go @@ -285,7 +285,7 @@ func schedule(scheduler scheduler.Scheduler, executionMgr execution.Manager, ite if err = executionMgr.UpdateTask(&models.Task{ ID: result.TaskID, Status: models.TaskStatusFailed, - EndTime: &now, + EndTime: now, }, "Status", "EndTime"); err != nil { log.Errorf("failed to update the task status %d: %v", result.TaskID, err) } @@ -299,7 +299,7 @@ func schedule(scheduler scheduler.Scheduler, executionMgr execution.Manager, ite if err = executionMgr.UpdateTask(&models.Task{ ID: result.TaskID, JobID: result.JobID, - StartTime: &now, + StartTime: now, }, "JobID", "StartTime"); err != nil { log.Errorf("failed to update the task %d: %v", result.TaskID, err) }