1514
}
1515
1517
>
archetypeID := rand.Uint32()
1518
>
currentSnapshot := s.CreateCHASMExecution(
1519
>
rand.Int63(),
1520
>
enumsspb.WORKFLOW_EXECUTION_STATE_CREATED,
1521
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1522
>
rand.Int63(),
1523
>
archetypeID,
1524
>
)
1525
>
1526
>
baseRunID := uuid.New().String()
1527
>
baseSnapshot, baseEvents := RandomSnapshot(
1528
>
s.T(),
1529
>
s.NamespaceID,
1530
>
s.WorkflowID,
1531
>
baseRunID,
1532
>
common.FirstEventID,
1533
>
rand.Int63(),
1534
>
enumsspb.WORKFLOW_EXECUTION_STATE_ZOMBIE,
1535
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1536
>
rand.Int63(),
1537
>
nil,
1538
>
)
1539
>
s.Empty(baseEvents)
1540
>
_, err := s.ExecutionManager.CreateWorkflowExecution(s.Ctx, &p.CreateWorkflowExecutionRequest{
1541
>
ShardID: s.ShardID,
1542
>
RangeID: s.RangeID,
1543
>
Mode: p.CreateWorkflowModeBypassCurrent,
1544
>
1545
>
PreviousRunID: "",
1546
>
PreviousLastWriteVersion: 0,
1547
>
1548
>
ArchetypeID: archetypeID,
1549
>
1550
>
NewWorkflowSnapshot: *baseSnapshot,
1551
>
NewWorkflowEvents: baseEvents,
1552
>
})
1553
>
s.NoError(err)
1554
>
1555
>
resetSnapshot, resetEvents := RandomSnapshot(
1556
>
s.T(),
1557
>
s.NamespaceID,
1558
>
s.WorkflowID,
1559
>
baseRunID,
1560
>
baseSnapshot.NextEventID,
1561
>
rand.Int63(),
1562
>
enumsspb.WORKFLOW_EXECUTION_STATE_COMPLETED,
1563
>
enumspb.WORKFLOW_EXECUTION_STATUS_COMPLETED,
1564
>
baseSnapshot.DBRecordVersion+1,
1565
>
nil,
1566
>
)
1567
>
s.Empty(resetEvents)
1568
>
1569
>
newRunID := uuid.New().String()
1570
>
newSnapshot, newEvents := RandomSnapshot(
1571
>
s.T(),
1572
>
s.NamespaceID,
1573
>
s.WorkflowID,
1574
>
newRunID,
1575
>
common.FirstEventID,
1576
>
rand.Int63(),
1577
>
enumsspb.WORKFLOW_EXECUTION_STATE_RUNNING,
1578
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1579
>
rand.Int63(),
1580
>
nil,
1581
>
)
1582
>
s.Empty(newEvents)
1583
>
1584
>
currentMutation, currentEvents := RandomMutation(
1585
>
s.T(),
1586
>
s.NamespaceID,
1587
>
s.WorkflowID,
1588
>
s.RunID,
1589
>
newSnapshot.NextEventID,
1590
>
rand.Int63(),
1591
>
enumsspb.WORKFLOW_EXECUTION_STATE_ZOMBIE,
1592
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
1593
>
currentSnapshot.DBRecordVersion+1,
1594
>
nil,
1595
>
)
1596
>
s.Empty(currentEvents)
1597
>
1598
>
_, err = s.ExecutionManager.ConflictResolveWorkflowExecution(s.Ctx, &p.ConflictResolveWorkflowExecutionRequest{
1599
>
ShardID: s.ShardID,
1600
>
RangeID: s.RangeID,
1601
>
Mode: p.ConflictResolveWorkflowModeUpdateCurrent,
1602
>
1603
>
ArchetypeID: archetypeID,
1604
>
1605
>
ResetWorkflowSnapshot: *resetSnapshot,
1606
>
ResetWorkflowEvents: resetEvents,
1607
>
1608
>
NewWorkflowSnapshot: newSnapshot,
1609
>
NewWorkflowEvents: newEvents,
1610
>
1611
>
CurrentWorkflowMutation: currentMutation,
1612
>
CurrentWorkflowEvents: currentEvents,
1613
>
})
1614
>
s.NoError(err)
1615
>
1616
>
s.AssertMSEqualWithDB(archetypeID, resetSnapshot)
1617
>
s.AssertMSEqualWithDB(archetypeID, newSnapshot)
1618
>
s.AssertMSEqualWithDB(archetypeID, currentSnapshot, currentMutation)
1619
>
}
1620
1621
func (s *ExecutionMutableStateSuite) TestConflictResolve_ResetCurrent() {