647
}
648
650
>
branchToken, currentSnapshot, currentEvents := s.CreateWorkflow(
651
>
rand.Int63(),
652
>
enumsspb.WORKFLOW_EXECUTION_STATE_CREATED,
653
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
654
>
rand.Int63(),
655
>
)
656
>
updateMutation, updateEvents := RandomMutation(
657
>
s.T(),
658
>
s.NamespaceID,
659
>
s.WorkflowID,
660
>
s.RunID,
661
>
currentSnapshot.NextEventID,
662
>
rand.Int63(),
663
>
enumsspb.WORKFLOW_EXECUTION_STATE_COMPLETED,
664
>
enumspb.WORKFLOW_EXECUTION_STATUS_COMPLETED,
665
>
currentSnapshot.DBRecordVersion+1,
666
>
branchToken,
667
>
)
668
>
669
>
newRunID := uuid.New().String()
670
>
newBranchToken := RandomBranchToken(s.NamespaceID, s.WorkflowID, newRunID, s.HistoryBranchUtil)
671
>
newSnapshot, newEvents := RandomSnapshot(
672
>
s.T(),
673
>
s.NamespaceID,
674
>
s.WorkflowID,
675
>
newRunID,
676
>
common.FirstEventID,
677
>
rand.Int63(),
678
>
enumsspb.WORKFLOW_EXECUTION_STATE_RUNNING,
679
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
680
>
rand.Int63(),
681
>
newBranchToken,
682
>
)
683
>
_, err := s.ExecutionManager.UpdateWorkflowExecution(s.Ctx, &p.UpdateWorkflowExecutionRequest{
684
>
ShardID: s.ShardID,
685
>
RangeID: s.RangeID,
686
>
Mode: p.UpdateWorkflowModeUpdateCurrent,
687
>
688
>
ArchetypeID: chasm.WorkflowArchetypeID,
689
>
690
>
UpdateWorkflowMutation: *updateMutation,
691
>
UpdateWorkflowEvents: updateEvents,
692
>
693
>
NewWorkflowSnapshot: newSnapshot,
694
>
NewWorkflowEvents: newEvents,
695
>
})
696
>
s.NoError(err)
697
>
698
>
s.AssertMSEqualWithDB(chasm.WorkflowArchetypeID, currentSnapshot, updateMutation)
699
>
s.AssertMSEqualWithDB(chasm.WorkflowArchetypeID, newSnapshot)
700
>
s.AssertHEEqualWithDB(branchToken, currentEvents, updateEvents)
701
>
s.AssertHEEqualWithDB(newBranchToken, newEvents)
702
>
}
703
704
func (s *ExecutionMutableStateSuite) TestUpdate_Zombie() {