877
}
878
880
>
s.CreateWorkflow(
881
>
rand.Int63(),
882
>
enumsspb.WORKFLOW_EXECUTION_STATE_CREATED,
883
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
884
>
rand.Int63(),
885
>
)
886
>
zombieRunID := uuid.New().String()
887
>
zombieBranchToken := RandomBranchToken(s.NamespaceID, s.WorkflowID, zombieRunID, s.HistoryBranchUtil)
888
>
zombieSnapshot, zombieEvents1 := RandomSnapshot(
889
>
s.T(),
890
>
s.NamespaceID,
891
>
s.WorkflowID,
892
>
zombieRunID,
893
>
common.FirstEventID,
894
>
rand.Int63(),
895
>
enumsspb.WORKFLOW_EXECUTION_STATE_ZOMBIE,
896
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
897
>
rand.Int63(),
898
>
zombieBranchToken,
899
>
)
900
>
_, err := s.ExecutionManager.CreateWorkflowExecution(s.Ctx, &p.CreateWorkflowExecutionRequest{
901
>
ShardID: s.ShardID,
902
>
RangeID: s.RangeID,
903
>
Mode: p.CreateWorkflowModeBypassCurrent,
904
>
905
>
PreviousRunID: "",
906
>
PreviousLastWriteVersion: 0,
907
>
908
>
ArchetypeID: chasm.WorkflowArchetypeID,
909
>
910
>
NewWorkflowSnapshot: *zombieSnapshot,
911
>
NewWorkflowEvents: zombieEvents1,
912
>
})
913
>
s.NoError(err)
914
>
915
>
zombieMutation, zombieEvents2 := RandomMutation(
916
>
s.T(),
917
>
s.NamespaceID,
918
>
s.WorkflowID,
919
>
zombieRunID,
920
>
zombieSnapshot.NextEventID,
921
>
rand.Int63(),
922
>
enumsspb.WORKFLOW_EXECUTION_STATE_COMPLETED,
923
>
enumspb.WORKFLOW_EXECUTION_STATUS_COMPLETED,
924
>
zombieSnapshot.DBRecordVersion+1,
925
>
zombieBranchToken,
926
>
)
927
>
newRunID := uuid.New().String()
928
>
newBranchToken := RandomBranchToken(s.NamespaceID, s.WorkflowID, newRunID, s.HistoryBranchUtil)
929
>
newZombieSnapshot, newEvents3 := RandomSnapshot(
930
>
s.T(),
931
>
s.NamespaceID,
932
>
s.WorkflowID,
933
>
newRunID,
934
>
common.FirstEventID,
935
>
rand.Int63(),
936
>
enumsspb.WORKFLOW_EXECUTION_STATE_ZOMBIE,
937
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
938
>
rand.Int63(),
939
>
newBranchToken,
940
>
)
941
>
_, err = s.ExecutionManager.UpdateWorkflowExecution(s.Ctx, &p.UpdateWorkflowExecutionRequest{
942
>
ShardID: s.ShardID,
943
>
RangeID: s.RangeID,
944
>
Mode: p.UpdateWorkflowModeBypassCurrent,
945
>
946
>
ArchetypeID: chasm.WorkflowArchetypeID,
947
>
948
>
UpdateWorkflowMutation: *zombieMutation,
949
>
UpdateWorkflowEvents: zombieEvents2,
950
>
951
>
NewWorkflowSnapshot: newZombieSnapshot,
952
>
NewWorkflowEvents: newEvents3,
953
>
})
954
>
s.NoError(err)
955
>
956
>
s.AssertMSEqualWithDB(chasm.WorkflowArchetypeID, zombieSnapshot, zombieMutation)
957
>
s.AssertMSEqualWithDB(chasm.WorkflowArchetypeID, newZombieSnapshot)
958
>
s.AssertHEEqualWithDB(zombieBranchToken, zombieEvents1, zombieEvents2)
959
>
s.AssertHEEqualWithDB(newBranchToken, newEvents3)
960
>
}
961
962
func (s *ExecutionMutableStateSuite) TestUpdate_ClosedWorkflow_IsCurrent() {