1000
}
1001
1003
>
nonCurrentLastWriteVersion := rand.Int63()
1004
>
nonCurrentBranchToken, nonCurrentSnapshot, nonCurrentEvents := s.CreateWorkflow(
1005
>
nonCurrentLastWriteVersion,
1006
>
enumsspb.WORKFLOW_EXECUTION_STATE_COMPLETED,
1007
>
enumspb.WORKFLOW_EXECUTION_STATUS_COMPLETED,
1008
>
rand.Int63(),
1009
>
)
1010
>
1011
>
// make current workflow to a different run
1012
>
currentRunID := uuid.New().String()
1013
>
currentBranchToken := RandomBranchToken(s.NamespaceID, s.WorkflowID, currentRunID, s.HistoryBranchUtil)
1014
>
currentSnapshot, currentEvents := RandomSnapshot(
1015
>
s.T(),
1016
>
s.NamespaceID,
1017
>
s.WorkflowID,
1018
>
currentRunID,
1019
>
common.FirstEventID,
1020
>
rand.Int63(),
1021
>
enumsspb.WORKFLOW_EXECUTION_STATE_RUNNING,
1022
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1023
>
rand.Int63(),
1024
>
currentBranchToken,
1025
>
)
1026
>
_, err := s.ExecutionManager.CreateWorkflowExecution(s.Ctx, &p.CreateWorkflowExecutionRequest{
1027
>
ShardID: s.ShardID,
1028
>
RangeID: s.RangeID,
1029
>
Mode: p.CreateWorkflowModeUpdateCurrent,
1030
>
1031
>
PreviousRunID: nonCurrentSnapshot.ExecutionState.RunId,
1032
>
PreviousLastWriteVersion: nonCurrentLastWriteVersion,
1033
>
1034
>
ArchetypeID: chasm.WorkflowArchetypeID,
1035
>
1036
>
NewWorkflowSnapshot: *currentSnapshot,
1037
>
NewWorkflowEvents: currentEvents,
1038
>
})
1039
>
s.NoError(err)
1040
>
1041
>
// Update the original closed workflow
1042
>
// NOTE: no new events for closed workflows
1043
>
nonCurrentMutation, _ := RandomMutation(
1044
>
s.T(),
1045
>
s.NamespaceID,
1046
>
s.WorkflowID,
1047
>
s.RunID,
1048
>
nonCurrentSnapshot.NextEventID,
1049
>
rand.Int63(),
1050
>
enumsspb.WORKFLOW_EXECUTION_STATE_COMPLETED,
1051
>
enumspb.WORKFLOW_EXECUTION_STATUS_COMPLETED,
1052
>
nonCurrentSnapshot.DBRecordVersion+1,
1053
>
nonCurrentBranchToken,
1054
>
)
1055
>
_, err = s.ExecutionManager.UpdateWorkflowExecution(s.Ctx, &p.UpdateWorkflowExecutionRequest{
1056
>
ShardID: s.ShardID,
1057
>
RangeID: s.RangeID,
1058
>
Mode: p.UpdateWorkflowModeIgnoreCurrent,
1059
>
1060
>
ArchetypeID: chasm.WorkflowArchetypeID,
1061
>
1062
>
UpdateWorkflowMutation: *nonCurrentMutation,
1063
>
UpdateWorkflowEvents: nil,
1064
>
1065
>
NewWorkflowSnapshot: nil,
1066
>
NewWorkflowEvents: nil,
1067
>
})
1068
>
s.NoError(err)
1069
>
1070
>
s.AssertMSEqualWithDB(chasm.WorkflowArchetypeID, nonCurrentSnapshot, nonCurrentMutation)
1071
>
s.AssertHEEqualWithDB(nonCurrentBranchToken, nonCurrentEvents)
1072
>
s.AssertMSEqualWithDB(chasm.WorkflowArchetypeID, currentSnapshot)
1073
>
s.AssertHEEqualWithDB(currentBranchToken, currentEvents)
1074
>
}
1075
1076
func (s *ExecutionMutableStateSuite) TestConflictResolve_SuppressCurrent() {