1245
}
1246
1248
>
branchToken, currentSnapshot, _ := s.CreateWorkflow(
1249
>
rand.Int63(),
1250
>
enumsspb.WORKFLOW_EXECUTION_STATE_CREATED,
1251
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1252
>
rand.Int63(),
1253
>
)
1254
>
1255
>
baseRunID := uuid.New().String()
1256
>
baseBranchToken := RandomBranchToken(s.NamespaceID, s.WorkflowID, baseRunID, s.HistoryBranchUtil)
1257
>
baseSnapshot, baseEvents := RandomSnapshot(
1258
>
s.T(),
1259
>
s.NamespaceID,
1260
>
s.WorkflowID,
1261
>
baseRunID,
1262
>
common.FirstEventID,
1263
>
rand.Int63(),
1264
>
enumsspb.WORKFLOW_EXECUTION_STATE_ZOMBIE,
1265
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1266
>
rand.Int63(),
1267
>
baseBranchToken,
1268
>
)
1269
>
_, err := s.ExecutionManager.CreateWorkflowExecution(s.Ctx, &p.CreateWorkflowExecutionRequest{
1270
>
ShardID: s.ShardID,
1271
>
RangeID: s.RangeID,
1272
>
Mode: p.CreateWorkflowModeBypassCurrent,
1273
>
1274
>
PreviousRunID: "",
1275
>
PreviousLastWriteVersion: 0,
1276
>
1277
>
ArchetypeID: chasm.WorkflowArchetypeID,
1278
>
1279
>
NewWorkflowSnapshot: *baseSnapshot,
1280
>
NewWorkflowEvents: baseEvents,
1281
>
})
1282
>
s.NoError(err)
1283
>
1284
>
resetSnapshot, resetEvents := RandomSnapshot(
1285
>
s.T(),
1286
>
s.NamespaceID,
1287
>
s.WorkflowID,
1288
>
baseRunID,
1289
>
baseSnapshot.NextEventID,
1290
>
rand.Int63(),
1291
>
enumsspb.WORKFLOW_EXECUTION_STATE_RUNNING,
1292
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1293
>
baseSnapshot.DBRecordVersion+1,
1294
>
baseBranchToken,
1295
>
)
1296
>
currentMutation, currentEvents2 := RandomMutation(
1297
>
s.T(),
1298
>
s.NamespaceID,
1299
>
s.WorkflowID,
1300
>
s.RunID,
1301
>
currentSnapshot.NextEventID,
1302
>
rand.Int63(),
1303
>
enumsspb.WORKFLOW_EXECUTION_STATE_ZOMBIE,
1304
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1305
>
rand.Int63(),
1306
>
branchToken,
1307
>
)
1308
>
_, err = s.ExecutionManager.ConflictResolveWorkflowExecution(s.Ctx, &p.ConflictResolveWorkflowExecutionRequest{
1309
>
ShardID: s.ShardID,
1310
>
RangeID: s.RangeID,
1311
>
Mode: p.ConflictResolveWorkflowModeUpdateCurrent,
1312
>
1313
>
ArchetypeID: chasm.WorkflowArchetypeID,
1314
>
1315
>
ResetWorkflowSnapshot: *resetSnapshot,
1316
>
ResetWorkflowEvents: resetEvents,
1317
>
1318
>
NewWorkflowSnapshot: nil,
1319
>
NewWorkflowEvents: nil,
1320
>
1321
>
CurrentWorkflowMutation: currentMutation,
1322
>
CurrentWorkflowEvents: currentEvents2,
1323
>
})
1324
>
s.IsType(&p.WorkflowConditionFailedError{}, err)
1325
>
1326
>
s.AssertMSEqualWithDB(chasm.WorkflowArchetypeID, baseSnapshot)
1327
>
s.AssertMSEqualWithDB(chasm.WorkflowArchetypeID, currentSnapshot)
1328
>
s.AssertHEPrefixWithDB(baseBranchToken, baseEvents)
1329
>
}
1330
1331
func (s *ExecutionMutableStateSuite) TestConflictResolve_SuppressCurrent_Conflict_Case2() {