1159
}
1160
1162
>
_, currentSnapshot, _ := s.CreateWorkflow(
1163
>
rand.Int63(),
1164
>
enumsspb.WORKFLOW_EXECUTION_STATE_CREATED,
1165
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1166
>
rand.Int63(),
1167
>
)
1168
>
1169
>
baseRunID := uuid.New().String()
1170
>
baseBranchToken := RandomBranchToken(s.NamespaceID, s.WorkflowID, baseRunID, s.HistoryBranchUtil)
1171
>
baseSnapshot, baseEvents := RandomSnapshot(
1172
>
s.T(),
1173
>
s.NamespaceID,
1174
>
s.WorkflowID,
1175
>
baseRunID,
1176
>
common.FirstEventID,
1177
>
rand.Int63(),
1178
>
enumsspb.WORKFLOW_EXECUTION_STATE_ZOMBIE,
1179
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1180
>
rand.Int63(),
1181
>
baseBranchToken,
1182
>
)
1183
>
_, err := s.ExecutionManager.CreateWorkflowExecution(s.Ctx, &p.CreateWorkflowExecutionRequest{
1184
>
ShardID: s.ShardID,
1185
>
RangeID: s.RangeID,
1186
>
Mode: p.CreateWorkflowModeBypassCurrent,
1187
>
1188
>
PreviousRunID: "",
1189
>
PreviousLastWriteVersion: 0,
1190
>
1191
>
ArchetypeID: chasm.WorkflowArchetypeID,
1192
>
1193
>
NewWorkflowSnapshot: *baseSnapshot,
1194
>
NewWorkflowEvents: baseEvents,
1195
>
})
1196
>
s.NoError(err)
1197
>
1198
>
resetSnapshot, resetEvents := RandomSnapshot(
1199
>
s.T(),
1200
>
s.NamespaceID,
1201
>
s.WorkflowID,
1202
>
baseRunID,
1203
>
baseSnapshot.NextEventID,
1204
>
rand.Int63(),
1205
>
enumsspb.WORKFLOW_EXECUTION_STATE_RUNNING,
1206
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1207
>
baseSnapshot.DBRecordVersion+1,
1208
>
baseBranchToken,
1209
>
)
1210
>
currentRunID := uuid.New().String()
1211
>
currentBranchToken := RandomBranchToken(s.NamespaceID, s.WorkflowID, currentRunID, s.HistoryBranchUtil)
1212
>
currentMutation, currentEvents := RandomMutation(
1213
>
s.T(),
1214
>
s.NamespaceID,
1215
>
s.WorkflowID,
1216
>
currentRunID,
1217
>
common.FirstEventID,
1218
>
rand.Int63(),
1219
>
enumsspb.WORKFLOW_EXECUTION_STATE_ZOMBIE,
1220
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1221
>
rand.Int63(),
1222
>
currentBranchToken,
1223
>
)
1224
>
_, err = s.ExecutionManager.ConflictResolveWorkflowExecution(s.Ctx, &p.ConflictResolveWorkflowExecutionRequest{
1225
>
ShardID: s.ShardID,
1226
>
RangeID: s.RangeID,
1227
>
Mode: p.ConflictResolveWorkflowModeUpdateCurrent,
1228
>
1229
>
ArchetypeID: chasm.WorkflowArchetypeID,
1230
>
1231
>
ResetWorkflowSnapshot: *resetSnapshot,
1232
>
ResetWorkflowEvents: resetEvents,
1233
>
1234
>
NewWorkflowSnapshot: nil,
1235
>
NewWorkflowEvents: nil,
1236
>
1237
>
CurrentWorkflowMutation: currentMutation,
1238
>
CurrentWorkflowEvents: currentEvents,
1239
>
})
1240
>
s.IsType(&p.CurrentWorkflowConditionFailedError{}, err)
1241
>
1242
>
s.AssertMSEqualWithDB(chasm.WorkflowArchetypeID, baseSnapshot)
1243
>
s.AssertMSEqualWithDB(chasm.WorkflowArchetypeID, currentSnapshot)
1244
>
s.AssertHEPrefixWithDB(baseBranchToken, baseEvents)
1245
>
}
1246
1247
func (s *ExecutionMutableStateSuite) TestConflictResolve_SuppressCurrent_Conflict_Case1() {