1074
}
1075
1077
>
branchToken, currentSnapshot, currentEvents1 := s.CreateWorkflow(
1078
>
rand.Int63(),
1079
>
enumsspb.WORKFLOW_EXECUTION_STATE_CREATED,
1080
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1081
>
rand.Int63(),
1082
>
)
1083
>
1084
>
baseRunID := uuid.New().String()
1085
>
baseBranchToken := RandomBranchToken(s.NamespaceID, s.WorkflowID, baseRunID, s.HistoryBranchUtil)
1086
>
baseSnapshot, baseEvents := RandomSnapshot(
1087
>
s.T(),
1088
>
s.NamespaceID,
1089
>
s.WorkflowID,
1090
>
baseRunID,
1091
>
common.FirstEventID,
1092
>
rand.Int63(),
1093
>
enumsspb.WORKFLOW_EXECUTION_STATE_ZOMBIE,
1094
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1095
>
rand.Int63(),
1096
>
baseBranchToken,
1097
>
)
1098
>
_, err := s.ExecutionManager.CreateWorkflowExecution(s.Ctx, &p.CreateWorkflowExecutionRequest{
1099
>
ShardID: s.ShardID,
1100
>
RangeID: s.RangeID,
1101
>
Mode: p.CreateWorkflowModeBypassCurrent,
1102
>
1103
>
PreviousRunID: "",
1104
>
PreviousLastWriteVersion: 0,
1105
>
1106
>
ArchetypeID: chasm.WorkflowArchetypeID,
1107
>
1108
>
NewWorkflowSnapshot: *baseSnapshot,
1109
>
NewWorkflowEvents: baseEvents,
1110
>
})
1111
>
s.NoError(err)
1112
>
1113
>
resetSnapshot, resetEvents := RandomSnapshot(
1114
>
s.T(),
1115
>
s.NamespaceID,
1116
>
s.WorkflowID,
1117
>
baseRunID,
1118
>
baseSnapshot.NextEventID,
1119
>
rand.Int63(),
1120
>
enumsspb.WORKFLOW_EXECUTION_STATE_RUNNING,
1121
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1122
>
baseSnapshot.DBRecordVersion+1,
1123
>
baseBranchToken,
1124
>
)
1125
>
currentMutation, currentEvents2 := RandomMutation(
1126
>
s.T(),
1127
>
s.NamespaceID,
1128
>
s.WorkflowID,
1129
>
s.RunID,
1130
>
currentSnapshot.NextEventID,
1131
>
rand.Int63(),
1132
>
enumsspb.WORKFLOW_EXECUTION_STATE_ZOMBIE,
1133
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1134
>
currentSnapshot.DBRecordVersion+1,
1135
>
branchToken,
1136
>
)
1137
>
_, err = s.ExecutionManager.ConflictResolveWorkflowExecution(s.Ctx, &p.ConflictResolveWorkflowExecutionRequest{
1138
>
ShardID: s.ShardID,
1139
>
RangeID: s.RangeID,
1140
>
Mode: p.ConflictResolveWorkflowModeUpdateCurrent,
1141
>
1142
>
ArchetypeID: chasm.WorkflowArchetypeID,
1143
>
1144
>
ResetWorkflowSnapshot: *resetSnapshot,
1145
>
ResetWorkflowEvents: resetEvents,
1146
>
1147
>
NewWorkflowSnapshot: nil,
1148
>
NewWorkflowEvents: nil,
1149
>
1150
>
CurrentWorkflowMutation: currentMutation,
1151
>
CurrentWorkflowEvents: currentEvents2,
1152
>
})
1153
>
s.NoError(err)
1154
>
1155
>
s.AssertMSEqualWithDB(chasm.WorkflowArchetypeID, resetSnapshot)
1156
>
s.AssertMSEqualWithDB(chasm.WorkflowArchetypeID, currentSnapshot, currentMutation)
1157
>
s.AssertHEEqualWithDB(baseBranchToken, baseEvents, resetEvents)
1158
>
s.AssertHEEqualWithDB(branchToken, currentEvents1, currentEvents2)
1159
>
}
1160
1161
func (s *ExecutionMutableStateSuite) TestConflictResolve_SuppressCurrent_CurrentConflict() {