diff --git a/service/history/conflictResolver_test.go b/service/history/conflictResolver_test.go index c4febc324fc..9123f8fede5 100644 --- a/service/history/conflictResolver_test.go +++ b/service/history/conflictResolver_test.go @@ -287,7 +287,7 @@ func (s *conflictResolverSuite) TestReset() { InsertRequestCancelInfos: []*persistence.RequestCancelInfo{}, InsertSignalInfos: []*persistence.SignalInfo{}, InsertSignalRequestedIDs: []string{}, - Encoding: common.EncodingType("json"), + Encoding: common.EncodingType(s.mockShard.GetConfig().EventEncodingType(domainID)), }).Return(nil).Once() s.mockExecutionMgr.On("GetWorkflowExecution", &persistence.GetWorkflowExecutionRequest{ DomainID: domainID, diff --git a/service/history/historyEngine2_test.go b/service/history/historyEngine2_test.go index 51c06e222db..04a59d7efdf 100644 --- a/service/history/historyEngine2_test.go +++ b/service/history/historyEngine2_test.go @@ -24,10 +24,11 @@ import ( "context" "encoding/json" "errors" - "github.com/uber/cadence/service/worker/sysworkflow" "os" "testing" + "github.com/uber/cadence/service/worker/sysworkflow" + log "github.com/sirupsen/logrus" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -62,6 +63,7 @@ type ( mockVisibilityMgr *mocks.VisibilityManager mockExecutionMgr *mocks.ExecutionManager mockHistoryMgr *mocks.HistoryManager + mockHistoryV2Mgr *mocks.HistoryV2Manager mockShardManager *mocks.ShardManager mockClusterMetadata *mocks.ClusterMetadata mockProducer *mocks.KafkaProducer @@ -108,6 +110,7 @@ func (s *engine2Suite) SetupTest() { s.mockVisibilityMgr = &mocks.VisibilityManager{} s.mockExecutionMgr = &mocks.ExecutionManager{} s.mockHistoryMgr = &mocks.HistoryManager{} + s.mockHistoryV2Mgr = &mocks.HistoryV2Manager{} s.mockShardManager = &mocks.ShardManager{} s.mockClusterMetadata = &mocks.ClusterMetadata{} s.mockProducer = &mocks.KafkaProducer{} @@ -131,6 +134,7 @@ func (s *engine2Suite) SetupTest() { transferSequenceNumber: 1, executionManager: s.mockExecutionMgr, historyMgr: s.mockHistoryMgr, + historyV2Mgr: s.mockHistoryV2Mgr, domainCache: s.mockDomainCache, shardManager: s.mockShardManager, maxTransferSequenceNumber: 100000, @@ -147,6 +151,7 @@ func (s *engine2Suite) SetupTest() { shard: mockShard, executionManager: s.mockExecutionMgr, historyMgr: s.mockHistoryMgr, + historyV2Mgr: s.mockHistoryV2Mgr, historyCache: historyCache, logger: s.logger, metricsClient: metrics.NewClient(tally.NoopScope, metrics.History), @@ -163,6 +168,7 @@ func (s *engine2Suite) TearDownTest() { s.mockMatchingClient.AssertExpectations(s.T()) s.mockExecutionMgr.AssertExpectations(s.T()) s.mockHistoryMgr.AssertExpectations(s.T()) + s.mockHistoryV2Mgr.AssertExpectations(s.T()) s.mockShardManager.AssertExpectations(s.T()) s.mockVisibilityMgr.AssertExpectations(s.T()) s.mockProducer.AssertExpectations(s.T()) @@ -180,8 +186,8 @@ func (s *engine2Suite) TestRecordDecisionTaskStartedSuccessStickyEnabled() { stickyTl := "stickyTaskList" identity := "testIdentity" - msBuilder := newMutableStateBuilder("test", s.historyEngine.shard, s.mockEventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2("test", s.historyEngine.shard, s.mockEventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) executionInfo := msBuilder.GetExecutionInfo() executionInfo.StickyTaskList = stickyTl @@ -193,7 +199,7 @@ func (s *engine2Suite) TestRecordDecisionTaskStartedSuccessStickyEnabled() { gwmsResponse := &p.GetWorkflowExecutionResponse{State: ms} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(nil, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( &p.GetDomainResponse{ @@ -239,7 +245,8 @@ func (s *engine2Suite) TestRecordDecisionTaskStartedSuccessStickyEnabled() { Name: &executionInfo.TaskList, Kind: common.TaskListKindPtr(workflow.TaskListKindNormal), }) - expectedResponse.EventStoreVersion = common.Int32Ptr(0) + expectedResponse.EventStoreVersion = common.Int32Ptr(p.EventStoreVersionV2) + expectedResponse.BranchToken = msBuilder.GetCurrentBranch() response, err := s.historyEngine.RecordDecisionTaskStarted(context.Background(), &request) s.Nil(err) @@ -450,14 +457,14 @@ func (s *engine2Suite) TestRecordDecisionTaskStartedConflictOnUpdate() { gwmsResponse := &p.GetWorkflowExecutionResponse{State: ms} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(nil, &p.ConditionFailedError{}).Once() ms2 := createMutableState(msBuilder) gwmsResponse2 := &p.GetWorkflowExecutionResponse{State: ms2} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse2, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(nil, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( &p.GetDomainResponse{ @@ -510,7 +517,7 @@ func (s *engine2Suite) TestRecordDecisionTaskRetrySameRequest() { gwmsResponse := &p.GetWorkflowExecutionResponse{State: ms} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(nil, &p.ConditionFailedError{}).Once() startedEventID := addDecisionTaskStartedEventWithRequestID(msBuilder, int64(2), requestID, tl, identity) @@ -568,7 +575,7 @@ func (s *engine2Suite) TestRecordDecisionTaskRetryDifferentRequest() { ms := createMutableState(msBuilder) gwmsResponse := &p.GetWorkflowExecutionResponse{State: ms} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(nil, &p.ConditionFailedError{}).Once() // Add event. @@ -629,7 +636,7 @@ func (s *engine2Suite) TestRecordDecisionTaskStartedMaxAttemptsExceeded() { s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() } - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Times( + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Times( conditionalRetryCount) s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(nil, &p.ConditionFailedError{}).Times(conditionalRetryCount) @@ -681,7 +688,7 @@ func (s *engine2Suite) TestRecordDecisionTaskSuccess() { ms := createMutableState(msBuilder) gwmsResponse := &p.GetWorkflowExecutionResponse{State: ms} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(nil, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( &p.GetDomainResponse{ @@ -789,7 +796,7 @@ func (s *engine2Suite) TestRecordActivityTaskStartedSuccess() { gwmsResponse1 := &p.GetWorkflowExecutionResponse{State: ms1} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse1, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(nil, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( &p.GetDomainResponse{ @@ -841,7 +848,7 @@ func (s *engine2Suite) TestRequestCancelWorkflowExecutionSuccess() { gwmsResponse1 := &p.GetWorkflowExecutionResponse{State: ms1} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse1, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(nil, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( &p.GetDomainResponse{ @@ -921,13 +928,14 @@ func (s *engine2Suite) TestRequestCancelWorkflowExecutionFail() { func (s *engine2Suite) createExecutionStartedState(we workflow.WorkflowExecution, tl, identity string, startDecision bool) mutableState { - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.historyEngine.shard, s.mockEventsCache, - s.logger) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.historyEngine.shard, s.mockEventsCache, + s.logger, we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 200, identity) di := addDecisionTaskScheduledEvent(msBuilder) if startDecision { addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) } + _ = msBuilder.SetHistoryTree(we.GetRunId()) return msBuilder } @@ -952,8 +960,8 @@ func (s *engine2Suite) TestRespondDecisionTaskCompletedRecordMarkerDecision() { markerDetails := []byte("marker details") markerName := "marker name" - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.historyEngine.shard, s.mockEventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.historyEngine.shard, s.mockEventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 200, identity) di := addDecisionTaskScheduledEvent(msBuilder) addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -970,7 +978,7 @@ func (s *engine2Suite) TestRespondDecisionTaskCompletedRecordMarkerDecision() { gwmsResponse := &p.GetWorkflowExecutionResponse{State: ms} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(nil, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( &p.GetDomainResponse{ @@ -1011,7 +1019,7 @@ func (s *engine2Suite) TestStartWorkflowExecution_BrandNew() { taskList := "testTaskList" identity := "testIdentity" - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("CreateWorkflowExecution", mock.Anything).Return(&p.CreateWorkflowExecutionResponse{}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( &p.GetDomainResponse{ @@ -1054,7 +1062,7 @@ func (s *engine2Suite) TestStartWorkflowExecution_StillRunning_Dedup() { requestID := "requestID" lastWriteVersion := common.EmptyVersion - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("CreateWorkflowExecution", mock.Anything).Return(nil, &p.WorkflowExecutionAlreadyStartedError{ Msg: "random message", StartRequestID: requestID, @@ -1063,7 +1071,7 @@ func (s *engine2Suite) TestStartWorkflowExecution_StillRunning_Dedup() { CloseStatus: p.WorkflowCloseStatusNone, LastWriteVersion: lastWriteVersion, }).Once() - s.mockHistoryMgr.On("DeleteWorkflowExecutionHistory", mock.Anything).Return(nil).Once() + s.mockHistoryV2Mgr.On("DeleteHistoryBranch", mock.Anything).Return(nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( &p.GetDomainResponse{ Info: &p.DomainInfo{ID: domainID}, @@ -1105,7 +1113,7 @@ func (s *engine2Suite) TestStartWorkflowExecution_StillRunning_NonDeDup() { identity := "testIdentity" lastWriteVersion := common.EmptyVersion - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("CreateWorkflowExecution", mock.Anything).Return(nil, &p.WorkflowExecutionAlreadyStartedError{ Msg: "random message", StartRequestID: "oldRequestID", @@ -1114,7 +1122,7 @@ func (s *engine2Suite) TestStartWorkflowExecution_StillRunning_NonDeDup() { CloseStatus: p.WorkflowCloseStatusNone, LastWriteVersion: lastWriteVersion, }).Once() - s.mockHistoryMgr.On("DeleteWorkflowExecutionHistory", mock.Anything).Return(nil).Once() + s.mockHistoryV2Mgr.On("DeleteHistoryBranch", mock.Anything).Return(nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( &p.GetDomainResponse{ Info: &p.DomainInfo{ID: domainID}, @@ -1166,7 +1174,7 @@ func (s *engine2Suite) TestStartWorkflowExecution_NotRunning_PrevSuccess() { expecedErrs := []bool{true, false, true} - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Times(len(expecedErrs)) + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Times(len(expecedErrs)) s.mockExecutionMgr.On( "CreateWorkflowExecution", mock.MatchedBy(func(request *p.CreateWorkflowExecutionRequest) bool { @@ -1206,7 +1214,7 @@ func (s *engine2Suite) TestStartWorkflowExecution_NotRunning_PrevSuccess() { }), ).Return(&p.CreateWorkflowExecutionResponse{}, nil).Once() } else { - s.mockHistoryMgr.On("DeleteWorkflowExecutionHistory", mock.Anything).Return(nil).Once() + s.mockHistoryV2Mgr.On("DeleteHistoryBranch", mock.Anything).Return(nil).Once() } resp, err := s.historyEngine.StartWorkflowExecution(context.Background(), &h.StartWorkflowExecutionRequest{ @@ -1262,7 +1270,7 @@ func (s *engine2Suite) TestStartWorkflowExecution_NotRunning_PrevFail() { for i, closeState := range closeStates { - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Times(len(expecedErrs)) + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Times(len(expecedErrs)) s.mockExecutionMgr.On( "CreateWorkflowExecution", mock.MatchedBy(func(request *p.CreateWorkflowExecutionRequest) bool { @@ -1303,7 +1311,7 @@ func (s *engine2Suite) TestStartWorkflowExecution_NotRunning_PrevFail() { }), ).Return(&p.CreateWorkflowExecutionResponse{}, nil).Once() } else { - s.mockHistoryMgr.On("DeleteWorkflowExecutionHistory", mock.Anything).Return(nil).Once() + s.mockHistoryV2Mgr.On("DeleteHistoryBranch", mock.Anything).Return(nil).Once() } resp, err := s.historyEngine.StartWorkflowExecution(context.Background(), &h.StartWorkflowExecutionRequest{ @@ -1356,15 +1364,15 @@ func (s *engine2Suite) TestSignalWithStartWorkflowExecution_JustSignal() { }, } - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.historyEngine.shard, s.mockEventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.historyEngine.shard, s.mockEventsCache, + bark.NewLoggerFromLogrus(log.New()), runID) ms := createMutableState(msBuilder) gwmsResponse := &p.GetWorkflowExecutionResponse{State: ms} gceResponse := &p.GetCurrentExecutionResponse{RunID: runID} s.mockExecutionMgr.On("GetCurrentExecution", mock.Anything).Return(gceResponse, nil).Once() s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(nil, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( &p.GetDomainResponse{ @@ -1416,7 +1424,7 @@ func (s *engine2Suite) TestSignalWithStartWorkflowExecution_WorkflowNotExist() { notExistErr := &workflow.EntityNotExistsError{Message: "Workflow not exist"} s.mockExecutionMgr.On("GetCurrentExecution", mock.Anything).Return(nil, notExistErr).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("CreateWorkflowExecution", mock.Anything).Return(&p.CreateWorkflowExecutionResponse{}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( &p.GetDomainResponse{ @@ -1466,8 +1474,8 @@ func (s *engine2Suite) TestSignalWithStartWorkflowExecution_WorkflowNotRunning() }, } - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.historyEngine.shard, s.mockEventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.historyEngine.shard, s.mockEventsCache, + bark.NewLoggerFromLogrus(log.New()), runID) ms := createMutableState(msBuilder) ms.ExecutionInfo.State = p.WorkflowStateCompleted gwmsResponse := &p.GetWorkflowExecutionResponse{State: ms} @@ -1475,7 +1483,7 @@ func (s *engine2Suite) TestSignalWithStartWorkflowExecution_WorkflowNotRunning() s.mockExecutionMgr.On("GetCurrentExecution", mock.Anything).Return(gceResponse, nil).Once() s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("CreateWorkflowExecution", mock.Anything).Return(&p.CreateWorkflowExecutionResponse{}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( &p.GetDomainResponse{ @@ -1524,8 +1532,8 @@ func (s *engine2Suite) TestSignalWithStartWorkflowExecution_Start_DuplicateReque }, } - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.historyEngine.shard, s.mockEventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.historyEngine.shard, s.mockEventsCache, + bark.NewLoggerFromLogrus(log.New()), runID) ms := createMutableState(msBuilder) ms.ExecutionInfo.State = p.WorkflowStateCompleted gwmsResponse := &p.GetWorkflowExecutionResponse{State: ms} @@ -1541,9 +1549,9 @@ func (s *engine2Suite) TestSignalWithStartWorkflowExecution_Start_DuplicateReque s.mockExecutionMgr.On("GetCurrentExecution", mock.Anything).Return(gceResponse, nil).Once() s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("CreateWorkflowExecution", mock.Anything).Return(nil, workflowAlreadyStartedErr).Once() - s.mockHistoryMgr.On("DeleteWorkflowExecutionHistory", mock.Anything).Return(nil).Once() + s.mockHistoryV2Mgr.On("DeleteHistoryBranch", mock.Anything).Return(nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( &p.GetDomainResponse{ Info: &p.DomainInfo{ID: domainID}, @@ -1591,8 +1599,8 @@ func (s *engine2Suite) TestSignalWithStartWorkflowExecution_Start_WorkflowAlread }, } - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.historyEngine.shard, s.mockEventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.historyEngine.shard, s.mockEventsCache, + bark.NewLoggerFromLogrus(log.New()), runID) ms := createMutableState(msBuilder) ms.ExecutionInfo.State = p.WorkflowStateCompleted gwmsResponse := &p.GetWorkflowExecutionResponse{State: ms} @@ -1608,9 +1616,9 @@ func (s *engine2Suite) TestSignalWithStartWorkflowExecution_Start_WorkflowAlread s.mockExecutionMgr.On("GetCurrentExecution", mock.Anything).Return(gceResponse, nil).Once() s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("CreateWorkflowExecution", mock.Anything).Return(nil, workflowAlreadyStartedErr).Once() - s.mockHistoryMgr.On("DeleteWorkflowExecutionHistory", mock.Anything).Return(nil).Once() + s.mockHistoryV2Mgr.On("DeleteHistoryBranch", mock.Anything).Return(nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( &p.GetDomainResponse{ Info: &p.DomainInfo{ID: domainID}, diff --git a/service/history/historyEngine3_eventsv2_test.go b/service/history/historyEngine3_eventsv2_test.go index a2fc369c784..d1668c9a61e 100644 --- a/service/history/historyEngine3_eventsv2_test.go +++ b/service/history/historyEngine3_eventsv2_test.go @@ -22,10 +22,11 @@ package history import ( "context" - "github.com/uber/cadence/service/worker/sysworkflow" "os" "testing" + "github.com/uber/cadence/service/worker/sysworkflow" + log "github.com/sirupsen/logrus" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -183,9 +184,8 @@ func (s *engine3Suite) TestRecordDecisionTaskStartedSuccessStickyEnabled() { stickyTl := "stickyTaskList" identity := "testIdentity" - msBuilder := newMutableStateBuilder("test", s.historyEngine.shard, s.mockEventsCache, - bark.NewLoggerFromLogrus(log.New())) - msBuilder.SetHistoryTree(msBuilder.GetExecutionInfo().RunID) + msBuilder := newMutableStateBuilderWithEventV2("test", s.historyEngine.shard, s.mockEventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) executionInfo := msBuilder.GetExecutionInfo() executionInfo.StickyTaskList = stickyTl @@ -322,9 +322,8 @@ func (s *engine3Suite) TestSignalWithStartWorkflowExecution_JustSignal() { }, } - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.historyEngine.shard, s.mockEventsCache, - bark.NewLoggerFromLogrus(log.New())) - msBuilder.SetHistoryTree(msBuilder.GetExecutionInfo().RunID) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.historyEngine.shard, s.mockEventsCache, + bark.NewLoggerFromLogrus(log.New()), runID) ms := createMutableState(msBuilder) gwmsResponse := &p.GetWorkflowExecutionResponse{State: ms} gceResponse := &p.GetCurrentExecutionResponse{RunID: runID} diff --git a/service/history/historyEngine_test.go b/service/history/historyEngine_test.go index 039b61d2ac3..309f2e93223 100644 --- a/service/history/historyEngine_test.go +++ b/service/history/historyEngine_test.go @@ -24,11 +24,12 @@ import ( "context" "encoding/json" "errors" - "github.com/uber/cadence/service/worker/sysworkflow" "os" "testing" "time" + "github.com/uber/cadence/service/worker/sysworkflow" + "github.com/uber/cadence/.gen/go/history" workflow "github.com/uber/cadence/.gen/go/shared" "github.com/uber/cadence/client" @@ -65,6 +66,7 @@ type ( mockVisibilityMgr *mocks.VisibilityManager mockExecutionMgr *mocks.ExecutionManager mockHistoryMgr *mocks.HistoryManager + mockHistoryV2Mgr *mocks.HistoryV2Manager mockShardManager *mocks.ShardManager mockClusterMetadata *mocks.ClusterMetadata mockProducer *mocks.KafkaProducer @@ -113,6 +115,7 @@ func (s *engineSuite) SetupTest() { s.mockVisibilityMgr = &mocks.VisibilityManager{} s.mockExecutionMgr = &mocks.ExecutionManager{} s.mockHistoryMgr = &mocks.HistoryManager{} + s.mockHistoryV2Mgr = &mocks.HistoryV2Manager{} s.mockShardManager = &mocks.ShardManager{} s.mockClusterMetadata = &mocks.ClusterMetadata{} s.mockProducer = &mocks.KafkaProducer{} @@ -138,6 +141,7 @@ func (s *engineSuite) SetupTest() { transferSequenceNumber: 1, executionManager: s.mockExecutionMgr, historyMgr: s.mockHistoryMgr, + historyV2Mgr: s.mockHistoryV2Mgr, domainCache: domainCache, shardManager: s.mockShardManager, maxTransferSequenceNumber: 100000, @@ -165,6 +169,7 @@ func (s *engineSuite) SetupTest() { shard: shardContextWrapper, executionManager: s.mockExecutionMgr, historyMgr: s.mockHistoryMgr, + historyV2Mgr: s.mockHistoryV2Mgr, historyCache: historyCache, logger: s.logger, metricsClient: metrics.NewClient(tally.NoopScope, metrics.History), @@ -185,6 +190,7 @@ func (s *engineSuite) TearDownTest() { s.mockMatchingClient.AssertExpectations(s.T()) s.mockExecutionMgr.AssertExpectations(s.T()) s.mockHistoryMgr.AssertExpectations(s.T()) + s.mockHistoryV2Mgr.AssertExpectations(s.T()) s.mockShardManager.AssertExpectations(s.T()) s.mockVisibilityMgr.AssertExpectations(s.T()) s.mockProducer.AssertExpectations(s.T()) @@ -202,8 +208,8 @@ func (s *engineSuite) TestGetMutableStateSync() { tasklist := "testTaskList" identity := "testIdentity" - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), execution.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, execution, "wType", tasklist, []byte("input"), 100, 200, identity) di := addDecisionTaskScheduledEvent(msBuilder) addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tasklist, identity) @@ -262,8 +268,8 @@ func (s *engineSuite) TestGetMutableStateLongPoll() { tasklist := "testTaskList" identity := "testIdentity" - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), execution.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, execution, "wType", tasklist, []byte("input"), 100, 200, identity) di := addDecisionTaskScheduledEvent(msBuilder) addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tasklist, identity) @@ -293,7 +299,7 @@ func (s *engineSuite) TestGetMutableStateLongPoll() { RunID: *execution.RunId, ScheduleID: 2, }) - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() timer := time.NewTimer(delay) @@ -355,8 +361,8 @@ func (s *engineSuite) TestGetMutableStateLongPollTimeout() { tasklist := "testTaskList" identity := "testIdentity" - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), execution.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, execution, "wType", tasklist, []byte("input"), 100, 200, identity) di := addDecisionTaskScheduledEvent(msBuilder) addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tasklist, identity) @@ -508,8 +514,8 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedUpdateExecutionFailed() { }) identity := "testIdentity" - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 200, identity) di := addDecisionTaskScheduledEvent(msBuilder) addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -532,7 +538,7 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedUpdateExecutionFailed() { nil, ) s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, errors.New("FAILED")).Once() s.mockShardManager.On("UpdateShard", mock.Anything).Return(nil).Once() @@ -561,8 +567,8 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedIfTaskCompleted() { }) identity := "testIdentity" - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 200, identity) di := addDecisionTaskScheduledEvent(msBuilder) startedEvent := addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -612,8 +618,8 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedIfTaskNotStarted() { }) identity := "testIdentity" - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 200, identity) addDecisionTaskScheduledEvent(msBuilder) @@ -667,8 +673,8 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedConflictOnUpdate() { activity3Type := "activity_type3" activity3Input := []byte("input3") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) di1 := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent1 := addDecisionTaskStartedEvent(msBuilder, di1.ScheduleID, tl, identity) @@ -729,12 +735,12 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedConflictOnUpdate() { nil, ) s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, &persistence.ConditionFailedError{}).Once() s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse2, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() _, err := s.mockHistoryEngine.RespondDecisionTaskCompleted(context.Background(), &history.RespondDecisionTaskCompletedRequest{ @@ -784,8 +790,8 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedMaxAttemptsExceeded() { executionContext := []byte("context") input := []byte("input") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 200, identity) di := addDecisionTaskScheduledEvent(msBuilder) addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -809,7 +815,7 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedMaxAttemptsExceeded() { gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, &persistence.ConditionFailedError{}).Once() } @@ -860,8 +866,8 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedCompleteWorkflowFailed() { activity2Result := []byte("activity2_result") workflowResult := []byte("workflow result") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 25, 200, identity) di1 := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent1 := addDecisionTaskStartedEvent(msBuilder, di1.ScheduleID, tl, identity) @@ -899,7 +905,7 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedCompleteWorkflowFailed() { s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() } - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( @@ -958,8 +964,8 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedFailWorkflowFailed() { reason := "workflow fail reason" details := []byte("workflow fail details") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 25, 200, identity) di1 := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent1 := addDecisionTaskStartedEvent(msBuilder, di1.ScheduleID, tl, identity) @@ -998,7 +1004,7 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedFailWorkflowFailed() { s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() } - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( @@ -1051,8 +1057,8 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedBadDecisionAttributes() { activity1Input := []byte("input1") activity1Result := []byte("activity1_result") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 25, 200, identity) di1 := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent1 := addDecisionTaskStartedEvent(msBuilder, di1.ScheduleID, tl, identity) @@ -1180,8 +1186,8 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedSingleActivityScheduledAtt executionContext := []byte("context") input := []byte("input") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), workflowTimeout, 200, identity) di := addDecisionTaskScheduledEvent(msBuilder) addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -1206,7 +1212,7 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedSingleActivityScheduledAtt s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() if !iVar.expectError { - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() } @@ -1265,8 +1271,8 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedSingleActivityScheduledDec executionContext := []byte("context") input := []byte("input") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 200, identity) di := addDecisionTaskScheduledEvent(msBuilder) addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -1289,7 +1295,7 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedSingleActivityScheduledDec gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( @@ -1351,8 +1357,8 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedCompleteWorkflowSuccess() executionContext := []byte("context") workflowResult := []byte("success") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 200, identity) di := addDecisionTaskScheduledEvent(msBuilder) addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -1368,7 +1374,7 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedCompleteWorkflowSuccess() gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( &persistence.GetDomainResponse{ @@ -1424,8 +1430,8 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedFailWorkflowSuccess() { details := []byte("fail workflow details") reason := "fail workflow reason" - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 200, identity) di := addDecisionTaskScheduledEvent(msBuilder) addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -1442,7 +1448,7 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedFailWorkflowSuccess() { gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( &persistence.GetDomainResponse{ @@ -1495,8 +1501,8 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedSignalExternalWorkflowSucc identity := "testIdentity" executionContext := []byte("context") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 200, identity) di := addDecisionTaskScheduledEvent(msBuilder) addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -1518,7 +1524,7 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedSignalExternalWorkflowSucc gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( &persistence.GetDomainResponse{ @@ -1565,8 +1571,8 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedSignalExternalWorkflowFail identity := "testIdentity" executionContext := []byte("context") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 200, identity) di := addDecisionTaskScheduledEvent(msBuilder) addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -1627,8 +1633,8 @@ func (s *engineSuite) TestRespondDecisionTaskCompletedSignalExternalWorkflowFail executionContext := []byte("context") foreignDomain := "unknown domain" - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 200, identity) di := addDecisionTaskScheduledEvent(msBuilder) addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -1826,8 +1832,8 @@ func (s *engineSuite) TestRespondActivityTaskCompletedIfNoAIdProvided() { }) identity := "testIdentity" - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), validRunID) ms := createMutableState(msBuilder) gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} gceResponse := &persistence.GetCurrentExecutionResponse{RunID: validRunID} @@ -1868,8 +1874,8 @@ func (s *engineSuite) TestRespondActivityTaskCompletedIfNoAidFound() { }) identity := "testIdentity" - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), validRunID) ms := createMutableState(msBuilder) gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} gceResponse := &persistence.GetCurrentExecutionResponse{RunID: validRunID} @@ -1919,8 +1925,8 @@ func (s *engineSuite) TestRespondActivityTaskCompletedUpdateExecutionFailed() { activityInput := []byte("input1") activityResult := []byte("activity result") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 200, identity) di := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent := addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -1948,7 +1954,7 @@ func (s *engineSuite) TestRespondActivityTaskCompletedUpdateExecutionFailed() { nil, ) s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, errors.New("FAILED")).Once() s.mockShardManager.On("UpdateShard", mock.Anything).Return(nil).Once() @@ -1981,8 +1987,8 @@ func (s *engineSuite) TestRespondActivityTaskCompletedIfTaskCompleted() { activityInput := []byte("input1") activityResult := []byte("activity result") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 200, identity) di := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent := addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -2044,8 +2050,8 @@ func (s *engineSuite) TestRespondActivityTaskCompletedIfTaskNotStarted() { activityInput := []byte("input1") activityResult := []byte("activity result") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 200, identity) di := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent := addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -2106,8 +2112,8 @@ func (s *engineSuite) TestRespondActivityTaskCompletedConflictOnUpdate() { activity2Type := "activity_type2" activity2Input := []byte("input2") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) di := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent1 := addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -2127,11 +2133,11 @@ func (s *engineSuite) TestRespondActivityTaskCompletedConflictOnUpdate() { gwmsResponse2 := &persistence.GetWorkflowExecutionResponse{State: ms2} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse1, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, &persistence.ConditionFailedError{}).Once() s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse2, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( @@ -2188,8 +2194,8 @@ func (s *engineSuite) TestRespondActivityTaskCompletedMaxAttemptsExceeded() { activityInput := []byte("input1") activityResult := []byte("activity result") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) di := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent := addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -2204,7 +2210,7 @@ func (s *engineSuite) TestRespondActivityTaskCompletedMaxAttemptsExceeded() { gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, &persistence.ConditionFailedError{}).Once() } @@ -2251,8 +2257,8 @@ func (s *engineSuite) TestRespondActivityTaskCompletedSuccess() { activityInput := []byte("input1") activityResult := []byte("activity result") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) di := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent := addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -2266,7 +2272,7 @@ func (s *engineSuite) TestRespondActivityTaskCompletedSuccess() { gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( @@ -2324,8 +2330,8 @@ func (s *engineSuite) TestRespondActivityTaskCompletedByIdSuccess() { ActivityID: activityID, }) - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) decisionScheduledEvent := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent := addDecisionTaskStartedEvent(msBuilder, decisionScheduledEvent.ScheduleID, tl, identity) @@ -2341,7 +2347,7 @@ func (s *engineSuite) TestRespondActivityTaskCompletedByIdSuccess() { s.mockExecutionMgr.On("GetCurrentExecution", mock.Anything).Return(gceResponse, nil).Once() s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( @@ -2528,8 +2534,8 @@ func (s *engineSuite) TestRespondActivityTaskFailededIfNoAIdProvided() { }) identity := "testIdentity" - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), validRunID) ms := createMutableState(msBuilder) gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} gceResponse := &persistence.GetCurrentExecutionResponse{RunID: validRunID} @@ -2570,8 +2576,8 @@ func (s *engineSuite) TestRespondActivityTaskFailededIfNoAIdFound() { }) identity := "testIdentity" - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), validRunID) ms := createMutableState(msBuilder) gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} gceResponse := &persistence.GetCurrentExecutionResponse{RunID: validRunID} @@ -2620,8 +2626,8 @@ func (s *engineSuite) TestRespondActivityTaskFailedUpdateExecutionFailed() { activityType := "activity_type1" activityInput := []byte("input1") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) di := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent := addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -2635,7 +2641,7 @@ func (s *engineSuite) TestRespondActivityTaskFailedUpdateExecutionFailed() { gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, errors.New("FAILED")).Once() s.mockShardManager.On("UpdateShard", mock.Anything).Return(nil).Once() @@ -2682,8 +2688,8 @@ func (s *engineSuite) TestRespondActivityTaskFailedIfTaskCompleted() { failReason := "fail reason" details := []byte("fail details") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) di := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent := addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -2745,8 +2751,8 @@ func (s *engineSuite) TestRespondActivityTaskFailedIfTaskNotStarted() { activityType := "activity_type1" activityInput := []byte("input1") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) di := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent := addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -2808,8 +2814,8 @@ func (s *engineSuite) TestRespondActivityTaskFailedConflictOnUpdate() { activity2Input := []byte("input2") activity2Result := []byte("activity2_result") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 25, 25, identity) di1 := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent1 := addDecisionTaskStartedEvent(msBuilder, di1.ScheduleID, tl, identity) @@ -2833,11 +2839,11 @@ func (s *engineSuite) TestRespondActivityTaskFailedConflictOnUpdate() { gwmsResponse2 := &persistence.GetWorkflowExecutionResponse{State: ms2} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse1, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, &persistence.ConditionFailedError{}).Once() s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse2, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( @@ -2894,8 +2900,8 @@ func (s *engineSuite) TestRespondActivityTaskFailedMaxAttemptsExceeded() { activityType := "activity_type1" activityInput := []byte("input1") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) di := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent := addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -2910,7 +2916,7 @@ func (s *engineSuite) TestRespondActivityTaskFailedMaxAttemptsExceeded() { gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, &persistence.ConditionFailedError{}).Once() } @@ -2957,8 +2963,8 @@ func (s *engineSuite) TestRespondActivityTaskFailedSuccess() { failReason := "failed" failDetails := []byte("fail details.") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) di := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent := addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -2972,7 +2978,7 @@ func (s *engineSuite) TestRespondActivityTaskFailedSuccess() { gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( @@ -3032,8 +3038,8 @@ func (s *engineSuite) TestRespondActivityTaskFailedByIDSuccess() { ActivityID: activityID, }) - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) decisionScheduledEvent := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent := addDecisionTaskStartedEvent(msBuilder, decisionScheduledEvent.ScheduleID, tl, identity) @@ -3049,7 +3055,7 @@ func (s *engineSuite) TestRespondActivityTaskFailedByIDSuccess() { s.mockExecutionMgr.On("GetCurrentExecution", mock.Anything).Return(gceResponse, nil).Once() s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( @@ -3106,8 +3112,8 @@ func (s *engineSuite) TestRecordActivityTaskHeartBeatSuccess_NoTimer() { activityType := "activity_type1" activityInput := []byte("input1") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) di := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent := addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -3167,8 +3173,8 @@ func (s *engineSuite) TestRecordActivityTaskHeartBeatSuccess_TimerRunning() { activityType := "activity_type1" activityInput := []byte("input1") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) di := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent := addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -3235,8 +3241,8 @@ func (s *engineSuite) TestRecordActivityTaskHeartBeatByIDSuccess() { ActivityID: activityID, }) - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) di := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent := addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -3296,8 +3302,8 @@ func (s *engineSuite) TestRespondActivityTaskCanceled_Scheduled() { activityType := "activity_type1" activityInput := []byte("input1") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) di := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent := addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -3354,8 +3360,8 @@ func (s *engineSuite) TestRespondActivityTaskCanceled_Started() { activityType := "activity_type1" activityInput := []byte("input1") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) di := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent := addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -3370,7 +3376,7 @@ func (s *engineSuite) TestRespondActivityTaskCanceled_Started() { gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( @@ -3426,8 +3432,8 @@ func (s *engineSuite) TestRespondActivityTaskCanceledByID_Started() { ActivityID: activityID, }) - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) decisionScheduledEvent := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent := addDecisionTaskStartedEvent(msBuilder, decisionScheduledEvent.ScheduleID, tl, identity) @@ -3444,7 +3450,7 @@ func (s *engineSuite) TestRespondActivityTaskCanceledByID_Started() { s.mockExecutionMgr.On("GetCurrentExecution", mock.Anything).Return(gceResponse, nil).Once() s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( @@ -3526,8 +3532,8 @@ func (s *engineSuite) TestRespondActivityTaskCanceledIfNoAIdProvided() { }) identity := "testIdentity" - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), validRunID) ms := createMutableState(msBuilder) gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} gceResponse := &persistence.GetCurrentExecutionResponse{RunID: validRunID} @@ -3568,8 +3574,8 @@ func (s *engineSuite) TestRespondActivityTaskCanceledIfNoAidFound() { }) identity := "testIdentity" - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), validRunID) ms := createMutableState(msBuilder) gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} gceResponse := &persistence.GetCurrentExecutionResponse{RunID: validRunID} @@ -3616,8 +3622,8 @@ func (s *engineSuite) TestRequestCancel_RespondDecisionTaskCompleted_NotSchedule identity := "testIdentity" activityID := "activity1_id" - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) di := addDecisionTaskScheduledEvent(msBuilder) addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -3633,7 +3639,7 @@ func (s *engineSuite) TestRequestCancel_RespondDecisionTaskCompleted_NotSchedule gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( @@ -3684,8 +3690,8 @@ func (s *engineSuite) TestRequestCancel_RespondDecisionTaskCompleted_Scheduled() activityType := "activity_type1" activityInput := []byte("input1") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) di := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent := addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -3707,7 +3713,7 @@ func (s *engineSuite) TestRequestCancel_RespondDecisionTaskCompleted_Scheduled() }} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( @@ -3759,8 +3765,8 @@ func (s *engineSuite) TestRequestCancel_RespondDecisionTaskCompleted_NoHeartBeat activityType := "activity_type1" activityInput := []byte("input1") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) di := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent := addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -3783,7 +3789,7 @@ func (s *engineSuite) TestRequestCancel_RespondDecisionTaskCompleted_NoHeartBeat }} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( @@ -3839,7 +3845,7 @@ func (s *engineSuite) TestRequestCancel_RespondDecisionTaskCompleted_NoHeartBeat s.True(*hbResponse.CancelRequested) // Try cancelling the request. - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( @@ -3890,8 +3896,8 @@ func (s *engineSuite) TestRequestCancel_RespondDecisionTaskCompleted_Success() { activityType := "activity_type1" activityInput := []byte("input1") - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) di := addDecisionTaskScheduledEvent(msBuilder) decisionStartedEvent := addDecisionTaskStartedEvent(msBuilder, di.ScheduleID, tl, identity) @@ -3914,7 +3920,7 @@ func (s *engineSuite) TestRequestCancel_RespondDecisionTaskCompleted_Success() { }} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( @@ -3970,7 +3976,7 @@ func (s *engineSuite) TestRequestCancel_RespondDecisionTaskCompleted_Success() { s.True(*hbResponse.CancelRequested) // Try cancelling the request. - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( @@ -4019,8 +4025,8 @@ func (s *engineSuite) TestStarTimer_DuplicateTimerID() { identity := "testIdentity" timerID := "t1" - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) di := addDecisionTaskScheduledEvent(msBuilder) @@ -4038,7 +4044,7 @@ func (s *engineSuite) TestStarTimer_DuplicateTimerID() { }} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( @@ -4083,8 +4089,8 @@ func (s *engineSuite) TestStarTimer_DuplicateTimerID() { decisionFailedEvent := false s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse2, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Run(func(arguments mock.Arguments) { - req := arguments.Get(0).(*persistence.AppendHistoryEventsRequest) + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Run(func(arguments mock.Arguments) { + req := arguments.Get(0).(*persistence.AppendHistoryNodesRequest) decTaskIndex := len(req.Events) - 1 if decTaskIndex >= 0 && *req.Events[decTaskIndex].EventType == workflow.EventTypeDecisionTaskFailed { decisionFailedEvent = true @@ -4129,8 +4135,8 @@ func (s *engineSuite) TestUserTimer_RespondDecisionTaskCompleted() { identity := "testIdentity" timerID := "t1" - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) // Verify cancel timer with a start event. addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) di := addDecisionTaskScheduledEvent(msBuilder) @@ -4152,7 +4158,7 @@ func (s *engineSuite) TestUserTimer_RespondDecisionTaskCompleted() { }} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( @@ -4202,8 +4208,8 @@ func (s *engineSuite) TestCancelTimer_RespondDecisionTaskCompleted_NoStartTimer( identity := "testIdentity" timerID := "t1" - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) // Verify cancel timer with a start event. addWorkflowExecutionStartedEvent(msBuilder, we, "wType", tl, []byte("input"), 100, 100, identity) di := addDecisionTaskScheduledEvent(msBuilder) @@ -4220,7 +4226,7 @@ func (s *engineSuite) TestCancelTimer_RespondDecisionTaskCompleted_NoStartTimer( }} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( @@ -4279,14 +4285,14 @@ func (s *engineSuite) TestSignalWorkflowExecution() { }, } - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) ms := createMutableState(msBuilder) ms.ExecutionInfo.DomainID = validDomainID gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(gwmsResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return( @@ -4334,8 +4340,8 @@ func (s *engineSuite) TestSignalWorkflowExecution_DuplicateRequest() { }, } - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) ms := createMutableState(msBuilder) // assume duplicate request id ms.SignalRequestedIDs = make(map[string]struct{}) @@ -4388,8 +4394,8 @@ func (s *engineSuite) TestSignalWorkflowExecution_Failed() { }, } - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), we.GetRunId()) ms := createMutableState(msBuilder) ms.ExecutionInfo.State = persistence.WorkflowStateCompleted gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} @@ -4430,8 +4436,8 @@ func (s *engineSuite) TestRemoveSignalMutableState() { RequestId: common.StringPtr(requestID), } - msBuilder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, - bark.NewLoggerFromLogrus(log.New())) + msBuilder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.mockHistoryEngine.shard, s.eventsCache, + bark.NewLoggerFromLogrus(log.New()), validRunID) ms := createMutableState(msBuilder) ms.ExecutionInfo.DomainID = validDomainID gwmsResponse := &persistence.GetWorkflowExecutionResponse{State: ms} @@ -4709,6 +4715,24 @@ func addCompleteWorkflowEvent(builder mutableState, decisionCompletedEventID int return e } +func newMutableStateBuilderWithEventV2(currentCluster string, shard ShardContext, eventsCache eventsCache, + logger bark.Logger, runID string) *mutableStateBuilder { + + msBuilder := newMutableStateBuilder(currentCluster, shard, eventsCache, logger) + _ = msBuilder.SetHistoryTree(runID) + + return msBuilder +} + +func newMutableStateBuilderWithReplicationStateWithEventV2(currentCluster string, shard ShardContext, eventsCache eventsCache, + logger bark.Logger, version int64, runID string) *mutableStateBuilder { + + msBuilder := newMutableStateBuilderWithReplicationState(currentCluster, shard, eventsCache, logger, version) + _ = msBuilder.SetHistoryTree(runID) + + return msBuilder +} + func createMutableState(ms mutableState) *persistence.WorkflowMutableState { builder := ms.(*mutableStateBuilder) builder.FlushBufferedEvents() diff --git a/service/history/historyReplicator_test.go b/service/history/historyReplicator_test.go index 00fcfae5833..197bb0711a5 100644 --- a/service/history/historyReplicator_test.go +++ b/service/history/historyReplicator_test.go @@ -64,7 +64,6 @@ type ( mockMessagingClient messaging.Client mockService service.Service mockShard *shardContextImpl - mockMutableState *mockMutableState mockTxProcessor *MockTransferQueueProcessor mockTimerProcessor *MockTimerQueueProcessor mockClientBean *client.MockClientBean @@ -125,7 +124,6 @@ func (s *historyReplicatorSuite) SetupTest() { s.mockTxProcessor = &MockTransferQueueProcessor{} s.mockTimerProcessor = &MockTimerQueueProcessor{} - s.mockMutableState = &mockMutableState{} historyCache := newHistoryCache(s.mockShard) s.mockClusterMetadata.On("IsGlobalDomainEnabled").Return(true) s.mockClusterMetadata.On("GetCurrentClusterName").Return(cluster.TestCurrentClusterName) @@ -1932,6 +1930,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_BrandNew() { transferTasks := []persistence.Task{&persistence.CloseExecutionTask{}} timerTasks := []persistence.Task{&persistence.DeleteHistoryEventTask{}} + msBuilder.On("GetEventStoreVersion").Return(int32(persistence.EventStoreVersionV2)) msBuilder.On("GetExecutionInfo").Return(&persistence.WorkflowExecutionInfo{ CreateRequestID: requestID, DomainID: domainID, @@ -1945,6 +1944,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_BrandNew() { WorkflowTypeName: workflowType, WorkflowTimeout: workflowTimeout, DecisionTimeoutValue: decisionTimeout, + EventStoreVersion: persistence.EventStoreVersionV2, }) msBuilder.On("UpdateReplicationStateLastEventID", sourceCluster, version, nextEventID-1).Once() msBuilder.On("GetReplicationState").Return(replicationState) @@ -1953,7 +1953,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_BrandNew() { msBuilder.On("GetCurrentBranch").Return(nil) historySize := 111 msBuilder.On("GetEventStoreVersion").Return(int32(0)) - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: historySize}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: historySize}, nil).Once() sBuilder.On("getTransferTasks").Return(transferTasks) sBuilder.On("getTimerTasks").Return(timerTasks) s.mockExecutionMgr.On("CreateWorkflowExecution", mock.MatchedBy(func(input *persistence.CreateWorkflowExecutionRequest) bool { @@ -1987,6 +1987,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_BrandNew() { CreateWorkflowMode: persistence.CreateWorkflowModeBrandNew, PreviousRunID: "", ReplicationState: replicationState, + EventStoreVersion: persistence.EventStoreVersionV2, }, input) return true })).Return(&persistence.CreateWorkflowExecutionResponse{}, nil).Once() @@ -2054,6 +2055,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_ISE() { transferTasks := []persistence.Task{&persistence.CloseExecutionTask{}} timerTasks := []persistence.Task{&persistence.DeleteHistoryEventTask{}} + msBuilder.On("GetEventStoreVersion").Return(int32(persistence.EventStoreVersionV2)) msBuilder.On("GetExecutionInfo").Return(&persistence.WorkflowExecutionInfo{ CreateRequestID: requestID, DomainID: domainID, @@ -2067,6 +2069,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_ISE() { WorkflowTypeName: workflowType, WorkflowTimeout: workflowTimeout, DecisionTimeoutValue: decisionTimeout, + EventStoreVersion: persistence.EventStoreVersionV2, }) msBuilder.On("UpdateReplicationStateLastEventID", sourceCluster, version, nextEventID-1).Once() msBuilder.On("GetReplicationState").Return(replicationState) @@ -2075,7 +2078,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_ISE() { msBuilder.On("GetCurrentBranch").Return(nil) historySize := 111 msBuilder.On("GetEventStoreVersion").Return(int32(0)) - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: historySize}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: historySize}, nil).Once() sBuilder.On("getTransferTasks").Return(transferTasks) sBuilder.On("getTimerTasks").Return(timerTasks) s.mockShardManager.On("UpdateShard", mock.Anything).Return(nil).Once() // this is called when err is returned, and shard will try to update @@ -2146,6 +2149,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_SameRunID() { transferTasks := []persistence.Task{&persistence.CloseExecutionTask{}} timerTasks := []persistence.Task{&persistence.DeleteHistoryEventTask{}} + msBuilder.On("GetEventStoreVersion").Return(int32(persistence.EventStoreVersionV2)) msBuilder.On("GetExecutionInfo").Return(&persistence.WorkflowExecutionInfo{ CreateRequestID: requestID, DomainID: domainID, @@ -2159,6 +2163,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_SameRunID() { WorkflowTypeName: workflowType, WorkflowTimeout: workflowTimeout, DecisionTimeoutValue: decisionTimeout, + EventStoreVersion: persistence.EventStoreVersionV2, }) msBuilder.On("UpdateReplicationStateLastEventID", sourceCluster, version, nextEventID-1).Once() msBuilder.On("GetReplicationState").Return(replicationState) @@ -2167,7 +2172,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_SameRunID() { msBuilder.On("GetCurrentBranch").Return(nil) historySize := 111 msBuilder.On("GetEventStoreVersion").Return(int32(0)) - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: historySize}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: historySize}, nil).Once() sBuilder.On("getTransferTasks").Return(transferTasks) sBuilder.On("getTimerTasks").Return(timerTasks) @@ -2245,6 +2250,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentComplete_In transferTasks := []persistence.Task{&persistence.CloseExecutionTask{}} timerTasks := []persistence.Task{&persistence.DeleteHistoryEventTask{}} + msBuilder.On("GetEventStoreVersion").Return(int32(persistence.EventStoreVersionV2)) msBuilder.On("GetExecutionInfo").Return(&persistence.WorkflowExecutionInfo{ CreateRequestID: requestID, DomainID: domainID, @@ -2258,6 +2264,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentComplete_In WorkflowTypeName: workflowType, WorkflowTimeout: workflowTimeout, DecisionTimeoutValue: decisionTimeout, + EventStoreVersion: persistence.EventStoreVersionV2, }) msBuilder.On("UpdateReplicationStateLastEventID", sourceCluster, version, nextEventID-1).Once() msBuilder.On("GetReplicationState").Return(replicationState) @@ -2266,7 +2273,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentComplete_In msBuilder.On("GetCurrentBranch").Return(nil) historySize := 111 msBuilder.On("GetEventStoreVersion").Return(int32(0)) - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: historySize}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: historySize}, nil).Once() sBuilder.On("getTransferTasks").Return(transferTasks) sBuilder.On("getTimerTasks").Return(timerTasks) @@ -2310,6 +2317,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentComplete_In CreateWorkflowMode: persistence.CreateWorkflowModeBrandNew, PreviousRunID: "", ReplicationState: replicationState, + EventStoreVersion: persistence.EventStoreVersionV2, }, input) })).Return(nil, errRet).Once() s.mockExecutionMgr.On("CreateWorkflowExecution", mock.MatchedBy(func(input *persistence.CreateWorkflowExecutionRequest) bool { @@ -2344,6 +2352,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentComplete_In PreviousRunID: currentRunID, PreviousLastWriteVersion: currentVersion, ReplicationState: replicationState, + EventStoreVersion: persistence.EventStoreVersionV2, }, input) })).Return(&persistence.CreateWorkflowExecutionResponse{}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return(&persistence.GetDomainResponse{ @@ -2411,6 +2420,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentComplete_In transferTasks := []persistence.Task{&persistence.CloseExecutionTask{}} timerTasks := []persistence.Task{&persistence.DeleteHistoryEventTask{}} + msBuilder.On("GetEventStoreVersion").Return(int32(persistence.EventStoreVersionV2)) msBuilder.On("GetExecutionInfo").Return(&persistence.WorkflowExecutionInfo{ CreateRequestID: requestID, DomainID: domainID, @@ -2424,6 +2434,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentComplete_In WorkflowTypeName: workflowType, WorkflowTimeout: workflowTimeout, DecisionTimeoutValue: decisionTimeout, + EventStoreVersion: persistence.EventStoreVersionV2, }) msBuilder.On("UpdateReplicationStateLastEventID", sourceCluster, version, nextEventID-1).Once() msBuilder.On("GetReplicationState").Return(replicationState) @@ -2432,7 +2443,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentComplete_In msBuilder.On("GetCurrentBranch").Return(nil) historySize := 111 msBuilder.On("GetEventStoreVersion").Return(int32(0)) - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: historySize}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: historySize}, nil).Once() sBuilder.On("getTransferTasks").Return(transferTasks) sBuilder.On("getTimerTasks").Return(timerTasks) @@ -2476,6 +2487,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentComplete_In CreateWorkflowMode: persistence.CreateWorkflowModeBrandNew, PreviousRunID: "", ReplicationState: replicationState, + EventStoreVersion: persistence.EventStoreVersionV2, }, input) })).Return(nil, errRet).Once() s.mockExecutionMgr.On("CreateWorkflowExecution", mock.MatchedBy(func(input *persistence.CreateWorkflowExecutionRequest) bool { @@ -2510,6 +2522,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentComplete_In PreviousRunID: currentRunID, PreviousLastWriteVersion: currentVersion, ReplicationState: replicationState, + EventStoreVersion: persistence.EventStoreVersionV2, }, input) })).Return(&persistence.CreateWorkflowExecutionResponse{}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return(&persistence.GetDomainResponse{ @@ -2577,6 +2590,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentComplete_In transferTasks := []persistence.Task{&persistence.CloseExecutionTask{}} timerTasks := []persistence.Task{&persistence.DeleteHistoryEventTask{}} + msBuilder.On("GetEventStoreVersion").Return(int32(persistence.EventStoreVersionV2)) msBuilder.On("GetExecutionInfo").Return(&persistence.WorkflowExecutionInfo{ CreateRequestID: requestID, DomainID: domainID, @@ -2590,6 +2604,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentComplete_In WorkflowTypeName: workflowType, WorkflowTimeout: workflowTimeout, DecisionTimeoutValue: decisionTimeout, + EventStoreVersion: persistence.EventStoreVersionV2, }) msBuilder.On("UpdateReplicationStateLastEventID", sourceCluster, version, nextEventID-1).Once() msBuilder.On("GetReplicationState").Return(replicationState) @@ -2598,7 +2613,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentComplete_In msBuilder.On("GetCurrentBranch").Return(nil) historySize := 111 msBuilder.On("GetEventStoreVersion").Return(int32(0)) - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: historySize}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: historySize}, nil).Once() sBuilder.On("getTransferTasks").Return(transferTasks) sBuilder.On("getTimerTasks").Return(timerTasks) @@ -2642,6 +2657,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentComplete_In CreateWorkflowMode: persistence.CreateWorkflowModeBrandNew, PreviousRunID: "", ReplicationState: replicationState, + EventStoreVersion: persistence.EventStoreVersionV2, }, input) })).Return(nil, errRet).Once() s.mockExecutionMgr.On("CreateWorkflowExecution", mock.MatchedBy(func(input *persistence.CreateWorkflowExecutionRequest) bool { @@ -2676,6 +2692,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentComplete_In PreviousRunID: currentRunID, PreviousLastWriteVersion: currentVersion, ReplicationState: replicationState, + EventStoreVersion: persistence.EventStoreVersionV2, }, input) })).Return(&persistence.CreateWorkflowExecutionResponse{}, nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return(&persistence.GetDomainResponse{ @@ -2742,6 +2759,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentRunning_Inc transferTasks := []persistence.Task{&persistence.CloseExecutionTask{}} timerTasks := []persistence.Task{&persistence.DeleteHistoryEventTask{}} + msBuilder.On("GetEventStoreVersion").Return(int32(persistence.EventStoreVersionV2)) msBuilder.On("GetExecutionInfo").Return(&persistence.WorkflowExecutionInfo{ CreateRequestID: requestID, DomainID: domainID, @@ -2755,6 +2773,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentRunning_Inc WorkflowTypeName: workflowType, WorkflowTimeout: workflowTimeout, DecisionTimeoutValue: decisionTimeout, + EventStoreVersion: persistence.EventStoreVersionV2, }) msBuilder.On("UpdateReplicationStateLastEventID", sourceCluster, version, nextEventID-1).Once() msBuilder.On("GetReplicationState").Return(replicationState) @@ -2763,7 +2782,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentRunning_Inc msBuilder.On("GetCurrentBranch").Return(nil) historySize := 111 msBuilder.On("GetEventStoreVersion").Return(int32(0)) - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: historySize}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: historySize}, nil).Once() sBuilder.On("getTransferTasks").Return(transferTasks) sBuilder.On("getTimerTasks").Return(timerTasks) @@ -2777,7 +2796,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentRunning_Inc } // the test above already assert the create workflow request, so here just use anyting s.mockExecutionMgr.On("CreateWorkflowExecution", mock.Anything).Return(nil, errRet).Once() - s.mockHistoryMgr.On("DeleteWorkflowExecutionHistory", mock.Anything).Return(nil).Once() + s.mockHistoryV2Mgr.On("DeleteHistoryBranch", mock.Anything).Return(nil).Once() s.mockMetadataMgr.On("GetDomain", mock.Anything).Return(&persistence.GetDomainResponse{ Info: &persistence.DomainInfo{ID: domainID, Name: "domain name"}, TableVersion: p.DomainTableVersionV1, @@ -2841,6 +2860,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentRunning_Inc transferTasks := []persistence.Task{&persistence.CloseExecutionTask{}} timerTasks := []persistence.Task{&persistence.DeleteHistoryEventTask{}} + msBuilder.On("GetEventStoreVersion").Return(int32(persistence.EventStoreVersionV2)) msBuilder.On("GetExecutionInfo").Return(&persistence.WorkflowExecutionInfo{ CreateRequestID: requestID, DomainID: domainID, @@ -2854,6 +2874,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentRunning_Inc WorkflowTypeName: workflowType, WorkflowTimeout: workflowTimeout, DecisionTimeoutValue: decisionTimeout, + EventStoreVersion: persistence.EventStoreVersionV2, }) msBuilder.On("UpdateReplicationStateLastEventID", sourceCluster, version, nextEventID-1).Once() msBuilder.On("GetReplicationState").Return(replicationState) @@ -2862,7 +2883,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentRunning_Inc msBuilder.On("GetCurrentBranch").Return(nil) historySize := 111 msBuilder.On("GetEventStoreVersion").Return(int32(0)) - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: historySize}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: historySize}, nil).Once() sBuilder.On("getTransferTasks").Return(transferTasks) sBuilder.On("getTimerTasks").Return(timerTasks) @@ -2979,6 +3000,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentRunning_Inc transferTasks := []persistence.Task{&persistence.CloseExecutionTask{}} timerTasks := []persistence.Task{&persistence.DeleteHistoryEventTask{}} + msBuilder.On("GetEventStoreVersion").Return(int32(persistence.EventStoreVersionV2)) msBuilder.On("GetExecutionInfo").Return(&persistence.WorkflowExecutionInfo{ CreateRequestID: requestID, LastEventTaskID: lastEventTaskID, @@ -2993,6 +3015,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentRunning_Inc WorkflowTypeName: workflowType, WorkflowTimeout: workflowTimeout, DecisionTimeoutValue: decisionTimeout, + EventStoreVersion: persistence.EventStoreVersionV2, }) msBuilder.On("UpdateReplicationStateLastEventID", sourceCluster, version, nextEventID-1).Once() msBuilder.On("GetReplicationState").Return(replicationState) @@ -3001,7 +3024,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentRunning_Inc msBuilder.On("GetCurrentBranch").Return(nil) historySize := 111 msBuilder.On("GetEventStoreVersion").Return(int32(0)) - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: historySize}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: historySize}, nil).Once() sBuilder.On("getTransferTasks").Return(transferTasks) sBuilder.On("getTimerTasks").Return(timerTasks) @@ -3119,6 +3142,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentRunning_Inc transferTasks := []persistence.Task{&persistence.CloseExecutionTask{}} timerTasks := []persistence.Task{&persistence.DeleteHistoryEventTask{}} + msBuilder.On("GetEventStoreVersion").Return(int32(persistence.EventStoreVersionV2)) msBuilder.On("GetExecutionInfo").Return(&persistence.WorkflowExecutionInfo{ CreateRequestID: requestID, DomainID: domainID, @@ -3132,6 +3156,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentRunning_Inc WorkflowTypeName: workflowType, WorkflowTimeout: workflowTimeout, DecisionTimeoutValue: decisionTimeout, + EventStoreVersion: persistence.EventStoreVersionV2, }) msBuilder.On("UpdateReplicationStateLastEventID", sourceCluster, version, nextEventID-1).Once() msBuilder.On("GetReplicationState").Return(replicationState) @@ -3140,7 +3165,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentRunning_Inc msBuilder.On("GetCurrentBranch").Return(nil) historySize := 111 msBuilder.On("GetEventStoreVersion").Return(int32(0)) - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: historySize}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: historySize}, nil).Once() sBuilder.On("getTransferTasks").Return(transferTasks) sBuilder.On("getTimerTasks").Return(timerTasks) @@ -3184,6 +3209,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentRunning_Inc CreateWorkflowMode: persistence.CreateWorkflowModeBrandNew, PreviousRunID: "", ReplicationState: replicationState, + EventStoreVersion: persistence.EventStoreVersionV2, }, input) })).Return(nil, errRet).Once() s.mockExecutionMgr.On("CreateWorkflowExecution", mock.MatchedBy(func(input *persistence.CreateWorkflowExecutionRequest) bool { @@ -3218,6 +3244,7 @@ func (s *historyReplicatorSuite) TestReplicateWorkflowStarted_CurrentRunning_Inc PreviousRunID: currentRunID, PreviousLastWriteVersion: version, ReplicationState: replicationState, + EventStoreVersion: persistence.EventStoreVersionV2, }, input) })).Return(&persistence.CreateWorkflowExecutionResponse{}, nil).Once() diff --git a/service/history/service.go b/service/history/service.go index 562bdc0f769..a2ae20cfd91 100644 --- a/service/history/service.go +++ b/service/history/service.go @@ -208,8 +208,8 @@ func NewConfig(dc *dynamicconfig.Collection, numberOfShards int, enableVisibilit // history client: client/history/client.go set the client timeout 30s LongPollExpirationInterval: dc.GetDurationPropertyFilteredByDomain(dynamicconfig.HistoryLongPollExpirationInterval, time.Second*20), - EventEncodingType: dc.GetStringPropertyFnWithDomainFilter(dynamicconfig.DefaultEventEncoding, string(common.EncodingTypeJSON)), - EnableEventsV2: dc.GetBoolPropertyFnWithDomainFilter(dynamicconfig.EnableEventsV2, false), + EventEncodingType: dc.GetStringPropertyFnWithDomainFilter(dynamicconfig.DefaultEventEncoding, string(common.EncodingTypeThriftRW)), + EnableEventsV2: dc.GetBoolPropertyFnWithDomainFilter(dynamicconfig.EnableEventsV2, true), NumArchiveSystemWorkflows: dc.GetIntProperty(dynamicconfig.NumArchiveSystemWorkflows, 1000), diff --git a/service/history/timerQueueProcessor2_test.go b/service/history/timerQueueProcessor2_test.go index ecdaa0ab428..23303770213 100644 --- a/service/history/timerQueueProcessor2_test.go +++ b/service/history/timerQueueProcessor2_test.go @@ -60,6 +60,7 @@ type ( mockVisibilityMgr *mocks.VisibilityManager mockExecutionMgr *mocks.ExecutionManager mockHistoryMgr *mocks.HistoryManager + mockHistoryV2Mgr *mocks.HistoryV2Manager mockShard ShardContext mockClusterMetadata *mocks.ClusterMetadata mockProducer *mocks.KafkaProducer @@ -93,6 +94,7 @@ func (s *timerQueueProcessor2Suite) SetupTest() { s.mockExecutionMgr = &mocks.ExecutionManager{} s.mockShardManager = &mocks.ShardManager{} s.mockHistoryMgr = &mocks.HistoryManager{} + s.mockHistoryV2Mgr = &mocks.HistoryV2Manager{} s.mockVisibilityMgr = &mocks.VisibilityManager{} s.mockMetadataMgr = &mocks.MetadataManager{} s.mockClusterMetadata = &mocks.ClusterMetadata{} @@ -127,6 +129,7 @@ func (s *timerQueueProcessor2Suite) SetupTest() { executionManager: s.mockExecutionMgr, shardManager: s.mockShardManager, historyMgr: s.mockHistoryMgr, + historyV2Mgr: s.mockHistoryV2Mgr, maxTransferSequenceNumber: 100000, closeCh: s.shardClosedCh, config: s.config, @@ -147,6 +150,7 @@ func (s *timerQueueProcessor2Suite) SetupTest() { currentClusterName: s.mockShard.GetService().GetClusterMetadata().GetCurrentClusterName(), shard: s.mockShard, historyMgr: s.mockHistoryMgr, + historyV2Mgr: s.mockHistoryV2Mgr, executionManager: s.mockExecutionMgr, historyCache: historyCache, logger: s.logger, @@ -163,6 +167,7 @@ func (s *timerQueueProcessor2Suite) TearDownTest() { s.mockMatchingClient.AssertExpectations(s.T()) s.mockExecutionMgr.AssertExpectations(s.T()) s.mockHistoryMgr.AssertExpectations(s.T()) + s.mockHistoryV2Mgr.AssertExpectations(s.T()) s.mockVisibilityMgr.AssertExpectations(s.T()) s.mockProducer.AssertExpectations(s.T()) s.mockClientBean.AssertExpectations(s.T()) @@ -176,7 +181,7 @@ func (s *timerQueueProcessor2Suite) TestTimerUpdateTimesOut() { taskList := "user-timer-update-times-out" - builder := newMutableStateBuilder(cluster.TestCurrentClusterName, s.mockHistoryEngine.shard, s.mockEventsCache, s.logger) + builder := newMutableStateBuilderWithEventV2(cluster.TestCurrentClusterName, s.mockShard, s.mockEventsCache, s.logger, we.GetRunId()) startRequest := &workflow.StartWorkflowExecutionRequest{ WorkflowType: &workflow.WorkflowType{Name: common.StringPtr("wType")}, TaskList: common.TaskListPtr(workflow.TaskList{Name: common.StringPtr(taskList)}), @@ -217,11 +222,11 @@ func (s *timerQueueProcessor2Suite) TestTimerUpdateTimesOut() { s.mockExecutionMgr.On("GetTimerIndexTasks", mock.Anything).Return( &persistence.GetTimerIndexTasksResponse{Timers: []*persistence.TimerTaskInfo{}}, nil) - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, errors.New("FAILED")).Once() s.mockShardManager.On("UpdateShard", mock.Anything).Return(nil) - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Run(func(arguments mock.Arguments) { // Done. waitCh <- struct{}{} @@ -248,7 +253,7 @@ func (s *timerQueueProcessor2Suite) TestWorkflowTimeout() { RunId: common.StringPtr(validRunID)} taskList := "task-workflow-times-out" - builder := newMutableStateBuilder(cluster.TestCurrentClusterName, s.mockHistoryEngine.shard, s.mockEventsCache, s.logger) + builder := newMutableStateBuilderWithEventV2(cluster.TestCurrentClusterName, s.mockShard, s.mockEventsCache, s.logger, we.GetRunId()) startRequest := &workflow.StartWorkflowExecutionRequest{ WorkflowType: &workflow.WorkflowType{Name: common.StringPtr("wType")}, TaskList: common.TaskListPtr(workflow.TaskList{Name: common.StringPtr(taskList)}), @@ -282,7 +287,7 @@ func (s *timerQueueProcessor2Suite) TestWorkflowTimeout() { wfResponse := &persistence.GetWorkflowExecutionResponse{State: ms} s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(wfResponse, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Run(func(arguments mock.Arguments) { // Done. waitCh <- struct{}{} diff --git a/service/history/timerQueueProcessor_test.go b/service/history/timerQueueProcessor_test.go index 4f69cc8c5b8..a24e6ed8697 100644 --- a/service/history/timerQueueProcessor_test.go +++ b/service/history/timerQueueProcessor_test.go @@ -144,8 +144,8 @@ func (s *timerQueueProcessorSuite) createExecutionWithTimers(domainID string, we identity string, timeOuts []int32) (*persistence.WorkflowMutableState, []persistence.Task) { // Generate first decision task event. - builder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, - s.ShardContext.GetEventsCache(), s.logger) + builder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, + s.ShardContext.GetEventsCache(), s.logger, we.GetRunId()) addWorkflowExecutionStartedEvent(builder, we, "wType", tl, []byte("input"), 100, 200, identity) di := addDecisionTaskScheduledEvent(builder) @@ -159,8 +159,8 @@ func (s *timerQueueProcessorSuite) createExecutionWithTimers(domainID string, we state0, err2 := s.GetWorkflowExecutionInfo(domainID, we) s.NoError(err2, "No error expected.") - builder = newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, - s.ShardContext.GetEventsCache(), s.logger) + builder = newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, + s.ShardContext.GetEventsCache(), s.logger, we.GetRunId()) builder.Load(state0) startedEvent := addDecisionTaskStartedEvent(builder, di.ScheduleID, tl, identity) addDecisionTaskCompletedEvent(builder, di.ScheduleID, *startedEvent.EventId, nil, identity) @@ -198,8 +198,8 @@ func (s *timerQueueProcessorSuite) addDecisionTimer(domainID string, we workflow s.NoError(err) condition := state.ExecutionInfo.NextEventID - builder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, - s.ShardContext.GetEventsCache(), s.logger) + builder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, + s.ShardContext.GetEventsCache(), s.logger, we.GetRunId()) builder.Load(state) di := addDecisionTaskScheduledEvent(builder) @@ -220,8 +220,8 @@ func (s *timerQueueProcessorSuite) addDecisionTimer(domainID string, we workflow func (s *timerQueueProcessorSuite) addUserTimer(domainID string, we workflow.WorkflowExecution, timerID string, tb *timerBuilder) []persistence.Task { state, err := s.GetWorkflowExecutionInfo(domainID, we) s.NoError(err) - builder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, - s.ShardContext.GetEventsCache(), s.logger) + builder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, + s.ShardContext.GetEventsCache(), s.logger, we.GetRunId()) builder.Load(state) condition := state.ExecutionInfo.NextEventID @@ -241,8 +241,8 @@ func (s *timerQueueProcessorSuite) addHeartBeatTimer(domainID string, we workflow.WorkflowExecution, tb *timerBuilder) (*workflow.HistoryEvent, []persistence.Task) { state, err := s.GetWorkflowExecutionInfo(domainID, we) s.NoError(err) - builder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, - s.ShardContext.GetEventsCache(), s.logger) + builder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, + s.ShardContext.GetEventsCache(), s.logger, we.GetRunId()) builder.Load(state) condition := state.ExecutionInfo.NextEventID @@ -362,8 +362,8 @@ func (s *timerQueueProcessorSuite) checkTimedOutEventFor(domainID string, we wor scheduleID int64) bool { info, err1 := s.GetWorkflowExecutionInfo(domainID, we) s.NoError(err1) - builder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, - s.ShardContext.GetEventsCache(), s.logger) + builder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, + s.ShardContext.GetEventsCache(), s.logger, we.GetRunId()) builder.Load(info) _, isRunning := builder.GetActivityInfo(scheduleID) @@ -374,8 +374,8 @@ func (s *timerQueueProcessorSuite) checkTimedOutEventForUserTimer(domainID strin timerID string) bool { info, err1 := s.GetWorkflowExecutionInfo(domainID, we) s.NoError(err1) - builder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, - s.ShardContext.GetEventsCache(), s.logger) + builder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, + s.ShardContext.GetEventsCache(), s.logger, we.GetRunId()) builder.Load(info) isRunning, _ := builder.GetUserTimer(timerID) @@ -417,8 +417,8 @@ func (s *timerQueueProcessorSuite) TestTimerActivityTaskScheduleToStart_WithOutS state, err := s.GetWorkflowExecutionInfo(domainID, workflowExecution) s.NoError(err) - builder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, - s.ShardContext.GetEventsCache(), s.logger) + builder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, + s.ShardContext.GetEventsCache(), s.logger, workflowExecution.GetRunId()) builder.Load(state) condition := state.ExecutionInfo.NextEventID @@ -461,8 +461,8 @@ func (s *timerQueueProcessorSuite) TestTimerActivityTaskScheduleToStart_WithStar state, err := s.GetWorkflowExecutionInfo(domainID, workflowExecution) s.NoError(err) - builder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, - s.ShardContext.GetEventsCache(), s.logger) + builder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, + s.ShardContext.GetEventsCache(), s.logger, workflowExecution.GetRunId()) builder.Load(state) condition := state.ExecutionInfo.NextEventID @@ -507,8 +507,8 @@ func (s *timerQueueProcessorSuite) TestTimerActivityTaskScheduleToStart_MoreThan state, err := s.GetWorkflowExecutionInfo(domainID, workflowExecution) s.NoError(err) - builder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, - s.ShardContext.GetEventsCache(), s.logger) + builder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, + s.ShardContext.GetEventsCache(), s.logger, workflowExecution.GetRunId()) builder.Load(state) condition := state.ExecutionInfo.NextEventID @@ -553,8 +553,8 @@ func (s *timerQueueProcessorSuite) TestTimerActivityTaskStartToClose_WithStart() state, err := s.GetWorkflowExecutionInfo(domainID, workflowExecution) s.NoError(err) - builder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, - s.ShardContext.GetEventsCache(), s.logger) + builder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, + s.ShardContext.GetEventsCache(), s.logger, workflowExecution.GetRunId()) builder.Load(state) condition := state.ExecutionInfo.NextEventID @@ -597,8 +597,8 @@ func (s *timerQueueProcessorSuite) TestTimerActivityTaskStartToClose_CompletedAc state, err := s.GetWorkflowExecutionInfo(domainID, workflowExecution) s.NoError(err) - builder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, - s.ShardContext.GetEventsCache(), s.logger) + builder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, + s.ShardContext.GetEventsCache(), s.logger, workflowExecution.GetRunId()) builder.Load(state) condition := state.ExecutionInfo.NextEventID @@ -646,8 +646,8 @@ func (s *timerQueueProcessorSuite) TestTimerActivityTaskScheduleToClose_JustSche state, err := s.GetWorkflowExecutionInfo(domainID, workflowExecution) s.NoError(err) - builder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, - s.ShardContext.GetEventsCache(), s.logger) + builder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, + s.ShardContext.GetEventsCache(), s.logger, workflowExecution.GetRunId()) builder.Load(state) condition := state.ExecutionInfo.NextEventID @@ -690,8 +690,8 @@ func (s *timerQueueProcessorSuite) TestTimerActivityTaskScheduleToClose_Started( state, err := s.GetWorkflowExecutionInfo(domainID, workflowExecution) s.NoError(err) - builder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, - s.ShardContext.GetEventsCache(), s.logger) + builder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, + s.ShardContext.GetEventsCache(), s.logger, workflowExecution.GetRunId()) builder.Load(state) condition := state.ExecutionInfo.NextEventID @@ -736,8 +736,8 @@ func (s *timerQueueProcessorSuite) TestTimerActivityTaskScheduleToClose_Complete state, err := s.GetWorkflowExecutionInfo(domainID, workflowExecution) s.NoError(err) - builder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, - s.ShardContext.GetEventsCache(), s.logger) + builder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, + s.ShardContext.GetEventsCache(), s.logger, workflowExecution.GetRunId()) builder.Load(state) condition := state.ExecutionInfo.NextEventID @@ -812,8 +812,8 @@ func (s *timerQueueProcessorSuite) TestTimerActivityTask_SameExpiry() { state, err := s.GetWorkflowExecutionInfo(domainID, workflowExecution) s.NoError(err) - builder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, - s.ShardContext.GetEventsCache(), s.logger) + builder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, + s.ShardContext.GetEventsCache(), s.logger, workflowExecution.GetRunId()) builder.Load(state) condition := state.ExecutionInfo.NextEventID @@ -858,8 +858,8 @@ func (s *timerQueueProcessorSuite) TestTimerActivityTask_SameExpiry() { // assert activity infos are deleted state, err = s.GetWorkflowExecutionInfo(domainID, workflowExecution) s.NoError(err) - builder = newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, - s.ShardContext.GetEventsCache(), s.logger) + builder = newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, + s.ShardContext.GetEventsCache(), s.logger, workflowExecution.GetRunId()) builder.Load(state) s.Equal(0, len(builder.pendingActivityInfoIDs)) } @@ -901,8 +901,8 @@ func (s *timerQueueProcessorSuite) TestTimerUserTimers_SameExpiry() { state, err := s.GetWorkflowExecutionInfo(domainID, workflowExecution) s.NoError(err) - builder := newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, - s.ShardContext.GetEventsCache(), s.logger) + builder := newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, + s.ShardContext.GetEventsCache(), s.logger, workflowExecution.GetRunId()) builder.Load(state) condition := state.ExecutionInfo.NextEventID @@ -935,8 +935,8 @@ func (s *timerQueueProcessorSuite) TestTimerUserTimers_SameExpiry() { // assert user timer infos are deleted state, err = s.GetWorkflowExecutionInfo(domainID, workflowExecution) s.NoError(err) - builder = newMutableStateBuilder(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, - s.ShardContext.GetEventsCache(), s.logger) + builder = newMutableStateBuilderWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), s.ShardContext, + s.ShardContext.GetEventsCache(), s.logger, workflowExecution.GetRunId()) builder.Load(state) s.Equal(0, len(builder.pendingTimerInfoIDs)) } diff --git a/service/history/timerQueueStandbyProcessor_test.go b/service/history/timerQueueStandbyProcessor_test.go index fad50b706ef..cb2ae5a3392 100644 --- a/service/history/timerQueueStandbyProcessor_test.go +++ b/service/history/timerQueueStandbyProcessor_test.go @@ -178,12 +178,13 @@ func (s *timerQueueStandbyProcessorSuite) TestProcessExpiredUserTimer_Pending() taskListName := "some random task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState( + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2( s.mockClusterMetadata.GetCurrentClusterName(), s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, + execution.GetRunId(), ) msBuilder.AddWorkflowExecutionStartedEvent( execution, @@ -248,8 +249,8 @@ func (s *timerQueueStandbyProcessorSuite) TestProcessExpiredUserTimer_Success() taskListName := "some random task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -305,8 +306,8 @@ func (s *timerQueueStandbyProcessorSuite) TestProcessExpiredUserTimer_Multiple() taskListName := "some random task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -368,8 +369,8 @@ func (s *timerQueueStandbyProcessorSuite) TestProcessActivityTimeout_Pending() { taskListName := "some random task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -436,8 +437,8 @@ func (s *timerQueueStandbyProcessorSuite) TestProcessActivityTimeout_Success() { taskListName := "some random task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -501,8 +502,8 @@ func (s *timerQueueStandbyProcessorSuite) TestProcessActivityTimeout_Multiple_Ca taskListName := "some random task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -597,7 +598,7 @@ func (s *timerQueueStandbyProcessorSuite) TestProcessActivityTimeout_Multiple_Ca ContinueAsNew: nil, FinishExecution: false, FinishedExecutionTTL: 0, - Encoding: common.EncodingType("json"), + Encoding: common.EncodingType(s.mockShard.GetConfig().EventEncodingType(domainID)), }, input) return true })).Return(&persistence.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &persistence.MutableStateUpdateSessionStats{}}, nil).Once() @@ -616,8 +617,8 @@ func (s *timerQueueStandbyProcessorSuite) TestProcessDecisionTimeout_Pending() { taskListName := "some random task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -673,8 +674,8 @@ func (s *timerQueueStandbyProcessorSuite) TestProcessDecisionTimeout_Success() { taskListName := "some random task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -722,8 +723,8 @@ func (s *timerQueueStandbyProcessorSuite) TestProcessWorkflowBackoffTimer_Pendin taskListName := "some random task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) event := msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -774,8 +775,8 @@ func (s *timerQueueStandbyProcessorSuite) TestProcessWorkflowBackoffTimer_Succes taskListName := "some random task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -818,8 +819,8 @@ func (s *timerQueueStandbyProcessorSuite) TestProcessWorkflowTimeout_Pending() { taskListName := "some random task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -876,8 +877,8 @@ func (s *timerQueueStandbyProcessorSuite) TestProcessWorkflowTimeout_Success() { taskListName := "some random task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -925,8 +926,8 @@ func (s *timerQueueStandbyProcessorSuite) TestProcessRetryTimeout() { taskListName := "some random task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ diff --git a/service/history/transferQueueActiveProcessor_test.go b/service/history/transferQueueActiveProcessor_test.go index d1cd3d9bf26..66e8598db73 100644 --- a/service/history/transferQueueActiveProcessor_test.go +++ b/service/history/transferQueueActiveProcessor_test.go @@ -58,6 +58,7 @@ type ( mockVisibilityMgr *mocks.VisibilityManager mockExecutionMgr *mocks.ExecutionManager mockHistoryMgr *mocks.HistoryManager + mockHistoryV2Mgr *mocks.HistoryV2Manager mockMatchingClient *mocks.MatchingClient mockHistoryClient *mocks.HistoryClient mockShard ShardContext @@ -98,6 +99,7 @@ func (s *transferQueueActiveProcessorSuite) SetupTest() { s.mockShardManager = &mocks.ShardManager{} s.mockExecutionMgr = &mocks.ExecutionManager{} s.mockHistoryMgr = &mocks.HistoryManager{} + s.mockHistoryV2Mgr = &mocks.HistoryV2Manager{} s.mockVisibilityMgr = &mocks.VisibilityManager{} s.mockMatchingClient = &mocks.MatchingClient{} s.mockHistoryClient = &mocks.HistoryClient{} @@ -133,6 +135,7 @@ func (s *transferQueueActiveProcessorSuite) SetupTest() { executionManager: s.mockExecutionMgr, shardManager: s.mockShardManager, historyMgr: s.mockHistoryMgr, + historyV2Mgr: s.mockHistoryV2Mgr, maxTransferSequenceNumber: 100000, closeCh: make(chan int, 100), config: NewDynamicConfigForTest(), @@ -149,6 +152,7 @@ func (s *transferQueueActiveProcessorSuite) SetupTest() { currentClusterName: s.mockShard.GetService().GetClusterMetadata().GetCurrentClusterName(), shard: s.mockShard, historyMgr: s.mockHistoryMgr, + historyV2Mgr: s.mockHistoryV2Mgr, executionManager: s.mockExecutionMgr, historyCache: historyCache, logger: s.logger, @@ -168,6 +172,7 @@ func (s *transferQueueActiveProcessorSuite) TearDownTest() { s.mockShardManager.AssertExpectations(s.T()) s.mockExecutionMgr.AssertExpectations(s.T()) s.mockHistoryMgr.AssertExpectations(s.T()) + s.mockHistoryV2Mgr.AssertExpectations(s.T()) s.mockMatchingClient.AssertExpectations(s.T()) s.mockHistoryClient.AssertExpectations(s.T()) s.mockVisibilityMgr.AssertExpectations(s.T()) @@ -188,8 +193,8 @@ func (s *transferQueueActiveProcessorSuite) TestProcessActivityTask_Success() { workflowType := "some random workflow type" taskListName := "some random task list" - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -244,8 +249,8 @@ func (s *transferQueueActiveProcessorSuite) TestProcessActivityTask_Duplication( workflowType := "some random workflow type" taskListName := "some random task list" - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -302,8 +307,8 @@ func (s *transferQueueActiveProcessorSuite) TestProcessDecisionTask_FirstDecisio workflowType := "some random workflow type" taskListName := "some random task list" - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -351,8 +356,8 @@ func (s *transferQueueActiveProcessorSuite) TestProcessDecisionTask_NonFirstDeci workflowType := "some random workflow type" taskListName := "some random task list" - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -406,8 +411,8 @@ func (s *transferQueueActiveProcessorSuite) TestProcessDecisionTask_Sticky_NonFi stickyTaskListName := "some random sticky task list" stickyTaskListTimeout := int32(233) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -465,8 +470,8 @@ func (s *transferQueueActiveProcessorSuite) TestProcessDecisionTask_DecisionNotS stickyTaskListName := "some random sticky task list" stickyTaskListTimeout := int32(233) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -522,8 +527,8 @@ func (s *transferQueueActiveProcessorSuite) TestProcessDecisionTask_Duplication( workflowType := "some random workflow type" taskListName := "some random task list" - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -579,8 +584,8 @@ func (s *transferQueueActiveProcessorSuite) TestProcessCloseExecution_HasParent( RunId: common.StringPtr(uuid.New()), } - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -645,8 +650,8 @@ func (s *transferQueueActiveProcessorSuite) TestProcessCloseExecution_NoParent() workflowType := "some random workflow type" taskListName := "some random task list" - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -704,8 +709,8 @@ func (s *transferQueueActiveProcessorSuite) TestProcessCancelExecution_Success() RunId: common.StringPtr(uuid.New()), } - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -744,7 +749,7 @@ func (s *transferQueueActiveProcessorSuite) TestProcessCancelExecution_Success() persistenceMutableState := createMutableState(msBuilder) s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(&persistence.GetWorkflowExecutionResponse{State: persistenceMutableState}, nil) s.mockHistoryClient.On("RequestCancelWorkflowExecution", nil, s.createRequetCancelWorkflowExecutionRequest(transferTask, rci)).Return(nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockClusterMetadata.On("ClusterNameForFailoverVersion", s.version).Return(cluster.TestCurrentClusterName) s.mockTimerQueueProcessor.On("NotifyNewTimers", cluster.TestCurrentClusterName, mock.Anything, mock.Anything).Once() @@ -768,8 +773,8 @@ func (s *transferQueueActiveProcessorSuite) TestProcessCancelExecution_Failure() RunId: common.StringPtr(uuid.New()), } - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -809,7 +814,7 @@ func (s *transferQueueActiveProcessorSuite) TestProcessCancelExecution_Failure() persistenceMutableState := createMutableState(msBuilder) s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(&persistence.GetWorkflowExecutionResponse{State: persistenceMutableState}, nil) s.mockHistoryClient.On("RequestCancelWorkflowExecution", nil, s.createRequetCancelWorkflowExecutionRequest(transferTask, rci)).Return(&workflow.EntityNotExistsError{}).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockClusterMetadata.On("ClusterNameForFailoverVersion", s.version).Return(cluster.TestCurrentClusterName) s.mockTimerQueueProcessor.On("NotifyNewTimers", cluster.TestCurrentClusterName, mock.Anything, mock.Anything).Once() @@ -833,8 +838,8 @@ func (s *transferQueueActiveProcessorSuite) TestProcessCancelExecution_Duplicati RunId: common.StringPtr(uuid.New()), } - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -898,8 +903,8 @@ func (s *transferQueueActiveProcessorSuite) TestProcessSignalExecution_Success() signalInput := []byte("some random signal input") signalControl := []byte("some random signal control") - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -940,7 +945,7 @@ func (s *transferQueueActiveProcessorSuite) TestProcessSignalExecution_Success() persistenceMutableState := createMutableState(msBuilder) s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(&persistence.GetWorkflowExecutionResponse{State: persistenceMutableState}, nil) s.mockHistoryClient.On("SignalWorkflowExecution", nil, s.createSignallWorkflowExecutionRequest(transferTask, si)).Return(nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockClusterMetadata.On("ClusterNameForFailoverVersion", s.version).Return(cluster.TestCurrentClusterName) s.mockTimerQueueProcessor.On("NotifyNewTimers", cluster.TestCurrentClusterName, mock.Anything, mock.Anything).Once() @@ -975,8 +980,8 @@ func (s *transferQueueActiveProcessorSuite) TestProcessSignalExecution_Failure() signalInput := []byte("some random signal input") signalControl := []byte("some random signal control") - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -1017,7 +1022,7 @@ func (s *transferQueueActiveProcessorSuite) TestProcessSignalExecution_Failure() persistenceMutableState := createMutableState(msBuilder) s.mockExecutionMgr.On("GetWorkflowExecution", mock.Anything).Return(&persistence.GetWorkflowExecutionResponse{State: persistenceMutableState}, nil) s.mockHistoryClient.On("SignalWorkflowExecution", nil, s.createSignallWorkflowExecutionRequest(transferTask, si)).Return(&workflow.EntityNotExistsError{}).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockClusterMetadata.On("ClusterNameForFailoverVersion", s.version).Return(cluster.TestCurrentClusterName) s.mockTimerQueueProcessor.On("NotifyNewTimers", cluster.TestCurrentClusterName, mock.Anything, mock.Anything).Once() @@ -1044,8 +1049,8 @@ func (s *transferQueueActiveProcessorSuite) TestProcessSignalExecution_Duplicati signalInput := []byte("some random signal input") signalControl := []byte("some random signal control") - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -1109,8 +1114,8 @@ func (s *transferQueueActiveProcessorSuite) TestProcessStartChildExecution_Succe childWorkflowType := "some random child workflow type" childTaskListName := "some random child task list" - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -1171,7 +1176,7 @@ func (s *transferQueueActiveProcessorSuite) TestProcessStartChildExecution_Succe domainName, childDomainName, )).Return(&workflow.StartWorkflowExecutionResponse{RunId: common.StringPtr(childRunID)}, nil).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockClusterMetadata.On("ClusterNameForFailoverVersion", s.version).Return(cluster.TestCurrentClusterName) s.mockHistoryClient.On("ScheduleDecisionTask", nil, &history.ScheduleDecisionTaskRequest{ @@ -1203,8 +1208,8 @@ func (s *transferQueueActiveProcessorSuite) TestProcessStartChildExecution_Failu childWorkflowType := "some random child workflow type" childTaskListName := "some random child task list" - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -1265,7 +1270,7 @@ func (s *transferQueueActiveProcessorSuite) TestProcessStartChildExecution_Failu domainName, childDomainName, )).Return(nil, &workflow.WorkflowExecutionAlreadyStartedError{}).Once() - s.mockHistoryMgr.On("AppendHistoryEvents", mock.Anything).Return(&p.AppendHistoryEventsResponse{Size: 0}, nil).Once() + s.mockHistoryV2Mgr.On("AppendHistoryNodes", mock.Anything).Return(&p.AppendHistoryNodesResponse{Size: 0}, nil).Once() s.mockExecutionMgr.On("UpdateWorkflowExecution", mock.Anything).Return(&p.UpdateWorkflowExecutionResponse{MutableStateUpdateSessionStats: &p.MutableStateUpdateSessionStats{}}, nil).Once() s.mockClusterMetadata.On("ClusterNameForFailoverVersion", s.version).Return(cluster.TestCurrentClusterName) s.mockTimerQueueProcessor.On("NotifyNewTimers", cluster.TestCurrentClusterName, mock.Anything, mock.Anything).Once() @@ -1291,8 +1296,8 @@ func (s *transferQueueActiveProcessorSuite) TestProcessStartChildExecution_Succe childWorkflowType := "some random child workflow type" childTaskListName := "some random child task list" - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -1380,8 +1385,8 @@ func (s *transferQueueActiveProcessorSuite) TestProcessStartChildExecution_Dupli childWorkflowType := "some random child workflow type" childTaskListName := "some random child task list" - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, s.version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ diff --git a/service/history/transferQueueStandbyProcessor_test.go b/service/history/transferQueueStandbyProcessor_test.go index 1f156055f96..c91c47a0236 100644 --- a/service/history/transferQueueStandbyProcessor_test.go +++ b/service/history/transferQueueStandbyProcessor_test.go @@ -182,8 +182,8 @@ func (s *transferQueueStandbyProcessorSuite) TestProcessActivityTask_Pending() { taskListName := "some random task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -237,8 +237,8 @@ func (s *transferQueueStandbyProcessorSuite) TestProcessActivityTask_Pending_Pus taskListName := "some random task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -293,8 +293,8 @@ func (s *transferQueueStandbyProcessorSuite) TestProcessActivityTask_Success() { taskListName := "some random task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -349,8 +349,8 @@ func (s *transferQueueStandbyProcessorSuite) TestProcessDecisionTask_Pending() { taskListName := "some random task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -398,8 +398,8 @@ func (s *transferQueueStandbyProcessorSuite) TestProcessDecisionTask_Pending_Pus taskListName := "some random task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -449,8 +449,8 @@ func (s *transferQueueStandbyProcessorSuite) TestProcessDecisionTask_Success_Fir taskListName := "some random task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -511,8 +511,8 @@ func (s *transferQueueStandbyProcessorSuite) TestProcessDecisionTask_Success_Non taskListName := "some random task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -566,8 +566,8 @@ func (s *transferQueueStandbyProcessorSuite) TestProcessCloseExecution() { taskListName := "some random task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -627,8 +627,8 @@ func (s *transferQueueStandbyProcessorSuite) TestProcessCancelExecution_Pending( } version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -698,8 +698,8 @@ func (s *transferQueueStandbyProcessorSuite) TestProcessCancelExecution_Success( } version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -762,8 +762,8 @@ func (s *transferQueueStandbyProcessorSuite) TestProcessSignalExecution_Pending( signalName := "some random signal name" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -835,8 +835,8 @@ func (s *transferQueueStandbyProcessorSuite) TestProcessSignalExecution_Success( signalName := "some random signal name" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -898,8 +898,8 @@ func (s *transferQueueStandbyProcessorSuite) TestProcessStartChildExecution_Pend childTaskListName := "some random child task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ @@ -969,8 +969,8 @@ func (s *transferQueueStandbyProcessorSuite) TestProcessStartChildExecution_Succ childTaskListName := "some random child task list" version := int64(4096) - msBuilder := newMutableStateBuilderWithReplicationState(s.mockClusterMetadata.GetCurrentClusterName(), - s.mockShard, s.mockShard.GetEventsCache(), s.logger, version) + msBuilder := newMutableStateBuilderWithReplicationStateWithEventV2(s.mockClusterMetadata.GetCurrentClusterName(), + s.mockShard, s.mockShard.GetEventsCache(), s.logger, version, execution.GetRunId()) msBuilder.AddWorkflowExecutionStartedEvent( execution, &history.StartWorkflowExecutionRequest{ diff --git a/service/history/workflowResetor_test.go b/service/history/workflowResetor_test.go index 50d1054c770..fd1edbee151 100644 --- a/service/history/workflowResetor_test.go +++ b/service/history/workflowResetor_test.go @@ -4002,7 +4002,7 @@ func (s *resetorSuite) TestApplyReset() { BranchToken: newBranchToken, Events: historyAfterReset.Events, TransactionID: 1, - Encoding: common.EncodingTypeJSON, + Encoding: common.EncodingType(s.config.EventEncodingType(domainID)), } appendV2Resp := &p.AppendHistoryNodesResponse{ Size: 200,