diff --git a/service/history/historyEngine.go b/service/history/historyEngine.go index 147e8cf1166..93f9f0149e6 100644 --- a/service/history/historyEngine.go +++ b/service/history/historyEngine.go @@ -1199,18 +1199,17 @@ func (e *historyEngineImpl) DescribeWorkflowExecution( } } - if workflowTask, ok := mutableState.GetPendingWorkflowTask(); ok { - pendingWorkflowTask := &workflowpb.PendingWorkflowTaskInfo{ + if pendingWorkflowTask, ok := mutableState.GetPendingWorkflowTask(); ok { + result.PendingWorkflowTask = &workflowpb.PendingWorkflowTaskInfo{ State: enumspb.PENDING_WORKFLOW_TASK_STATE_SCHEDULED, - ScheduledTime: workflowTask.ScheduledTime, - OriginalScheduledTime: workflowTask.OriginalScheduledTime, - Attempt: workflowTask.Attempt, + ScheduledTime: pendingWorkflowTask.ScheduledTime, + OriginalScheduledTime: pendingWorkflowTask.OriginalScheduledTime, + Attempt: pendingWorkflowTask.Attempt, } - if workflowTask.StartedEventID != common.EmptyEventID { - pendingWorkflowTask.State = enumspb.PENDING_WORKFLOW_TASK_STATE_STARTED - pendingWorkflowTask.StartedTime = workflowTask.StartedTime + if pendingWorkflowTask.StartedEventID != common.EmptyEventID { + result.PendingWorkflowTask.State = enumspb.PENDING_WORKFLOW_TASK_STATE_STARTED + result.PendingWorkflowTask.StartedTime = pendingWorkflowTask.StartedTime } - result.PendingWorkflowTask = pendingWorkflowTask } return result, nil diff --git a/service/history/historyEngine2_test.go b/service/history/historyEngine2_test.go index ad9588985d6..e3d05d777b3 100644 --- a/service/history/historyEngine2_test.go +++ b/service/history/historyEngine2_test.go @@ -209,7 +209,7 @@ func (s *engine2Suite) TestRecordWorkflowTaskStartedSuccessStickyEnabled() { executionInfo.StickyTaskQueue = stickyTl addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) + wt := addWorkflowTaskScheduledEvent(msBuilder) ms := workflow.TestCloneToProto(msBuilder) @@ -238,12 +238,12 @@ func (s *engine2Suite) TestRecordWorkflowTaskStartedSuccessStickyEnabled() { if executionInfo.LastWorkflowTaskStartedEventId != common.EmptyEventID { expectedResponse.PreviousStartedEventId = executionInfo.LastWorkflowTaskStartedEventId } - expectedResponse.ScheduledEventId = di.ScheduledEventID - expectedResponse.ScheduledTime = di.ScheduledTime - expectedResponse.StartedEventId = di.ScheduledEventID + 1 + expectedResponse.ScheduledEventId = wt.ScheduledEventID + expectedResponse.ScheduledTime = wt.ScheduledTime + expectedResponse.StartedEventId = wt.ScheduledEventID + 1 expectedResponse.StickyExecutionEnabled = true expectedResponse.NextEventId = msBuilder.GetNextEventID() + 1 - expectedResponse.Attempt = di.Attempt + expectedResponse.Attempt = wt.Attempt expectedResponse.WorkflowExecutionTaskQueue = &taskqueuepb.TaskQueue{ Name: executionInfo.TaskQueue, Kind: enumspb.TASK_QUEUE_KIND_NORMAL, @@ -909,9 +909,9 @@ func (s *engine2Suite) createExecutionStartedStateWithParent( msBuilder := workflow.TestLocalMutableState(s.historyEngine.shard, s.mockEventsCache, tests.LocalNamespaceEntry, s.logger, we.GetRunId()) addWorkflowExecutionStartedEventWithParent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, parentInfo, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) + wt := addWorkflowTaskScheduledEvent(msBuilder) if startWorkflowTask { - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) } _ = msBuilder.SetHistoryTree(we.GetRunId()) versionHistory, _ := versionhistory.GetCurrentVersionHistory( @@ -947,8 +947,8 @@ func (s *engine2Suite) TestRespondWorkflowTaskCompletedRecordMarkerCommand() { msBuilder := workflow.TestLocalMutableState(s.historyEngine.shard, s.mockEventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) commands := []*commandpb.Command{{ CommandType: enumspb.COMMAND_TYPE_RECORD_MARKER, @@ -1002,8 +1002,8 @@ func (s *engine2Suite) TestRespondWorkflowTaskCompleted_StartChildWithSearchAttr msBuilder := workflow.TestLocalMutableState(s.historyEngine.shard, s.mockEventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, nil, 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) commands := []*commandpb.Command{{ CommandType: enumspb.COMMAND_TYPE_START_CHILD_WORKFLOW_EXECUTION, @@ -1680,10 +1680,10 @@ func (s *engine2Suite) TestRecordChildExecutionCompleted() { s.IsType(&serviceerror.NotFound{}, err) // add child init event - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTasksStartEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, "testTaskQueue", uuid.New()) - di.StartedEventID = workflowTasksStartEvent.GetEventId() - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTasksStartEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, "testTaskQueue", uuid.New()) + wt.StartedEventID = workflowTasksStartEvent.GetEventId() + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, wt.StartedEventID, "some random identity") initiatedEvent, _ := addStartChildWorkflowExecutionInitiatedEvent(msBuilder, workflowTaskCompletedEvent.GetEventId(), uuid.New(), tests.ChildNamespace, tests.ChildNamespaceID, childWorkflowID, childWorkflowType, childTaskQueueName, nil, 1*time.Second, 1*time.Second, 1*time.Second, enumspb.PARENT_CLOSE_POLICY_TERMINATE) @@ -1860,10 +1860,10 @@ func (s *engine2Suite) TestVerifyChildExecutionCompletionRecorded_InitiatedEvent WorkflowId: tests.WorkflowID, RunId: tests.RunID, }, "wType", taskQueueName, payloads.EncodeString("input"), 25*time.Second, 20*time.Second, 200*time.Second, "identity") - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTasksStartEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = workflowTasksStartEvent.GetEventId() - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTasksStartEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = workflowTasksStartEvent.GetEventId() + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, wt.StartedEventID, "some random identity") initiatedEvent, ci := addStartChildWorkflowExecutionInitiatedEvent(msBuilder, workflowTaskCompletedEvent.GetEventId(), uuid.New(), tests.ChildNamespace, tests.ChildNamespaceID, childWorkflowID, childWorkflowType, childTaskQueueName, nil, 1*time.Second, 1*time.Second, 1*time.Second, enumspb.PARENT_CLOSE_POLICY_TERMINATE) diff --git a/service/history/historyEngine3_eventsv2_test.go b/service/history/historyEngine3_eventsv2_test.go index 53684bbd7b8..6204230c574 100644 --- a/service/history/historyEngine3_eventsv2_test.go +++ b/service/history/historyEngine3_eventsv2_test.go @@ -186,7 +186,7 @@ func (s *engine3Suite) TestRecordWorkflowTaskStartedSuccessStickyEnabled() { executionInfo.StickyTaskQueue = stickyTl addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) + wt := addWorkflowTaskScheduledEvent(msBuilder) ms := workflow.TestCloneToProto(msBuilder) @@ -215,12 +215,12 @@ func (s *engine3Suite) TestRecordWorkflowTaskStartedSuccessStickyEnabled() { if executionInfo.LastWorkflowTaskStartedEventId != common.EmptyEventID { expectedResponse.PreviousStartedEventId = executionInfo.LastWorkflowTaskStartedEventId } - expectedResponse.ScheduledEventId = di.ScheduledEventID - expectedResponse.ScheduledTime = di.ScheduledTime - expectedResponse.StartedEventId = di.ScheduledEventID + 1 + expectedResponse.ScheduledEventId = wt.ScheduledEventID + expectedResponse.ScheduledTime = wt.ScheduledTime + expectedResponse.StartedEventId = wt.ScheduledEventID + 1 expectedResponse.StickyExecutionEnabled = true expectedResponse.NextEventId = msBuilder.GetNextEventID() + 1 - expectedResponse.Attempt = di.Attempt + expectedResponse.Attempt = wt.Attempt expectedResponse.WorkflowExecutionTaskQueue = &taskqueuepb.TaskQueue{ Name: executionInfo.TaskQueue, Kind: enumspb.TASK_QUEUE_KIND_NORMAL, diff --git a/service/history/historyEngine_test.go b/service/history/historyEngine_test.go index dfdb57df05f..e3cb492758b 100644 --- a/service/history/historyEngine_test.go +++ b/service/history/historyEngine_test.go @@ -228,8 +228,8 @@ func (s *engineSuite) TestGetMutableStateSync() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), execution.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, execution, "wType", taskqueue, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, taskqueue, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, taskqueue, identity) ms := workflow.TestCloneToProto(msBuilder) gweResponse := &persistence.GetWorkflowExecutionResponse{State: ms} // right now the next event ID is 4 @@ -290,8 +290,8 @@ func (s *engineSuite) TestGetMutableStateLongPoll() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), execution.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, execution, "wType", taskqueue, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, taskqueue, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, taskqueue, identity) ms := workflow.TestCloneToProto(msBuilder) gweResponse := &persistence.GetWorkflowExecutionResponse{State: ms} // right now the next event ID is 4 @@ -366,8 +366,8 @@ func (s *engineSuite) TestGetMutableStateLongPoll_CurrentBranchChanged() { log.NewTestLogger(), execution.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, execution, "wType", taskqueue, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, taskqueue, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, taskqueue, identity) ms := workflow.TestCloneToProto(msBuilder) gweResponse := &persistence.GetWorkflowExecutionResponse{State: ms} // right now the next event ID is 4 @@ -428,8 +428,8 @@ func (s *engineSuite) TestGetMutableStateLongPollTimeout() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), execution.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, execution, "wType", taskqueue, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, taskqueue, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, taskqueue, identity) ms := workflow.TestCloneToProto(msBuilder) gweResponse := &persistence.GetWorkflowExecutionResponse{State: ms} // right now the next event ID is 4 @@ -455,10 +455,10 @@ func (s *engineSuite) TestQueryWorkflow_RejectBasedOnCompleted() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), execution.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, execution, "wType", taskqueue, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - event := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, taskqueue, identity) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(msBuilder) + event := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, taskqueue, identity) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, wt.StartedEventID, "some random identity") addCompleteWorkflowEvent(msBuilder, event.GetEventId(), nil) ms := workflow.TestCloneToProto(msBuilder) gweResponse := &persistence.GetWorkflowExecutionResponse{State: ms} @@ -489,10 +489,10 @@ func (s *engineSuite) TestQueryWorkflow_RejectBasedOnFailed() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), execution.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, execution, "wType", taskqueue, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - event := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, taskqueue, identity) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(msBuilder) + event := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, taskqueue, identity) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, wt.StartedEventID, "some random identity") addFailWorkflowEvent(msBuilder, event.GetEventId(), failure.NewServerFailure("failure reason", true), enumspb.RETRY_STATE_NON_RETRYABLE_FAILURE) ms := workflow.TestCloneToProto(msBuilder) gweResponse := &persistence.GetWorkflowExecutionResponse{State: ms} @@ -537,9 +537,9 @@ func (s *engineSuite) TestQueryWorkflow_DirectlyThroughMatching() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), execution.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, execution, "wType", taskqueue, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - startedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, taskqueue, identity) - addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, startedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + startedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, taskqueue, identity) + addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, startedEvent.EventId, identity) ms := workflow.TestCloneToProto(msBuilder) gweResponse := &persistence.GetWorkflowExecutionResponse{State: ms} @@ -575,11 +575,11 @@ func (s *engineSuite) TestQueryWorkflow_WorkflowTaskDispatch_Timeout() { identity := "testIdentity" msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), execution.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, execution, "wType", taskqueue, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - startedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, taskqueue, identity) - addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, startedEvent.EventId, identity) - di = addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, taskqueue, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + startedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, taskqueue, identity) + addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, startedEvent.EventId, identity) + wt = addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, taskqueue, identity) ms := workflow.TestCloneToProto(msBuilder) gweResponse := &persistence.GetWorkflowExecutionResponse{State: ms} @@ -629,11 +629,11 @@ func (s *engineSuite) TestQueryWorkflow_ConsistentQueryBufferFull() { identity := "testIdentity" msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), execution.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, execution, "wType", taskqueue, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - startedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, taskqueue, identity) - addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, startedEvent.EventId, identity) - di = addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, taskqueue, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + startedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, taskqueue, identity) + addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, startedEvent.EventId, identity) + wt = addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, taskqueue, identity) ms := workflow.TestCloneToProto(msBuilder) gweResponse := &persistence.GetWorkflowExecutionResponse{State: ms} @@ -675,11 +675,11 @@ func (s *engineSuite) TestQueryWorkflow_WorkflowTaskDispatch_Complete() { identity := "testIdentity" msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), execution.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, execution, "wType", taskqueue, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - startedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, taskqueue, identity) - addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, startedEvent.EventId, identity) - di = addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, taskqueue, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + startedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, taskqueue, identity) + addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, startedEvent.EventId, identity) + wt = addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, taskqueue, identity) ms := workflow.TestCloneToProto(msBuilder) gweResponse := &persistence.GetWorkflowExecutionResponse{State: ms} @@ -746,11 +746,11 @@ func (s *engineSuite) TestQueryWorkflow_WorkflowTaskDispatch_Unblocked() { identity := "testIdentity" msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), execution.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, execution, "wType", taskqueue, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - startedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, taskqueue, identity) - addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, startedEvent.EventId, identity) - di = addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, taskqueue, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + startedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, taskqueue, identity) + addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, startedEvent.EventId, identity) + wt = addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, taskqueue, identity) ms := workflow.TestCloneToProto(msBuilder) gweResponse := &persistence.GetWorkflowExecutionResponse{State: ms} @@ -889,8 +889,8 @@ func (s *engineSuite) TestRespondWorkflowTaskCompletedUpdateExecutionFailed() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tq, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tq, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tq, identity) ms := workflow.TestCloneToProto(msBuilder) gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} @@ -930,9 +930,9 @@ func (s *engineSuite) TestRespondWorkflowTaskCompletedIfTaskCompleted() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tq, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - startedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tq, identity) - addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, startedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + startedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tq, identity) + addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, startedEvent.EventId, identity) ms := workflow.TestCloneToProto(msBuilder) gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} @@ -1115,8 +1115,8 @@ func (s *engineSuite) TestRespondWorkflowTaskCompleted_StaleCache() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) commands := []*commandpb.Command{{ CommandType: enumspb.COMMAND_TYPE_SCHEDULE_ACTIVITY_TASK, @@ -1456,8 +1456,8 @@ func (s *engineSuite) TestRespondWorkflowTaskCompletedSingleActivityScheduledAtt msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), time.Duration(runTimeout*10)*time.Second, time.Duration(runTimeout)*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) commands := []*commandpb.Command{{ CommandType: enumspb.COMMAND_TYPE_SCHEDULE_ACTIVITY_TASK, @@ -1549,8 +1549,8 @@ func (s *engineSuite) TestRespondWorkflowTaskCompletedBadBinary() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, ns, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) var commands []*commandpb.Command @@ -1607,8 +1607,8 @@ func (s *engineSuite) TestRespondWorkflowTaskCompletedSingleActivityScheduledWor msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 90*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) commands := []*commandpb.Command{{ CommandType: enumspb.COMMAND_TYPE_SCHEDULE_ACTIVITY_TASK, @@ -1678,8 +1678,8 @@ func (s *engineSuite) TestRespondWorkflowTaskCompleted_ActivityLocalDispatch() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 90*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) scheduleToCloseTimeout := timestamp.DurationPtr(90 * time.Second) scheduleToStartTimeout := timestamp.DurationPtr(10 * time.Second) @@ -1784,8 +1784,8 @@ func (s *engineSuite) TestRespondWorkflowTaskCompleted_WorkflowTaskHeartbeatTime msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) msBuilder.GetExecutionInfo().WorkflowTaskOriginalScheduledTime = timestamp.TimePtr(time.Now().UTC().Add(-time.Hour)) var commands []*commandpb.Command @@ -1828,8 +1828,8 @@ func (s *engineSuite) TestRespondWorkflowTaskCompleted_WorkflowTaskHeartbeatNotT msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) msBuilder.GetExecutionInfo().WorkflowTaskOriginalScheduledTime = timestamp.TimePtr(time.Now().UTC().Add(-time.Minute)) var commands []*commandpb.Command @@ -1872,8 +1872,8 @@ func (s *engineSuite) TestRespondWorkflowTaskCompleted_WorkflowTaskHeartbeatNotT msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) msBuilder.GetExecutionInfo().WorkflowTaskOriginalScheduledTime = nil var commands []*commandpb.Command @@ -1917,8 +1917,8 @@ func (s *engineSuite) TestRespondWorkflowTaskCompletedCompleteWorkflowSuccess() msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) commands := []*commandpb.Command{{ CommandType: enumspb.COMMAND_TYPE_COMPLETE_WORKFLOW_EXECUTION, @@ -1970,8 +1970,8 @@ func (s *engineSuite) TestRespondWorkflowTaskCompletedFailWorkflowSuccess() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) commands := []*commandpb.Command{{ CommandType: enumspb.COMMAND_TYPE_FAIL_WORKFLOW_EXECUTION, @@ -2022,8 +2022,8 @@ func (s *engineSuite) TestRespondWorkflowTaskCompletedSignalExternalWorkflowSucc msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) commands := []*commandpb.Command{{ CommandType: enumspb.COMMAND_TYPE_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION, @@ -2078,8 +2078,8 @@ func (s *engineSuite) TestRespondWorkflowTaskCompletedStartChildWorkflowWithAban msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) abandon := enumspb.PARENT_CLOSE_POLICY_ABANDON commands := []*commandpb.Command{{ @@ -2142,8 +2142,8 @@ func (s *engineSuite) TestRespondWorkflowTaskCompletedStartChildWorkflowWithTerm msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) terminate := enumspb.PARENT_CLOSE_POLICY_TERMINATE commands := []*commandpb.Command{{ @@ -2207,8 +2207,8 @@ Attempt: 1, msBuilder := tests.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, loggerimpl.NewTestLogger(s.Suite), tests.RunID) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payload.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) commands := []*commandpb.Command{{ CommandType: enumspb.COMMAND_TYPE_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION, @@ -2257,8 +2257,8 @@ func (s *engineSuite) TestRespondWorkflowTaskCompletedSignalExternalWorkflowFail msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) commands := []*commandpb.Command{{ CommandType: enumspb.COMMAND_TYPE_SIGNAL_EXTERNAL_WORKFLOW_EXECUTION, @@ -2483,9 +2483,9 @@ func (s *engineSuite) TestRespondActivityTaskCompletedUpdateExecutionFailed() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) activityScheduledEvent, _ := addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 5*time.Second) addActivityTaskStartedEvent(msBuilder, activityScheduledEvent.EventId, identity) @@ -2531,9 +2531,9 @@ func (s *engineSuite) TestRespondActivityTaskCompletedIfTaskCompleted() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) activityScheduledEvent, _ := addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 5*time.Second) activityStartedEvent := addActivityTaskStartedEvent(msBuilder, activityScheduledEvent.EventId, identity) addActivityTaskCompletedEvent(msBuilder, activityScheduledEvent.EventId, activityStartedEvent.EventId, @@ -2581,9 +2581,9 @@ func (s *engineSuite) TestRespondActivityTaskCompletedIfTaskNotStarted() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 50*time.Second, 200*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 5*time.Second) ms := workflow.TestCloneToProto(msBuilder) @@ -2630,9 +2630,9 @@ func (s *engineSuite) TestRespondActivityTaskCompletedConflictOnUpdate() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent1 := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent1 := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent1.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent1 := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent1 := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent1.EventId, identity) activity1ScheduledEvent, _ := addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent1.EventId, activity1ID, activity1Type, tl, activity1Input, 100*time.Second, 10*time.Second, 1*time.Second, 5*time.Second) activity2ScheduledEvent, _ := addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent1.EventId, activity2ID, activity2Type, tl, activity2Input, 100*time.Second, 10*time.Second, 1*time.Second, 5*time.Second) addActivityTaskStartedEvent(msBuilder, activity1ScheduledEvent.EventId, identity) @@ -2665,11 +2665,11 @@ func (s *engineSuite) TestRespondActivityTaskCompletedConflictOnUpdate() { s.Equal(enumsspb.WORKFLOW_EXECUTION_STATE_RUNNING, executionBuilder.GetExecutionState().State) s.True(executionBuilder.HasPendingWorkflowTask()) - di, ok := executionBuilder.GetWorkflowTaskInfo(int64(10)) + wt, ok := executionBuilder.GetWorkflowTaskInfo(int64(10)) s.True(ok) - s.EqualValues(int64(100), di.WorkflowTaskTimeout.Seconds()) - s.Equal(int64(10), di.ScheduledEventID) - s.Equal(common.EmptyEventID, di.StartedEventID) + s.EqualValues(int64(100), wt.WorkflowTaskTimeout.Seconds()) + s.Equal(int64(10), wt.ScheduledEventID) + s.Equal(common.EmptyEventID, wt.StartedEventID) } func (s *engineSuite) TestRespondActivityTaskCompletedMaxAttemptsExceeded() { @@ -2696,9 +2696,9 @@ func (s *engineSuite) TestRespondActivityTaskCompletedMaxAttemptsExceeded() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) activityScheduledEvent, _ := addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 5*time.Second) addActivityTaskStartedEvent(msBuilder, activityScheduledEvent.EventId, identity) @@ -2745,9 +2745,9 @@ func (s *engineSuite) TestRespondActivityTaskCompletedSuccess() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) activityScheduledEvent, _ := addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 5*time.Second) addActivityTaskStartedEvent(msBuilder, activityScheduledEvent.EventId, identity) @@ -2772,11 +2772,11 @@ func (s *engineSuite) TestRespondActivityTaskCompletedSuccess() { s.Equal(enumsspb.WORKFLOW_EXECUTION_STATE_RUNNING, executionBuilder.GetExecutionState().State) s.True(executionBuilder.HasPendingWorkflowTask()) - di, ok := executionBuilder.GetWorkflowTaskInfo(int64(8)) + wt, ok := executionBuilder.GetWorkflowTaskInfo(int64(8)) s.True(ok) - s.EqualValues(int64(100), di.WorkflowTaskTimeout.Seconds()) - s.Equal(int64(8), di.ScheduledEventID) - s.Equal(common.EmptyEventID, di.StartedEventID) + s.EqualValues(int64(100), wt.WorkflowTaskTimeout.Seconds()) + s.Equal(int64(8), wt.ScheduledEventID) + s.Equal(common.EmptyEventID, wt.StartedEventID) } func (s *engineSuite) TestRespondActivityTaskCompletedByIdSuccess() { @@ -2833,11 +2833,11 @@ func (s *engineSuite) TestRespondActivityTaskCompletedByIdSuccess() { s.Equal(enumsspb.WORKFLOW_EXECUTION_STATE_RUNNING, executionBuilder.GetExecutionState().State) s.True(executionBuilder.HasPendingWorkflowTask()) - di, ok := executionBuilder.GetWorkflowTaskInfo(int64(8)) + wt, ok := executionBuilder.GetWorkflowTaskInfo(int64(8)) s.True(ok) - s.EqualValues(int64(100), di.WorkflowTaskTimeout.Seconds()) - s.Equal(int64(8), di.ScheduledEventID) - s.Equal(common.EmptyEventID, di.StartedEventID) + s.EqualValues(int64(100), wt.WorkflowTaskTimeout.Seconds()) + s.Equal(int64(8), wt.ScheduledEventID) + s.Equal(common.EmptyEventID, wt.StartedEventID) } func (s *engineSuite) TestRespondActivityTaskFailedInvalidToken() { @@ -3031,9 +3031,9 @@ func (s *engineSuite) TestRespondActivityTaskFailedUpdateExecutionFailed() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) activityScheduledEvent, _ := addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 5*time.Second) addActivityTaskStartedEvent(msBuilder, activityScheduledEvent.EventId, identity) @@ -3078,9 +3078,9 @@ func (s *engineSuite) TestRespondActivityTaskFailedIfTaskCompleted() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) activityScheduledEvent, _ := addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 5*time.Second) activityStartedEvent := addActivityTaskStartedEvent(msBuilder, activityScheduledEvent.EventId, identity) addActivityTaskFailedEvent(msBuilder, activityScheduledEvent.EventId, activityStartedEvent.EventId, failure, enumspb.RETRY_STATE_NON_RETRYABLE_FAILURE, identity) @@ -3126,9 +3126,9 @@ func (s *engineSuite) TestRespondActivityTaskFailedIfTaskNotStarted() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 5*time.Second) ms := workflow.TestCloneToProto(msBuilder) @@ -3214,11 +3214,11 @@ func (s *engineSuite) TestRespondActivityTaskFailedConflictOnUpdate() { s.Equal(enumsspb.WORKFLOW_EXECUTION_STATE_RUNNING, executionBuilder.GetExecutionState().State) s.True(executionBuilder.HasPendingWorkflowTask()) - di, ok := executionBuilder.GetWorkflowTaskInfo(int64(10)) + wt, ok := executionBuilder.GetWorkflowTaskInfo(int64(10)) s.True(ok) - s.EqualValues(int64(25), di.WorkflowTaskTimeout.Seconds()) - s.Equal(int64(10), di.ScheduledEventID) - s.Equal(common.EmptyEventID, di.StartedEventID) + s.EqualValues(int64(25), wt.WorkflowTaskTimeout.Seconds()) + s.Equal(int64(10), wt.ScheduledEventID) + s.Equal(common.EmptyEventID, wt.StartedEventID) } func (s *engineSuite) TestRespondActivityTaskFailedMaxAttemptsExceeded() { @@ -3244,9 +3244,9 @@ func (s *engineSuite) TestRespondActivityTaskFailedMaxAttemptsExceeded() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) activityScheduledEvent, _ := addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 5*time.Second) addActivityTaskStartedEvent(msBuilder, activityScheduledEvent.EventId, identity) @@ -3292,9 +3292,9 @@ func (s *engineSuite) TestRespondActivityTaskFailedSuccess() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) activityScheduledEvent, _ := addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 5*time.Second) addActivityTaskStartedEvent(msBuilder, activityScheduledEvent.EventId, identity) @@ -3319,11 +3319,11 @@ func (s *engineSuite) TestRespondActivityTaskFailedSuccess() { s.Equal(enumsspb.WORKFLOW_EXECUTION_STATE_RUNNING, executionBuilder.GetExecutionState().State) s.True(executionBuilder.HasPendingWorkflowTask()) - di, ok := executionBuilder.GetWorkflowTaskInfo(int64(8)) + wt, ok := executionBuilder.GetWorkflowTaskInfo(int64(8)) s.True(ok) - s.EqualValues(int64(100), di.WorkflowTaskTimeout.Seconds()) - s.Equal(int64(8), di.ScheduledEventID) - s.Equal(common.EmptyEventID, di.StartedEventID) + s.EqualValues(int64(100), wt.WorkflowTaskTimeout.Seconds()) + s.Equal(int64(8), wt.ScheduledEventID) + s.Equal(common.EmptyEventID, wt.StartedEventID) } func (s *engineSuite) TestRespondActivityTaskFailedWithHeartbeatSuccess() { @@ -3350,9 +3350,9 @@ func (s *engineSuite) TestRespondActivityTaskFailedWithHeartbeatSuccess() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) activityScheduledEvent, activityInfo := addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 5*time.Second) addActivityTaskStartedEvent(msBuilder, activityScheduledEvent.EventId, identity) @@ -3383,11 +3383,11 @@ func (s *engineSuite) TestRespondActivityTaskFailedWithHeartbeatSuccess() { s.Equal(enumsspb.WORKFLOW_EXECUTION_STATE_RUNNING, executionBuilder.GetExecutionState().State) s.True(executionBuilder.HasPendingWorkflowTask()) - di, ok := executionBuilder.GetWorkflowTaskInfo(int64(8)) + wt, ok := executionBuilder.GetWorkflowTaskInfo(int64(8)) s.True(ok) - s.EqualValues(int64(100), di.WorkflowTaskTimeout.Seconds()) - s.Equal(int64(8), di.ScheduledEventID) - s.Equal(common.EmptyEventID, di.StartedEventID) + s.EqualValues(int64(100), wt.WorkflowTaskTimeout.Seconds()) + s.Equal(int64(8), wt.ScheduledEventID) + s.Equal(common.EmptyEventID, wt.StartedEventID) s.NotNil(activityInfo.GetLastHeartbeatDetails()) } @@ -3446,11 +3446,11 @@ func (s *engineSuite) TestRespondActivityTaskFailedByIdSuccess() { s.Equal(enumsspb.WORKFLOW_EXECUTION_STATE_RUNNING, executionBuilder.GetExecutionState().State) s.True(executionBuilder.HasPendingWorkflowTask()) - di, ok := executionBuilder.GetWorkflowTaskInfo(int64(8)) + wt, ok := executionBuilder.GetWorkflowTaskInfo(int64(8)) s.True(ok) - s.EqualValues(int64(100), di.WorkflowTaskTimeout.Seconds()) - s.Equal(int64(8), di.ScheduledEventID) - s.Equal(common.EmptyEventID, di.StartedEventID) + s.EqualValues(int64(100), wt.WorkflowTaskTimeout.Seconds()) + s.Equal(int64(8), wt.ScheduledEventID) + s.Equal(common.EmptyEventID, wt.StartedEventID) } func (s *engineSuite) TestRecordActivityTaskHeartBeatSuccess_NoTimer() { @@ -3476,9 +3476,9 @@ func (s *engineSuite) TestRecordActivityTaskHeartBeatSuccess_NoTimer() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) activityScheduledEvent, _ := addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 0*time.Second) addActivityTaskStartedEvent(msBuilder, activityScheduledEvent.EventId, identity) @@ -3524,9 +3524,9 @@ func (s *engineSuite) TestRecordActivityTaskHeartBeatSuccess_TimerRunning() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) activityScheduledEvent, _ := addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 1*time.Second) addActivityTaskStartedEvent(msBuilder, activityScheduledEvent.EventId, identity) @@ -3579,9 +3579,9 @@ func (s *engineSuite) TestRecordActivityTaskHeartBeatByIDSuccess() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) activityScheduledEvent, _ := addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 0*time.Second) addActivityTaskStartedEvent(msBuilder, activityScheduledEvent.EventId, identity) @@ -3627,9 +3627,9 @@ func (s *engineSuite) TestRespondActivityTaskCanceled_Scheduled() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 1*time.Second) ms := workflow.TestCloneToProto(msBuilder) @@ -3672,9 +3672,9 @@ func (s *engineSuite) TestRespondActivityTaskCanceled_Started() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) activityScheduledEvent, _ := addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 1*time.Second) addActivityTaskStartedEvent(msBuilder, activityScheduledEvent.EventId, identity) _, _, err := msBuilder.AddActivityTaskCancelRequestedEvent(workflowTaskCompletedEvent.EventId, activityScheduledEvent.EventId, identity) @@ -3701,11 +3701,11 @@ func (s *engineSuite) TestRespondActivityTaskCanceled_Started() { s.Equal(enumsspb.WORKFLOW_EXECUTION_STATE_RUNNING, executionBuilder.GetExecutionState().State) s.True(executionBuilder.HasPendingWorkflowTask()) - di, ok := executionBuilder.GetWorkflowTaskInfo(int64(9)) + wt, ok := executionBuilder.GetWorkflowTaskInfo(int64(9)) s.True(ok) - s.EqualValues(int64(100), di.WorkflowTaskTimeout.Seconds()) - s.Equal(int64(9), di.ScheduledEventID) - s.Equal(common.EmptyEventID, di.StartedEventID) + s.EqualValues(int64(100), wt.WorkflowTaskTimeout.Seconds()) + s.Equal(int64(9), wt.ScheduledEventID) + s.Equal(common.EmptyEventID, wt.StartedEventID) } func (s *engineSuite) TestRespondActivityTaskCanceledById_Started() { @@ -3762,11 +3762,11 @@ func (s *engineSuite) TestRespondActivityTaskCanceledById_Started() { s.Equal(enumsspb.WORKFLOW_EXECUTION_STATE_RUNNING, executionBuilder.GetExecutionState().State) s.True(executionBuilder.HasPendingWorkflowTask()) - di, ok := executionBuilder.GetWorkflowTaskInfo(int64(9)) + wt, ok := executionBuilder.GetWorkflowTaskInfo(int64(9)) s.True(ok) - s.EqualValues(int64(100), di.WorkflowTaskTimeout.Seconds()) - s.Equal(int64(9), di.ScheduledEventID) - s.Equal(common.EmptyEventID, di.StartedEventID) + s.EqualValues(int64(100), wt.WorkflowTaskTimeout.Seconds()) + s.Equal(int64(9), wt.ScheduledEventID) + s.Equal(common.EmptyEventID, wt.StartedEventID) } func (s *engineSuite) TestRespondActivityTaskCanceledIfNoRunID() { @@ -3891,8 +3891,8 @@ func (s *engineSuite) TestRequestCancel_RespondWorkflowTaskCompleted_NotSchedule msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) commands := []*commandpb.Command{{ CommandType: enumspb.COMMAND_TYPE_REQUEST_CANCEL_ACTIVITY_TASK, @@ -3955,9 +3955,9 @@ func (s *engineSuite) TestRequestCancel_RespondWorkflowTaskCompleted_Scheduled() msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) _, aInfo := addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 1*time.Second) di2 := addWorkflowTaskScheduledEvent(msBuilder) addWorkflowTaskStartedEvent(msBuilder, di2.ScheduledEventID, tl, identity) @@ -4019,9 +4019,9 @@ func (s *engineSuite) TestRequestCancel_RespondWorkflowTaskCompleted_Started() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) activityScheduledEvent, _ := addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 0*time.Second) addActivityTaskStartedEvent(msBuilder, activityScheduledEvent.EventId, identity) di2 := addWorkflowTaskScheduledEvent(msBuilder) @@ -4081,9 +4081,9 @@ func (s *engineSuite) TestRequestCancel_RespondWorkflowTaskCompleted_Completed() msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) _, aInfo := addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 0*time.Second) di2 := addWorkflowTaskScheduledEvent(msBuilder) addWorkflowTaskStartedEvent(msBuilder, di2.ScheduledEventID, tl, identity) @@ -4148,9 +4148,9 @@ func (s *engineSuite) TestRequestCancel_RespondWorkflowTaskCompleted_NoHeartBeat msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) activityScheduledEvent, _ := addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 0*time.Second) addActivityTaskStartedEvent(msBuilder, activityScheduledEvent.EventId, identity) di2 := addWorkflowTaskScheduledEvent(msBuilder) @@ -4252,9 +4252,9 @@ func (s *engineSuite) TestRequestCancel_RespondWorkflowTaskCompleted_Success() { msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) activityScheduledEvent, _ := addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 1*time.Second) addActivityTaskStartedEvent(msBuilder, activityScheduledEvent.EventId, identity) di2 := addWorkflowTaskScheduledEvent(msBuilder) @@ -4356,9 +4356,9 @@ func (s *engineSuite) TestRequestCancel_RespondWorkflowTaskCompleted_SuccessWith msBuilder := workflow.TestLocalMutableState(s.mockHistoryEngine.shard, s.eventsCache, tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) activityScheduledEvent, _ := addActivityTaskScheduledEvent(msBuilder, workflowTaskCompletedEvent.EventId, activityID, activityType, tl, activityInput, 100*time.Second, 10*time.Second, 1*time.Second, 1*time.Second) addActivityTaskStartedEvent(msBuilder, activityScheduledEvent.EventId, identity) di2 := addWorkflowTaskScheduledEvent(msBuilder) @@ -4505,8 +4505,8 @@ func (s *engineSuite) TestStarTimer_DuplicateTimerID() { tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) ms := workflow.TestCloneToProto(msBuilder) gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} @@ -4607,9 +4607,9 @@ func (s *engineSuite) TestUserTimer_RespondWorkflowTaskCompleted() { tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) // Verify cancel timer with a start event. addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) addTimerStartedEvent(msBuilder, workflowTaskCompletedEvent.EventId, timerID, 10*time.Second) di2 := addWorkflowTaskScheduledEvent(msBuilder) addWorkflowTaskStartedEvent(msBuilder, di2.ScheduledEventID, tl, identity) @@ -4666,8 +4666,8 @@ func (s *engineSuite) TestCancelTimer_RespondWorkflowTaskCompleted_NoStartTimer( tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) // Verify cancel timer with a start event. addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) ms := workflow.TestCloneToProto(msBuilder) gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} @@ -4731,9 +4731,9 @@ func (s *engineSuite) TestCancelTimer_RespondWorkflowTaskCompleted_TimerFired() tests.LocalNamespaceEntry, log.NewTestLogger(), we.GetRunId()) // Verify cancel timer with a start event. addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, payloads.EncodeString("input"), 100*time.Second, 100*time.Second, 100*time.Second, identity) - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, tl, identity) - workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTaskStartedEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, tl, identity) + workflowTaskCompletedEvent := addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, workflowTaskStartedEvent.EventId, identity) addTimerStartedEvent(msBuilder, workflowTaskCompletedEvent.EventId, timerID, 10*time.Second) di2 := addWorkflowTaskScheduledEvent(msBuilder) addWorkflowTaskStartedEvent(msBuilder, di2.ScheduledEventID, tl, identity) @@ -5233,8 +5233,8 @@ func addWorkflowExecutionStartedEvent(builder workflow.MutableState, workflowExe } func addWorkflowTaskScheduledEvent(builder workflow.MutableState) *workflow.WorkflowTaskInfo { - di, _ := builder.AddWorkflowTaskScheduledEvent(false) - return di + workflowTask, _ := builder.AddWorkflowTaskScheduledEvent(false) + return workflowTask } func addWorkflowTaskStartedEvent(builder workflow.MutableState, scheduledEventID int64, taskQueue, diff --git a/service/history/timerQueueActiveTaskExecutor_test.go b/service/history/timerQueueActiveTaskExecutor_test.go index f0370b8ff12..371d491bcf8 100644 --- a/service/history/timerQueueActiveTaskExecutor_test.go +++ b/service/history/timerQueueActiveTaskExecutor_test.go @@ -238,10 +238,10 @@ func (s *timerQueueActiveTaskExecutorSuite) TestProcessUserTimerTimeout_Fire() { ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") timerID := "timer" timerTimeout := 2 * time.Second @@ -309,10 +309,10 @@ func (s *timerQueueActiveTaskExecutorSuite) TestProcessUserTimerTimeout_Noop() { ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") timerID := "timer" timerTimeout := 2 * time.Second @@ -374,10 +374,10 @@ func (s *timerQueueActiveTaskExecutorSuite) TestProcessActivityTimeout_NoRetryPo ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskqueue := "taskqueue" activityID := "activity" @@ -414,7 +414,7 @@ func (s *timerQueueActiveTaskExecutorSuite) TestProcessActivityTimeout_NoRetryPo TaskID: int64(100), TimeoutType: enumspb.TIMEOUT_TYPE_SCHEDULE_TO_CLOSE, VisibilityTimestamp: task.(*tasks.ActivityTimeoutTask).VisibilityTimestamp, - EventID: di.ScheduledEventID, + EventID: wt.ScheduledEventID, } persistenceMutableState := s.createPersistenceMutableState(mutableState, scheduledEvent.GetEventId(), scheduledEvent.GetVersion()) @@ -454,10 +454,10 @@ func (s *timerQueueActiveTaskExecutorSuite) TestProcessActivityTimeout_NoRetryPo ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") identity := "identity" taskqueue := "taskqueue" @@ -496,7 +496,7 @@ func (s *timerQueueActiveTaskExecutorSuite) TestProcessActivityTimeout_NoRetryPo TaskID: int64(100), TimeoutType: enumspb.TIMEOUT_TYPE_SCHEDULE_TO_CLOSE, VisibilityTimestamp: task.(*tasks.ActivityTimeoutTask).VisibilityTimestamp, - EventID: di.ScheduledEventID, + EventID: wt.ScheduledEventID, } completeEvent := addActivityTaskCompletedEvent(mutableState, scheduledEvent.GetEventId(), startedEvent.GetEventId(), nil, identity) @@ -536,10 +536,10 @@ func (s *timerQueueActiveTaskExecutorSuite) TestProcessActivityTimeout_RetryPoli ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") identity := "identity" taskqueue := "taskqueue" @@ -586,7 +586,7 @@ func (s *timerQueueActiveTaskExecutorSuite) TestProcessActivityTimeout_RetryPoli TaskID: int64(100), TimeoutType: enumspb.TIMEOUT_TYPE_SCHEDULE_TO_CLOSE, VisibilityTimestamp: task.(*tasks.ActivityTimeoutTask).VisibilityTimestamp, - EventID: di.ScheduledEventID, + EventID: wt.ScheduledEventID, } persistenceMutableState := s.createPersistenceMutableState(mutableState, scheduledEvent.GetEventId(), scheduledEvent.GetVersion()) @@ -630,10 +630,10 @@ func (s *timerQueueActiveTaskExecutorSuite) TestProcessActivityTimeout_RetryPoli ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskqueue := "taskqueue" activityID := "activity" @@ -677,7 +677,7 @@ func (s *timerQueueActiveTaskExecutorSuite) TestProcessActivityTimeout_RetryPoli TaskID: int64(100), TimeoutType: enumspb.TIMEOUT_TYPE_SCHEDULE_TO_CLOSE, VisibilityTimestamp: task.(*tasks.ActivityTimeoutTask).VisibilityTimestamp, - EventID: di.ScheduledEventID, + EventID: wt.ScheduledEventID, } persistenceMutableState := s.createPersistenceMutableState(mutableState, scheduledEvent.GetEventId(), scheduledEvent.GetVersion()) @@ -716,10 +716,10 @@ func (s *timerQueueActiveTaskExecutorSuite) TestProcessActivityTimeout_RetryPoli ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") identity := "identity" taskqueue := "taskqueue" @@ -766,7 +766,7 @@ func (s *timerQueueActiveTaskExecutorSuite) TestProcessActivityTimeout_RetryPoli TaskID: int64(100), TimeoutType: enumspb.TIMEOUT_TYPE_SCHEDULE_TO_CLOSE, VisibilityTimestamp: task.(*tasks.ActivityTimeoutTask).VisibilityTimestamp, - EventID: di.ScheduledEventID, + EventID: wt.ScheduledEventID, } completeEvent := addActivityTaskCompletedEvent(mutableState, scheduledEvent.GetEventId(), common.TransientEventID, nil, identity) @@ -805,10 +805,10 @@ func (s *timerQueueActiveTaskExecutorSuite) TestProcessActivityTimeout_Heartbeat ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") identity := "identity" taskqueue := "taskqueue" @@ -892,8 +892,8 @@ func (s *timerQueueActiveTaskExecutorSuite) TestWorkflowTaskTimeout_Fire() { ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - startedEvent := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) + wt := addWorkflowTaskScheduledEvent(mutableState) + startedEvent := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) timerTask := &tasks.WorkflowTaskTimeoutTask{ WorkflowKey: definition.NewWorkflowKey( @@ -906,7 +906,7 @@ func (s *timerQueueActiveTaskExecutorSuite) TestWorkflowTaskTimeout_Fire() { TaskID: int64(100), TimeoutType: enumspb.TIMEOUT_TYPE_START_TO_CLOSE, VisibilityTimestamp: s.now, - EventID: di.ScheduledEventID, + EventID: wt.ScheduledEventID, } persistenceMutableState := s.createPersistenceMutableState(mutableState, startedEvent.GetEventId(), startedEvent.GetVersion()) @@ -948,8 +948,8 @@ func (s *timerQueueActiveTaskExecutorSuite) TestWorkflowTaskTimeout_Noop() { ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - startedEvent := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) + wt := addWorkflowTaskScheduledEvent(mutableState) + startedEvent := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) timerTask := &tasks.WorkflowTaskTimeoutTask{ WorkflowKey: definition.NewWorkflowKey( @@ -962,7 +962,7 @@ func (s *timerQueueActiveTaskExecutorSuite) TestWorkflowTaskTimeout_Noop() { TaskID: int64(100), TimeoutType: enumspb.TIMEOUT_TYPE_START_TO_CLOSE, VisibilityTimestamp: s.now, - EventID: di.ScheduledEventID - 1, + EventID: wt.ScheduledEventID - 1, } persistenceMutableState := s.createPersistenceMutableState(mutableState, startedEvent.GetEventId(), startedEvent.GetVersion()) @@ -1048,10 +1048,10 @@ func (s *timerQueueActiveTaskExecutorSuite) TestWorkflowBackoffTimer_Noop() { ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") timerTask := &tasks.WorkflowBackoffTimerTask{ WorkflowKey: definition.NewWorkflowKey( @@ -1100,10 +1100,10 @@ func (s *timerQueueActiveTaskExecutorSuite) TestActivityRetryTimer_Fire() { ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskqueue := "taskqueue" activityID := "activity" @@ -1191,10 +1191,10 @@ func (s *timerQueueActiveTaskExecutorSuite) TestActivityRetryTimer_Noop() { ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") identity := "identity" taskqueue := "taskqueue" @@ -1269,10 +1269,10 @@ func (s *timerQueueActiveTaskExecutorSuite) TestWorkflowTimeout_Fire() { ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - startEvent := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = startEvent.GetEventId() - completionEvent := addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + startEvent := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = startEvent.GetEventId() + completionEvent := addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") timerTask := &tasks.WorkflowTimeoutTask{ WorkflowKey: definition.NewWorkflowKey( @@ -1330,10 +1330,10 @@ func (s *timerQueueActiveTaskExecutorSuite) TestWorkflowTimeout_Retry() { executionInfo.RetryMaximumInterval = timestamp.DurationFromSeconds(1) executionInfo.RetryBackoffCoefficient = 1 - di := addWorkflowTaskScheduledEvent(mutableState) - startEvent := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = startEvent.GetEventId() - completionEvent := addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + startEvent := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = startEvent.GetEventId() + completionEvent := addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") timerTask := &tasks.WorkflowTimeoutTask{ WorkflowKey: definition.NewWorkflowKey( @@ -1388,10 +1388,10 @@ func (s *timerQueueActiveTaskExecutorSuite) TestWorkflowTimeout_Cron() { executionInfo.StartTime = &s.now executionInfo.CronSchedule = "* * * * *" - di := addWorkflowTaskScheduledEvent(mutableState) - startEvent := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = startEvent.GetEventId() - completionEvent := addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + startEvent := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = startEvent.GetEventId() + completionEvent := addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") timerTask := &tasks.WorkflowTimeoutTask{ WorkflowKey: definition.NewWorkflowKey( @@ -1445,10 +1445,10 @@ func (s *timerQueueActiveTaskExecutorSuite) TestWorkflowTimeout_WorkflowExpired( executionInfo.StartTime = &s.now executionInfo.CronSchedule = "* * * * *" - di := addWorkflowTaskScheduledEvent(mutableState) - startEvent := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = startEvent.GetEventId() - completionEvent := addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + startEvent := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = startEvent.GetEventId() + completionEvent := addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") timerTask := &tasks.WorkflowTimeoutTask{ WorkflowKey: definition.NewWorkflowKey( diff --git a/service/history/timerQueueStandbyTaskExecutor_test.go b/service/history/timerQueueStandbyTaskExecutor_test.go index 6f01da61b6d..b57a73904e2 100644 --- a/service/history/timerQueueStandbyTaskExecutor_test.go +++ b/service/history/timerQueueStandbyTaskExecutor_test.go @@ -233,10 +233,10 @@ func (s *timerQueueStandbyTaskExecutorSuite) TestProcessUserTimerTimeout_Pending ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") timerID := "timer" timerTimeout := 2 * time.Second @@ -325,10 +325,10 @@ func (s *timerQueueStandbyTaskExecutorSuite) TestProcessUserTimerTimeout_Success ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") timerID := "timer" timerTimeout := 2 * time.Second @@ -390,10 +390,10 @@ func (s *timerQueueStandbyTaskExecutorSuite) TestProcessUserTimerTimeout_Multipl ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") timerID1 := "timer-1" timerTimeout1 := 2 * time.Second @@ -459,10 +459,10 @@ func (s *timerQueueStandbyTaskExecutorSuite) TestProcessActivityTimeout_Pending( ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskqueue := "taskqueue" activityID := "activity" @@ -552,10 +552,10 @@ func (s *timerQueueStandbyTaskExecutorSuite) TestProcessActivityTimeout_Success( ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") identity := "identity" taskqueue := "taskqueue" @@ -623,10 +623,10 @@ func (s *timerQueueStandbyTaskExecutorSuite) TestProcessActivityTimeout_Heartbea ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") identity := "identity" taskqueue := "taskqueue" @@ -695,10 +695,10 @@ func (s *timerQueueStandbyTaskExecutorSuite) TestProcessActivityTimeout_Multiple ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") identity := "identity" taskqueue := "taskqueue" @@ -819,8 +819,8 @@ func (s *timerQueueStandbyTaskExecutorSuite) TestProcessWorkflowTaskTimeout_Pend ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - startedEvent := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) + wt := addWorkflowTaskScheduledEvent(mutableState) + startedEvent := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) // Flush buffered events so real IDs get assigned mutableState.FlushBufferedEvents() nextEventID := startedEvent.GetEventId() @@ -836,7 +836,7 @@ func (s *timerQueueStandbyTaskExecutorSuite) TestProcessWorkflowTaskTimeout_Pend TaskID: int64(100), TimeoutType: enumspb.TIMEOUT_TYPE_START_TO_CLOSE, VisibilityTimestamp: s.now, - EventID: di.ScheduledEventID, + EventID: wt.ScheduledEventID, } persistenceMutableState := s.createPersistenceMutableState(mutableState, startedEvent.GetEventId(), startedEvent.GetVersion()) @@ -926,10 +926,10 @@ func (s *timerQueueStandbyTaskExecutorSuite) TestProcessWorkflowTaskTimeout_Succ ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") // Flush buffered events so real IDs get assigned mutableState.FlushBufferedEvents() @@ -944,7 +944,7 @@ func (s *timerQueueStandbyTaskExecutorSuite) TestProcessWorkflowTaskTimeout_Succ TaskID: int64(100), TimeoutType: enumspb.TIMEOUT_TYPE_START_TO_CLOSE, VisibilityTimestamp: s.now, - EventID: di.ScheduledEventID, + EventID: wt.ScheduledEventID, } persistenceMutableState := s.createPersistenceMutableState(mutableState, event.GetEventId(), event.GetVersion()) @@ -1055,7 +1055,7 @@ func (s *timerQueueStandbyTaskExecutorSuite) TestProcessWorkflowBackoffTimer_Suc ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) + wt := addWorkflowTaskScheduledEvent(mutableState) // Flush buffered events so real IDs get assigned mutableState.FlushBufferedEvents() @@ -1071,7 +1071,7 @@ func (s *timerQueueStandbyTaskExecutorSuite) TestProcessWorkflowBackoffTimer_Suc WorkflowBackoffType: enumsspb.WORKFLOW_BACKOFF_TYPE_CRON, } - persistenceMutableState := s.createPersistenceMutableState(mutableState, di.ScheduledEventID, di.Version) + persistenceMutableState := s.createPersistenceMutableState(mutableState, wt.ScheduledEventID, wt.Version) s.mockExecutionMgr.EXPECT().GetWorkflowExecution(gomock.Any(), gomock.Any()).Return(&persistence.GetWorkflowExecutionResponse{State: persistenceMutableState}, nil) s.mockShard.SetCurrentTime(s.clusterName, s.now) @@ -1104,10 +1104,10 @@ func (s *timerQueueStandbyTaskExecutorSuite) TestProcessWorkflowTimeout_Pending( ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - startEvent := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = startEvent.GetEventId() - completionEvent := addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + startEvent := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = startEvent.GetEventId() + completionEvent := addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") // Flush buffered events so real IDs get assigned mutableState.FlushBufferedEvents() nextEventID := completionEvent.GetEventId() @@ -1182,10 +1182,10 @@ func (s *timerQueueStandbyTaskExecutorSuite) TestProcessWorkflowTimeout_Success( ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") event = addCompleteWorkflowEvent(mutableState, event.GetEventId(), nil) // Flush buffered events so real IDs get assigned mutableState.FlushBufferedEvents() @@ -1277,10 +1277,10 @@ func (s *timerQueueStandbyTaskExecutorSuite) TestProcessActivityRetryTimer_Noop( ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") identity := "identity" taskqueue := "taskqueue" @@ -1376,10 +1376,10 @@ func (s *timerQueueStandbyTaskExecutorSuite) TestProcessActivityRetryTimer_Activ ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") identity := "identity" taskqueue := "taskqueue" @@ -1446,10 +1446,10 @@ func (s *timerQueueStandbyTaskExecutorSuite) TestProcessActivityRetryTimer_Pendi ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskqueue := "taskqueue" activityID := "activity" diff --git a/service/history/transferQueueActiveTaskExecutor_test.go b/service/history/transferQueueActiveTaskExecutor_test.go index 12f10c2f26c..823fba2d1bf 100644 --- a/service/history/transferQueueActiveTaskExecutor_test.go +++ b/service/history/transferQueueActiveTaskExecutor_test.go @@ -270,10 +270,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessActivityTask_Success() ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) activityID := "activity-1" @@ -326,10 +326,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessActivityTask_Duplicati ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) activityID := "activity-1" @@ -391,7 +391,7 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessWorkflowTask_FirstWork s.Nil(err) taskID := int64(59) - di := addWorkflowTaskScheduledEvent(mutableState) + wt := addWorkflowTaskScheduledEvent(mutableState) transferTask := &tasks.WorkflowTask{ WorkflowKey: definition.NewWorkflowKey( @@ -402,11 +402,11 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessWorkflowTask_FirstWork Version: s.version, TaskID: taskID, TaskQueue: taskQueueName, - ScheduledEventID: di.ScheduledEventID, + ScheduledEventID: wt.ScheduledEventID, VisibilityTimestamp: time.Now().UTC(), } - persistenceMutableState := s.createPersistenceMutableState(mutableState, di.ScheduledEventID, di.Version) + persistenceMutableState := s.createPersistenceMutableState(mutableState, wt.ScheduledEventID, wt.Version) s.mockExecutionMgr.EXPECT().GetWorkflowExecution(gomock.Any(), gomock.Any()).Return(&persistence.GetWorkflowExecutionResponse{State: persistenceMutableState}, nil) s.mockMatchingClient.EXPECT().AddWorkflowTask(gomock.Any(), s.createAddWorkflowTaskRequest(transferTask, mutableState), gomock.Any()).Return(&matchingservice.AddWorkflowTaskResponse{}, nil) @@ -442,15 +442,15 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessWorkflowTask_NonFirstW ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") s.NotNil(event) // make another round of workflow task taskID := int64(59) - di = addWorkflowTaskScheduledEvent(mutableState) + wt = addWorkflowTaskScheduledEvent(mutableState) transferTask := &tasks.WorkflowTask{ WorkflowKey: definition.NewWorkflowKey( @@ -461,11 +461,11 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessWorkflowTask_NonFirstW Version: s.version, TaskID: taskID, TaskQueue: taskQueueName, - ScheduledEventID: di.ScheduledEventID, + ScheduledEventID: wt.ScheduledEventID, VisibilityTimestamp: time.Now().UTC(), } - persistenceMutableState := s.createPersistenceMutableState(mutableState, di.ScheduledEventID, di.Version) + persistenceMutableState := s.createPersistenceMutableState(mutableState, wt.ScheduledEventID, wt.Version) s.mockExecutionMgr.EXPECT().GetWorkflowExecution(gomock.Any(), gomock.Any()).Return(&persistence.GetWorkflowExecutionResponse{State: persistenceMutableState}, nil) s.mockMatchingClient.EXPECT().AddWorkflowTask(gomock.Any(), s.createAddWorkflowTaskRequest(transferTask, mutableState), gomock.Any()).Return(&matchingservice.AddWorkflowTaskResponse{}, nil) @@ -500,10 +500,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessWorkflowTask_Sticky_No ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") s.NotNil(event) // set the sticky taskqueue attr executionInfo := mutableState.GetExecutionInfo() @@ -512,7 +512,7 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessWorkflowTask_Sticky_No // make another round of workflow task taskID := int64(59) - di = addWorkflowTaskScheduledEvent(mutableState) + wt = addWorkflowTaskScheduledEvent(mutableState) transferTask := &tasks.WorkflowTask{ WorkflowKey: definition.NewWorkflowKey( @@ -523,11 +523,11 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessWorkflowTask_Sticky_No Version: s.version, TaskID: taskID, TaskQueue: stickyTaskQueueName, - ScheduledEventID: di.ScheduledEventID, + ScheduledEventID: wt.ScheduledEventID, VisibilityTimestamp: time.Now().UTC(), } - persistenceMutableState := s.createPersistenceMutableState(mutableState, di.ScheduledEventID, di.Version) + persistenceMutableState := s.createPersistenceMutableState(mutableState, wt.ScheduledEventID, wt.Version) s.mockExecutionMgr.EXPECT().GetWorkflowExecution(gomock.Any(), gomock.Any()).Return(&persistence.GetWorkflowExecutionResponse{State: persistenceMutableState}, nil) s.mockMatchingClient.EXPECT().AddWorkflowTask(gomock.Any(), s.createAddWorkflowTaskRequest(transferTask, mutableState), gomock.Any()).Return(&matchingservice.AddWorkflowTaskResponse{}, nil) @@ -565,10 +565,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessWorkflowTask_WorkflowT ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") s.NotNil(event) // set the sticky taskqueue attr executionInfo := mutableState.GetExecutionInfo() @@ -577,7 +577,7 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessWorkflowTask_WorkflowT // make another round of workflow task taskID := int64(59) - di = addWorkflowTaskScheduledEvent(mutableState) + wt = addWorkflowTaskScheduledEvent(mutableState) transferTask := &tasks.WorkflowTask{ WorkflowKey: definition.NewWorkflowKey( @@ -588,11 +588,11 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessWorkflowTask_WorkflowT Version: s.version, TaskID: taskID, TaskQueue: taskQueueName, - ScheduledEventID: di.ScheduledEventID, + ScheduledEventID: wt.ScheduledEventID, VisibilityTimestamp: time.Now().UTC(), } - persistenceMutableState := s.createPersistenceMutableState(mutableState, di.ScheduledEventID, di.Version) + persistenceMutableState := s.createPersistenceMutableState(mutableState, wt.ScheduledEventID, wt.Version) s.mockExecutionMgr.EXPECT().GetWorkflowExecution(gomock.Any(), gomock.Any()).Return(&persistence.GetWorkflowExecutionResponse{State: persistenceMutableState}, nil) s.mockMatchingClient.EXPECT().AddWorkflowTask(gomock.Any(), s.createAddWorkflowTaskRequest(transferTask, mutableState), gomock.Any()).Return(&matchingservice.AddWorkflowTaskResponse{}, nil) @@ -626,10 +626,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessWorkflowTask_Duplicati s.Nil(err) taskID := int64(4096) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") transferTask := &tasks.WorkflowTask{ WorkflowKey: definition.NewWorkflowKey( @@ -640,7 +640,7 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessWorkflowTask_Duplicati Version: s.version, TaskID: taskID, TaskQueue: taskQueueName, - ScheduledEventID: di.ScheduledEventID, + ScheduledEventID: wt.ScheduledEventID, VisibilityTimestamp: time.Now().UTC(), } @@ -694,10 +694,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessCloseExecution_HasPare ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) event = addCompleteWorkflowEvent(mutableState, event.GetEventId(), nil) @@ -755,10 +755,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessCloseExecution_NoParen ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) event = addCompleteWorkflowEvent(mutableState, event.GetEventId(), nil) @@ -812,20 +812,20 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessCloseExecution_NoParen ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() - dt := enumspb.COMMAND_TYPE_START_CHILD_WORKFLOW_EXECUTION + commandType := enumspb.COMMAND_TYPE_START_CHILD_WORKFLOW_EXECUTION parentClosePolicy1 := enumspb.PARENT_CLOSE_POLICY_ABANDON parentClosePolicy2 := enumspb.PARENT_CLOSE_POLICY_TERMINATE parentClosePolicy3 := enumspb.PARENT_CLOSE_POLICY_REQUEST_CANCEL - event, _ = mutableState.AddWorkflowTaskCompletedEvent(di.ScheduledEventID, di.StartedEventID, &workflowservice.RespondWorkflowTaskCompletedRequest{ + event, _ = mutableState.AddWorkflowTaskCompletedEvent(wt.ScheduledEventID, wt.StartedEventID, &workflowservice.RespondWorkflowTaskCompletedRequest{ Identity: "some random identity", Commands: []*commandpb.Command{ { - CommandType: dt, + CommandType: commandType, Attributes: &commandpb.Command_StartChildWorkflowExecutionCommandAttributes{StartChildWorkflowExecutionCommandAttributes: &commandpb.StartChildWorkflowExecutionCommandAttributes{ Namespace: "child namespace1", WorkflowId: "child workflow1", @@ -838,7 +838,7 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessCloseExecution_NoParen }}, }, { - CommandType: dt, + CommandType: commandType, Attributes: &commandpb.Command_StartChildWorkflowExecutionCommandAttributes{StartChildWorkflowExecutionCommandAttributes: &commandpb.StartChildWorkflowExecutionCommandAttributes{ Namespace: "child namespace2", WorkflowId: "child workflow2", @@ -851,7 +851,7 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessCloseExecution_NoParen }}, }, { - CommandType: dt, + CommandType: commandType, Attributes: &commandpb.Command_StartChildWorkflowExecutionCommandAttributes{StartChildWorkflowExecutionCommandAttributes: &commandpb.StartChildWorkflowExecutionCommandAttributes{ Namespace: "child namespace3", WorkflowId: "child workflow3", @@ -965,16 +965,16 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessCloseExecution_NoParen ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() - dt := enumspb.COMMAND_TYPE_START_CHILD_WORKFLOW_EXECUTION + commandType := enumspb.COMMAND_TYPE_START_CHILD_WORKFLOW_EXECUTION parentClosePolicy := enumspb.PARENT_CLOSE_POLICY_TERMINATE var commands []*commandpb.Command for i := 0; i < 10; i++ { commands = append(commands, &commandpb.Command{ - CommandType: dt, + CommandType: commandType, Attributes: &commandpb.Command_StartChildWorkflowExecutionCommandAttributes{StartChildWorkflowExecutionCommandAttributes: &commandpb.StartChildWorkflowExecutionCommandAttributes{ WorkflowId: "child workflow" + convert.IntToString(i), WorkflowType: &commonpb.WorkflowType{ @@ -987,7 +987,7 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessCloseExecution_NoParen }) } - event, _ = mutableState.AddWorkflowTaskCompletedEvent(di.ScheduledEventID, di.StartedEventID, &workflowservice.RespondWorkflowTaskCompletedRequest{ + event, _ = mutableState.AddWorkflowTaskCompletedEvent(wt.ScheduledEventID, wt.StartedEventID, &workflowservice.RespondWorkflowTaskCompletedRequest{ Identity: "some random identity", Commands: commands, }, configs.DefaultHistoryMaxAutoResetPoints) @@ -1060,16 +1060,16 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessCloseExecution_NoParen ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() - dt := enumspb.COMMAND_TYPE_START_CHILD_WORKFLOW_EXECUTION + commandType := enumspb.COMMAND_TYPE_START_CHILD_WORKFLOW_EXECUTION parentClosePolicy := enumspb.PARENT_CLOSE_POLICY_ABANDON var commands []*commandpb.Command for i := 0; i < 10; i++ { commands = append(commands, &commandpb.Command{ - CommandType: dt, + CommandType: commandType, Attributes: &commandpb.Command_StartChildWorkflowExecutionCommandAttributes{StartChildWorkflowExecutionCommandAttributes: &commandpb.StartChildWorkflowExecutionCommandAttributes{ WorkflowId: "child workflow" + convert.IntToString(i), WorkflowType: &commonpb.WorkflowType{ @@ -1082,7 +1082,7 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessCloseExecution_NoParen }) } - event, _ = mutableState.AddWorkflowTaskCompletedEvent(di.ScheduledEventID, di.StartedEventID, &workflowservice.RespondWorkflowTaskCompletedRequest{ + event, _ = mutableState.AddWorkflowTaskCompletedEvent(wt.ScheduledEventID, wt.StartedEventID, &workflowservice.RespondWorkflowTaskCompletedRequest{ Identity: "some random identity", Commands: commands, }, configs.DefaultHistoryMaxAutoResetPoints) @@ -1282,10 +1282,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessCancelExecution_Succes ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) event, rci := addRequestCancelInitiatedEvent(mutableState, event.GetEventId(), uuid.New(), tests.TargetNamespace, tests.TargetNamespaceID, targetExecution.GetWorkflowId(), targetExecution.GetRunId()) @@ -1346,10 +1346,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessCancelExecution_Failur ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) event, rci := addRequestCancelInitiatedEvent(mutableState, event.GetEventId(), uuid.New(), tests.TargetNamespace, tests.TargetNamespaceID, targetExecution.GetWorkflowId(), targetExecution.GetRunId()) @@ -1410,10 +1410,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessCancelExecution_Failur ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) event, _ = addRequestCancelInitiatedEvent(mutableState, event.GetEventId(), uuid.New(), tests.TargetNamespace, tests.TargetNamespaceID, targetExecution.GetWorkflowId(), targetExecution.GetRunId()) @@ -1472,10 +1472,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessCancelExecution_Duplic ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) event, _ = addRequestCancelInitiatedEvent(mutableState, event.GetEventId(), uuid.New(), tests.TargetNamespace, tests.TargetNamespaceID, targetExecution.GetWorkflowId(), targetExecution.GetRunId()) @@ -1542,10 +1542,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessSignalExecution_Succes ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) event, si := addRequestSignalInitiatedEvent(mutableState, event.GetEventId(), uuid.New(), @@ -1623,10 +1623,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessSignalExecution_Failur ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) event, si := addRequestSignalInitiatedEvent(mutableState, event.GetEventId(), uuid.New(), @@ -1695,10 +1695,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessSignalExecution_Failur ) s.NoError(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) event, _ = addRequestSignalInitiatedEvent(mutableState, event.GetEventId(), uuid.New(), @@ -1765,10 +1765,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessSignalExecution_Duplic ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) event, _ = addRequestSignalInitiatedEvent(mutableState, event.GetEventId(), uuid.New(), @@ -1831,10 +1831,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessStartChildExecution_Su ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) @@ -1922,10 +1922,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessStartChildExecution_Fa ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) @@ -2005,10 +2005,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessStartChildExecution_Fa ) s.NoError(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) @@ -2081,10 +2081,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessStartChildExecution_Su ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) @@ -2171,10 +2171,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessStartChildExecution_Du ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) @@ -2255,10 +2255,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessorStartChildExecution_ ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) @@ -2294,10 +2294,10 @@ func (s *transferQueueActiveTaskExecutorSuite) TestProcessorStartChildExecution_ childClock := vclock.NewVectorClock(rand.Int63(), rand.Int31(), rand.Int63()) event = addChildWorkflowExecutionStartedEvent(mutableState, event.GetEventId(), childExecution.GetWorkflowId(), childExecution.GetRunId(), childWorkflowType, childClock) ci.StartedEventId = event.GetEventId() - di = addWorkflowTaskScheduledEvent(mutableState) - event = addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, "some random identity") - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt = addWorkflowTaskScheduledEvent(mutableState) + event = addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, "some random identity") + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") event = addCompleteWorkflowEvent(mutableState, event.EventId, nil) // Flush buffered events so real IDs get assigned mutableState.FlushBufferedEvents() diff --git a/service/history/transferQueueStandbyTaskExecutor_test.go b/service/history/transferQueueStandbyTaskExecutor_test.go index 389bbabdc5a..b19b62b0c6e 100644 --- a/service/history/transferQueueStandbyTaskExecutor_test.go +++ b/service/history/transferQueueStandbyTaskExecutor_test.go @@ -234,10 +234,10 @@ func (s *transferQueueStandbyTaskExecutorSuite) TestProcessActivityTask_Pending( ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) activityID := "activity-1" @@ -324,10 +324,10 @@ func (s *transferQueueStandbyTaskExecutorSuite) TestProcessActivityTask_Success( ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) activityID := "activity-1" @@ -386,7 +386,7 @@ func (s *transferQueueStandbyTaskExecutorSuite) TestProcessWorkflowTask_Pending( s.Nil(err) taskID := int64(59) - di := addWorkflowTaskScheduledEvent(mutableState) + wt := addWorkflowTaskScheduledEvent(mutableState) now := time.Now().UTC() transferTask := &tasks.WorkflowTask{ @@ -399,10 +399,10 @@ func (s *transferQueueStandbyTaskExecutorSuite) TestProcessWorkflowTask_Pending( VisibilityTimestamp: now, TaskID: taskID, TaskQueue: taskQueueName, - ScheduledEventID: di.ScheduledEventID, + ScheduledEventID: wt.ScheduledEventID, } - persistenceMutableState := s.createPersistenceMutableState(mutableState, di.ScheduledEventID, di.Version) + persistenceMutableState := s.createPersistenceMutableState(mutableState, wt.ScheduledEventID, wt.Version) s.mockExecutionMgr.EXPECT().GetWorkflowExecution(gomock.Any(), gomock.Any()).Return(&persistence.GetWorkflowExecutionResponse{State: persistenceMutableState}, nil) // no-op post action @@ -425,7 +425,7 @@ func (s *transferQueueStandbyTaskExecutorSuite) TestProcessWorkflowTask_Pending( namespace.ID(transferTask.NamespaceID), transferTask.WorkflowID, transferTask.RunID, - di.ScheduledEventID, + wt.ScheduledEventID, s.version, int64(0), int64(0), @@ -466,7 +466,7 @@ func (s *transferQueueStandbyTaskExecutorSuite) TestProcessWorkflowTask_Success_ s.Nil(err) taskID := int64(59) - di := addWorkflowTaskScheduledEvent(mutableState) + wt := addWorkflowTaskScheduledEvent(mutableState) now := time.Now().UTC() transferTask := &tasks.WorkflowTask{ @@ -479,11 +479,11 @@ func (s *transferQueueStandbyTaskExecutorSuite) TestProcessWorkflowTask_Success_ VisibilityTimestamp: now, TaskID: taskID, TaskQueue: taskQueueName, - ScheduledEventID: di.ScheduledEventID, + ScheduledEventID: wt.ScheduledEventID, } - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() persistenceMutableState := s.createPersistenceMutableState(mutableState, event.GetEventId(), event.GetVersion()) s.mockExecutionMgr.EXPECT().GetWorkflowExecution(gomock.Any(), gomock.Any()).Return(&persistence.GetWorkflowExecutionResponse{State: persistenceMutableState}, nil) @@ -518,13 +518,13 @@ func (s *transferQueueStandbyTaskExecutorSuite) TestProcessWorkflowTask_Success_ ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) - di = addWorkflowTaskScheduledEvent(mutableState) + wt = addWorkflowTaskScheduledEvent(mutableState) now := time.Now().UTC() transferTask := &tasks.WorkflowTask{ @@ -537,11 +537,11 @@ func (s *transferQueueStandbyTaskExecutorSuite) TestProcessWorkflowTask_Success_ VisibilityTimestamp: now, TaskID: taskID, TaskQueue: taskQueueName, - ScheduledEventID: di.ScheduledEventID, + ScheduledEventID: wt.ScheduledEventID, } - event = addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() + event = addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() persistenceMutableState := s.createPersistenceMutableState(mutableState, event.GetEventId(), event.GetVersion()) s.mockExecutionMgr.EXPECT().GetWorkflowExecution(gomock.Any(), gomock.Any()).Return(&persistence.GetWorkflowExecutionResponse{State: persistenceMutableState}, nil) @@ -594,10 +594,10 @@ func (s *transferQueueStandbyTaskExecutorSuite) TestProcessCloseExecution() { ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) event = addCompleteWorkflowEvent(mutableState, event.GetEventId(), nil) @@ -687,10 +687,10 @@ func (s *transferQueueStandbyTaskExecutorSuite) TestProcessCancelExecution_Pendi ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) event, _ = addRequestCancelInitiatedEvent(mutableState, event.GetEventId(), uuid.New(), tests.TargetNamespace, tests.TargetNamespaceID, targetExecution.GetWorkflowId(), targetExecution.GetRunId()) @@ -777,10 +777,10 @@ func (s *transferQueueStandbyTaskExecutorSuite) TestProcessCancelExecution_Succe ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) event, _ = addRequestCancelInitiatedEvent(mutableState, event.GetEventId(), uuid.New(), tests.TargetNamespace, tests.TargetNamespaceID, targetExecution.GetWorkflowId(), targetExecution.GetRunId()) @@ -844,10 +844,10 @@ func (s *transferQueueStandbyTaskExecutorSuite) TestProcessSignalExecution_Pendi ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) event, _ = addRequestSignalInitiatedEvent(mutableState, event.GetEventId(), uuid.New(), @@ -935,10 +935,10 @@ func (s *transferQueueStandbyTaskExecutorSuite) TestProcessSignalExecution_Succe ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) event, _ = addRequestSignalInitiatedEvent(mutableState, event.GetEventId(), uuid.New(), @@ -1001,10 +1001,10 @@ func (s *transferQueueStandbyTaskExecutorSuite) TestProcessStartChildExecution_P ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) event, _ = addStartChildWorkflowExecutionInitiatedEvent(mutableState, event.GetEventId(), uuid.New(), @@ -1108,10 +1108,10 @@ func (s *transferQueueStandbyTaskExecutorSuite) TestProcessStartChildExecution_S ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) event, childInfo := addStartChildWorkflowExecutionInitiatedEvent(mutableState, event.GetEventId(), uuid.New(), diff --git a/service/history/visibilityQueueTaskExecutor_test.go b/service/history/visibilityQueueTaskExecutor_test.go index 6796dcd4944..418da9fb552 100644 --- a/service/history/visibilityQueueTaskExecutor_test.go +++ b/service/history/visibilityQueueTaskExecutor_test.go @@ -213,10 +213,10 @@ func (s *visibilityQueueTaskExecutorSuite) TestProcessCloseExecution() { ) s.Nil(err) - di := addWorkflowTaskScheduledEvent(mutableState) - event := addWorkflowTaskStartedEvent(mutableState, di.ScheduledEventID, taskQueueName, uuid.New()) - di.StartedEventID = event.GetEventId() - event = addWorkflowTaskCompletedEvent(mutableState, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(mutableState) + event := addWorkflowTaskStartedEvent(mutableState, wt.ScheduledEventID, taskQueueName, uuid.New()) + wt.StartedEventID = event.GetEventId() + event = addWorkflowTaskCompletedEvent(mutableState, wt.ScheduledEventID, wt.StartedEventID, "some random identity") taskID := int64(59) event = addCompleteWorkflowEvent(mutableState, event.GetEventId(), nil) @@ -271,7 +271,7 @@ func (s *visibilityQueueTaskExecutorSuite) TestProcessRecordWorkflowStartedTask( s.Nil(err) taskID := int64(59) - di := addWorkflowTaskScheduledEvent(mutableState) + wt := addWorkflowTaskScheduledEvent(mutableState) visibilityTask := &tasks.StartExecutionVisibilityTask{ WorkflowKey: definition.NewWorkflowKey( @@ -284,7 +284,7 @@ func (s *visibilityQueueTaskExecutorSuite) TestProcessRecordWorkflowStartedTask( TaskID: taskID, } - persistenceMutableState := s.createPersistenceMutableState(mutableState, di.ScheduledEventID, di.Version) + persistenceMutableState := s.createPersistenceMutableState(mutableState, wt.ScheduledEventID, wt.Version) s.mockExecutionMgr.EXPECT().GetWorkflowExecution(gomock.Any(), gomock.Any()).Return(&persistence.GetWorkflowExecutionResponse{State: persistenceMutableState}, nil) s.mockVisibilityMgr.EXPECT().RecordWorkflowExecutionStarted( gomock.Any(), @@ -322,7 +322,7 @@ func (s *visibilityQueueTaskExecutorSuite) TestProcessUpsertWorkflowSearchAttrib s.NoError(err) taskID := int64(59) - di := addWorkflowTaskScheduledEvent(mutableState) + wt := addWorkflowTaskScheduledEvent(mutableState) visibilityTask := &tasks.UpsertExecutionVisibilityTask{ WorkflowKey: definition.NewWorkflowKey( @@ -334,7 +334,7 @@ func (s *visibilityQueueTaskExecutorSuite) TestProcessUpsertWorkflowSearchAttrib TaskID: taskID, } - persistenceMutableState := s.createPersistenceMutableState(mutableState, di.ScheduledEventID, di.Version) + persistenceMutableState := s.createPersistenceMutableState(mutableState, wt.ScheduledEventID, wt.Version) s.mockExecutionMgr.EXPECT().GetWorkflowExecution(gomock.Any(), gomock.Any()).Return(&persistence.GetWorkflowExecutionResponse{State: persistenceMutableState}, nil) s.mockVisibilityMgr.EXPECT().UpsertWorkflowExecution( gomock.Any(), diff --git a/service/history/workflow/mutable_state_impl_test.go b/service/history/workflow/mutable_state_impl_test.go index 70ada211634..a08dadc60d7 100644 --- a/service/history/workflow/mutable_state_impl_test.go +++ b/service/history/workflow/mutable_state_impl_test.go @@ -374,9 +374,9 @@ func (s *mutableStateSuite) TestTransientWorkflowTaskSchedule_CurrentVersionChan }) s.NoError(err) - di, err := s.mutableState.AddWorkflowTaskScheduledEventAsHeartbeat(true, timestamp.TimeNowPtrUtc()) + wt, err := s.mutableState.AddWorkflowTaskScheduledEventAsHeartbeat(true, timestamp.TimeNowPtrUtc()) s.NoError(err) - s.NotNil(di) + s.NotNil(wt) s.Equal(int32(1), s.mutableState.GetExecutionInfo().WorkflowTaskAttempt) s.Equal(0, s.mutableState.hBuilder.BufferEventSize()) @@ -405,9 +405,9 @@ func (s *mutableStateSuite) TestTransientWorkflowTaskStart_CurrentVersionChanged }) s.NoError(err) - di, err := s.mutableState.AddWorkflowTaskScheduledEventAsHeartbeat(true, timestamp.TimeNowPtrUtc()) + wt, err := s.mutableState.AddWorkflowTaskScheduledEventAsHeartbeat(true, timestamp.TimeNowPtrUtc()) s.NoError(err) - s.NotNil(di) + s.NotNil(wt) err = s.mutableState.UpdateCurrentVersion(version+1, true) s.NoError(err) @@ -543,7 +543,7 @@ func (s *mutableStateSuite) prepareTransientWorkflowTaskCompletionFirstBatchRepl s.Nil(err) // setup transient workflow task - di, err := s.mutableState.ReplicateWorkflowTaskScheduledEvent( + wt, err := s.mutableState.ReplicateWorkflowTaskScheduledEvent( workflowTaskScheduleEvent.GetVersion(), workflowTaskScheduleEvent.GetEventId(), workflowTaskScheduleEvent.GetWorkflowTaskScheduledEventAttributes().GetTaskQueue(), @@ -553,9 +553,9 @@ func (s *mutableStateSuite) prepareTransientWorkflowTaskCompletionFirstBatchRepl nil, ) s.Nil(err) - s.NotNil(di) + s.NotNil(wt) - di, err = s.mutableState.ReplicateWorkflowTaskStartedEvent(nil, + wt, err = s.mutableState.ReplicateWorkflowTaskStartedEvent(nil, workflowTaskStartedEvent.GetVersion(), workflowTaskScheduleEvent.GetEventId(), workflowTaskStartedEvent.GetEventId(), @@ -563,7 +563,7 @@ func (s *mutableStateSuite) prepareTransientWorkflowTaskCompletionFirstBatchRepl timestamp.TimeValue(workflowTaskStartedEvent.GetEventTime()), ) s.Nil(err) - s.NotNil(di) + s.NotNil(wt) err = s.mutableState.ReplicateWorkflowTaskFailedEvent() s.Nil(err) @@ -594,7 +594,7 @@ func (s *mutableStateSuite) prepareTransientWorkflowTaskCompletionFirstBatchRepl } eventID++ - di, err = s.mutableState.ReplicateWorkflowTaskScheduledEvent( + wt, err = s.mutableState.ReplicateWorkflowTaskScheduledEvent( newWorkflowTaskScheduleEvent.GetVersion(), newWorkflowTaskScheduleEvent.GetEventId(), newWorkflowTaskScheduleEvent.GetWorkflowTaskScheduledEventAttributes().GetTaskQueue(), @@ -604,9 +604,9 @@ func (s *mutableStateSuite) prepareTransientWorkflowTaskCompletionFirstBatchRepl nil, ) s.Nil(err) - s.NotNil(di) + s.NotNil(wt) - di, err = s.mutableState.ReplicateWorkflowTaskStartedEvent(nil, + wt, err = s.mutableState.ReplicateWorkflowTaskStartedEvent(nil, newWorkflowTaskStartedEvent.GetVersion(), newWorkflowTaskScheduleEvent.GetEventId(), newWorkflowTaskStartedEvent.GetEventId(), @@ -614,7 +614,7 @@ func (s *mutableStateSuite) prepareTransientWorkflowTaskCompletionFirstBatchRepl timestamp.TimeValue(newWorkflowTaskStartedEvent.GetEventTime()), ) s.Nil(err) - s.NotNil(di) + s.NotNil(wt) s.mutableState.SetHistoryBuilder(NewImmutableHistoryBuilder([]*historypb.HistoryEvent{ newWorkflowTaskScheduleEvent, diff --git a/service/history/workflow/mutable_state_rebuilder_test.go b/service/history/workflow/mutable_state_rebuilder_test.go index 51791c26022..6d9de72fff6 100644 --- a/service/history/workflow/mutable_state_rebuilder_test.go +++ b/service/history/workflow/mutable_state_rebuilder_test.go @@ -732,7 +732,7 @@ func (s *stateBuilderSuite) TestApplyEvents_EventTypeWorkflowTaskScheduled() { Attempt: workflowTaskAttempt, }}, } - di := &WorkflowTaskInfo{ + wt := &WorkflowTaskInfo{ Version: event.GetVersion(), ScheduledEventID: event.GetEventId(), StartedEventID: common.EmptyEventID, @@ -744,11 +744,11 @@ func (s *stateBuilderSuite) TestApplyEvents_EventTypeWorkflowTaskScheduled() { s.executionInfo.TaskQueue = taskqueue.GetName() s.mockMutableState.EXPECT().ReplicateWorkflowTaskScheduledEvent( event.GetVersion(), event.GetEventId(), taskqueue, &timeout, workflowTaskAttempt, event.GetEventTime(), event.GetEventTime(), - ).Return(di, nil) + ).Return(wt, nil) s.mockUpdateVersion(event) s.mockTaskGenerator.EXPECT().GenerateScheduleWorkflowTaskTasks( timestamp.TimeValue(event.GetEventTime()), - di.ScheduledEventID, + wt.ScheduledEventID, ).Return(nil) s.mockMutableState.EXPECT().ClearStickyness() @@ -782,7 +782,7 @@ func (s *stateBuilderSuite) TestApplyEvents_EventTypeWorkflowTaskStarted() { RequestId: workflowTaskRequestID, }}, } - di := &WorkflowTaskInfo{ + wt := &WorkflowTaskInfo{ Version: event.GetVersion(), ScheduledEventID: scheduledEventID, StartedEventID: event.GetEventId(), @@ -793,11 +793,11 @@ func (s *stateBuilderSuite) TestApplyEvents_EventTypeWorkflowTaskStarted() { } s.mockMutableState.EXPECT().ReplicateWorkflowTaskStartedEvent( (*WorkflowTaskInfo)(nil), event.GetVersion(), scheduledEventID, event.GetEventId(), workflowTaskRequestID, timestamp.TimeValue(event.GetEventTime()), - ).Return(di, nil) + ).Return(wt, nil) s.mockUpdateVersion(event) s.mockTaskGenerator.EXPECT().GenerateStartWorkflowTaskTasks( timestamp.TimeValue(event.GetEventTime()), - di.ScheduledEventID, + wt.ScheduledEventID, ).Return(nil) s.mockMutableState.EXPECT().ClearStickyness() diff --git a/service/history/workflow/workflow_task_state_machine.go b/service/history/workflow/workflow_task_state_machine.go index a625175bf56..5cf06ca5e59 100644 --- a/service/history/workflow/workflow_task_state_machine.go +++ b/service/history/workflow/workflow_task_state_machine.go @@ -549,8 +549,8 @@ func (m *workflowTaskStateMachine) AddWorkflowTaskTimedOutEvent( startedEventID int64, ) (*historypb.HistoryEvent, error) { opTag := tag.WorkflowActionWorkflowTaskTimedOut - dt, ok := m.GetWorkflowTaskInfo(scheduledEventID) - if !ok || dt.StartedEventID != startedEventID { + workflowTask, ok := m.GetWorkflowTaskInfo(scheduledEventID) + if !ok || workflowTask.StartedEventID != startedEventID { m.ms.logger.Warn(mutableStateInvalidHistoryActionMsg, opTag, tag.WorkflowEventID(m.ms.GetNextEventID()), tag.ErrorTypeInvalidHistoryAction, @@ -561,7 +561,7 @@ func (m *workflowTaskStateMachine) AddWorkflowTaskTimedOutEvent( var event *historypb.HistoryEvent // Avoid creating new history events when workflow tasks are continuously timing out - if dt.Attempt == 1 { + if workflowTask.Attempt == 1 { event = m.ms.hBuilder.AddWorkflowTaskTimedOutEvent( scheduledEventID, startedEventID, diff --git a/service/history/workflowTaskHandlerCallbacks.go b/service/history/workflowTaskHandlerCallbacks.go index fb8ad7fab02..205e85fef67 100644 --- a/service/history/workflowTaskHandlerCallbacks.go +++ b/service/history/workflowTaskHandlerCallbacks.go @@ -669,7 +669,7 @@ func (handler *workflowTaskHandlerCallbacksImpl) createRecordWorkflowTaskStarted response.PreviousStartedEventId = executionInfo.LastWorkflowTaskStartedEventId } - // Starting workflowTask could result in different scheduledEventID if workflowTask was transient and new new events came in + // Starting workflowTask could result in different scheduledEventID if workflowTask was transient and new events came in // before it was started. response.ScheduledEventId = workflowTask.ScheduledEventID response.StartedEventId = workflowTask.StartedEventID diff --git a/service/history/workflowTaskHandlerCallbacks_test.go b/service/history/workflowTaskHandlerCallbacks_test.go index aaa9655778c..e664cc5364f 100644 --- a/service/history/workflowTaskHandlerCallbacks_test.go +++ b/service/history/workflowTaskHandlerCallbacks_test.go @@ -245,10 +245,10 @@ func (s *WorkflowTaskHandlerCallbackSuite) TestVerifyFirstWorkflowTaskScheduled_ WorkflowId: tests.WorkflowID, RunId: tests.RunID, }, "wType", "testTaskQueue", payloads.EncodeString("input"), 25*time.Second, 20*time.Second, 200*time.Second, "identity") - di := addWorkflowTaskScheduledEvent(msBuilder) - workflowTasksStartEvent := addWorkflowTaskStartedEvent(msBuilder, di.ScheduledEventID, "testTaskQueue", uuid.New()) - di.StartedEventID = workflowTasksStartEvent.GetEventId() - addWorkflowTaskCompletedEvent(msBuilder, di.ScheduledEventID, di.StartedEventID, "some random identity") + wt := addWorkflowTaskScheduledEvent(msBuilder) + workflowTasksStartEvent := addWorkflowTaskStartedEvent(msBuilder, wt.ScheduledEventID, "testTaskQueue", uuid.New()) + wt.StartedEventID = workflowTasksStartEvent.GetEventId() + addWorkflowTaskCompletedEvent(msBuilder, wt.ScheduledEventID, wt.StartedEventID, "some random identity") ms := workflow.TestCloneToProto(msBuilder) gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms}