1413
}
1414
1416
>
branchToken, currentSnapshot, currentEvents1 := s.CreateWorkflow(
1417
>
rand.Int63(),
1418
>
enumsspb.WORKFLOW_EXECUTION_STATE_CREATED,
1419
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1420
>
rand.Int63(),
1421
>
)
1422
>
1423
>
baseRunID := uuid.New().String()
1424
>
baseBranchToken := RandomBranchToken(s.NamespaceID, s.WorkflowID, baseRunID, s.HistoryBranchUtil)
1425
>
baseSnapshot, baseEvents := RandomSnapshot(
1426
>
s.T(),
1427
>
s.NamespaceID,
1428
>
s.WorkflowID,
1429
>
baseRunID,
1430
>
common.FirstEventID,
1431
>
rand.Int63(),
1432
>
enumsspb.WORKFLOW_EXECUTION_STATE_ZOMBIE,
1433
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1434
>
rand.Int63(),
1435
>
baseBranchToken,
1436
>
)
1437
>
_, err := s.ExecutionManager.CreateWorkflowExecution(s.Ctx, &p.CreateWorkflowExecutionRequest{
1438
>
ShardID: s.ShardID,
1439
>
RangeID: s.RangeID,
1440
>
Mode: p.CreateWorkflowModeBypassCurrent,
1441
>
1442
>
PreviousRunID: "",
1443
>
PreviousLastWriteVersion: 0,
1444
>
1445
>
ArchetypeID: chasm.WorkflowArchetypeID,
1446
>
1447
>
NewWorkflowSnapshot: *baseSnapshot,
1448
>
NewWorkflowEvents: baseEvents,
1449
>
})
1450
>
s.NoError(err)
1451
>
1452
>
resetSnapshot, resetEvents := RandomSnapshot(
1453
>
s.T(),
1454
>
s.NamespaceID,
1455
>
s.WorkflowID,
1456
>
baseRunID,
1457
>
baseSnapshot.NextEventID,
1458
>
rand.Int63(),
1459
>
enumsspb.WORKFLOW_EXECUTION_STATE_COMPLETED,
1460
>
enumspb.WORKFLOW_EXECUTION_STATUS_COMPLETED,
1461
>
baseSnapshot.DBRecordVersion+1,
1462
>
baseBranchToken,
1463
>
)
1464
>
newRunID := uuid.New().String()
1465
>
newBranchToken := RandomBranchToken(s.NamespaceID, s.WorkflowID, newRunID, s.HistoryBranchUtil)
1466
>
newSnapshot, newEvents := RandomSnapshot(
1467
>
s.T(),
1468
>
s.NamespaceID,
1469
>
s.WorkflowID,
1470
>
newRunID,
1471
>
common.FirstEventID,
1472
>
rand.Int63(),
1473
>
enumsspb.WORKFLOW_EXECUTION_STATE_RUNNING,
1474
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1475
>
rand.Int63(),
1476
>
newBranchToken,
1477
>
)
1478
>
currentMutation, currentEvents2 := RandomMutation(
1479
>
s.T(),
1480
>
s.NamespaceID,
1481
>
s.WorkflowID,
1482
>
s.RunID,
1483
>
newSnapshot.NextEventID,
1484
>
rand.Int63(),
1485
>
enumsspb.WORKFLOW_EXECUTION_STATE_ZOMBIE,
1486
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1487
>
currentSnapshot.DBRecordVersion+1,
1488
>
branchToken,
1489
>
)
1490
>
_, err = s.ExecutionManager.ConflictResolveWorkflowExecution(s.Ctx, &p.ConflictResolveWorkflowExecutionRequest{
1491
>
ShardID: s.ShardID,
1492
>
RangeID: s.RangeID,
1493
>
Mode: p.ConflictResolveWorkflowModeUpdateCurrent,
1494
>
1495
>
ArchetypeID: chasm.WorkflowArchetypeID,
1496
>
1497
>
ResetWorkflowSnapshot: *resetSnapshot,
1498
>
ResetWorkflowEvents: resetEvents,
1499
>
1500
>
NewWorkflowSnapshot: newSnapshot,
1501
>
NewWorkflowEvents: newEvents,
1502
>
1503
>
CurrentWorkflowMutation: currentMutation,
1504
>
CurrentWorkflowEvents: currentEvents2,
1505
>
})
1506
>
s.NoError(err)
1507
>
1508
>
s.AssertMSEqualWithDB(chasm.WorkflowArchetypeID, resetSnapshot)
1509
>
s.AssertMSEqualWithDB(chasm.WorkflowArchetypeID, newSnapshot)
1510
>
s.AssertMSEqualWithDB(chasm.WorkflowArchetypeID, currentSnapshot, currentMutation)
1511
>
s.AssertHEEqualWithDB(baseBranchToken, baseEvents, resetEvents)
1512
>
s.AssertHEEqualWithDB(newBranchToken, newEvents)
1513
>
s.AssertHEEqualWithDB(branchToken, currentEvents1, currentEvents2)
1514
>
}
1515
1516
func (s *ExecutionMutableStateSuite) TestConflictResolve_SuppressCurrent_WithNew_CHASM() {