1329
}
1330
1332
>
branchToken, currentSnapshot, _ := s.CreateWorkflow(
1333
>
rand.Int63(),
1334
>
enumsspb.WORKFLOW_EXECUTION_STATE_CREATED,
1335
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1336
>
rand.Int63(),
1337
>
)
1338
>
1339
>
baseRunID := uuid.New().String()
1340
>
baseBranchToken := RandomBranchToken(s.NamespaceID, s.WorkflowID, baseRunID, s.HistoryBranchUtil)
1341
>
baseSnapshot, baseEvents := RandomSnapshot(
1342
>
s.T(),
1343
>
s.NamespaceID,
1344
>
s.WorkflowID,
1345
>
baseRunID,
1346
>
common.FirstEventID,
1347
>
rand.Int63(),
1348
>
enumsspb.WORKFLOW_EXECUTION_STATE_ZOMBIE,
1349
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1350
>
rand.Int63(),
1351
>
baseBranchToken,
1352
>
)
1353
>
_, err := s.ExecutionManager.CreateWorkflowExecution(s.Ctx, &p.CreateWorkflowExecutionRequest{
1354
>
ShardID: s.ShardID,
1355
>
RangeID: s.RangeID,
1356
>
Mode: p.CreateWorkflowModeBypassCurrent,
1357
>
1358
>
PreviousRunID: "",
1359
>
PreviousLastWriteVersion: 0,
1360
>
1361
>
ArchetypeID: chasm.WorkflowArchetypeID,
1362
>
1363
>
NewWorkflowSnapshot: *baseSnapshot,
1364
>
NewWorkflowEvents: baseEvents,
1365
>
})
1366
>
s.NoError(err)
1367
>
1368
>
resetSnapshot, resetEvents := RandomSnapshot(
1369
>
s.T(),
1370
>
s.NamespaceID,
1371
>
s.WorkflowID,
1372
>
baseRunID,
1373
>
baseSnapshot.NextEventID,
1374
>
rand.Int63(),
1375
>
enumsspb.WORKFLOW_EXECUTION_STATE_RUNNING,
1376
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1377
>
rand.Int63(),
1378
>
baseBranchToken,
1379
>
)
1380
>
currentMutation, currentEvents2 := RandomMutation(
1381
>
s.T(),
1382
>
s.NamespaceID,
1383
>
s.WorkflowID,
1384
>
s.RunID,
1385
>
currentSnapshot.NextEventID,
1386
>
rand.Int63(),
1387
>
enumsspb.WORKFLOW_EXECUTION_STATE_ZOMBIE,
1388
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1389
>
currentSnapshot.DBRecordVersion+1,
1390
>
branchToken,
1391
>
)
1392
>
_, err = s.ExecutionManager.ConflictResolveWorkflowExecution(s.Ctx, &p.ConflictResolveWorkflowExecutionRequest{
1393
>
ShardID: s.ShardID,
1394
>
RangeID: s.RangeID,
1395
>
Mode: p.ConflictResolveWorkflowModeUpdateCurrent,
1396
>
1397
>
ArchetypeID: chasm.WorkflowArchetypeID,
1398
>
1399
>
ResetWorkflowSnapshot: *resetSnapshot,
1400
>
ResetWorkflowEvents: resetEvents,
1401
>
1402
>
NewWorkflowSnapshot: nil,
1403
>
NewWorkflowEvents: nil,
1404
>
1405
>
CurrentWorkflowMutation: currentMutation,
1406
>
CurrentWorkflowEvents: currentEvents2,
1407
>
})
1408
>
s.IsType(&p.WorkflowConditionFailedError{}, err)
1409
>
1410
>
s.AssertMSEqualWithDB(chasm.WorkflowArchetypeID, baseSnapshot)
1411
>
s.AssertMSEqualWithDB(chasm.WorkflowArchetypeID, currentSnapshot)
1412
>
s.AssertHEPrefixWithDB(baseBranchToken, baseEvents)
1413
>
}
1414
1415
func (s *ExecutionMutableStateSuite) TestConflictResolve_SuppressCurrent_WithNew() {