@@ -223,6 +223,47 @@ func (s *ExecutionMutableStateSuite) TestCreate_Reuse() {
223
223
s .AssertHEEqualWithDB (newBranchToken , newEvents )
224
224
}
225
225
226
+ func (s * ExecutionMutableStateSuite ) TestCreate_Reuse_CHASM () {
227
+ // CHASM snapshot has no events and empty current version history.
228
+ prevLastWriteVersion := rand .Int63 ()
229
+ prevSnapshot := s .CreateCHASMSnapshot (
230
+ prevLastWriteVersion ,
231
+ enumsspb .WORKFLOW_EXECUTION_STATE_COMPLETED ,
232
+ enumspb .WORKFLOW_EXECUTION_STATUS_COMPLETED ,
233
+ rand .Int63 (),
234
+ )
235
+
236
+ newRunID := uuid .New ().String ()
237
+ newSnapshot , newEvents := RandomSnapshot (
238
+ s .T (),
239
+ s .NamespaceID ,
240
+ s .WorkflowID ,
241
+ newRunID ,
242
+ common .FirstEventID ,
243
+ rand .Int63 (),
244
+ enumsspb .WORKFLOW_EXECUTION_STATE_CREATED ,
245
+ enumspb .WORKFLOW_EXECUTION_STATUS_RUNNING ,
246
+ rand .Int63 (),
247
+ nil , // CHASM snapshot has no events
248
+ )
249
+ s .Empty (newEvents )
250
+
251
+ _ , err := s .ExecutionManager .CreateWorkflowExecution (s .Ctx , & p.CreateWorkflowExecutionRequest {
252
+ ShardID : s .ShardID ,
253
+ RangeID : s .RangeID ,
254
+ Mode : p .CreateWorkflowModeUpdateCurrent ,
255
+
256
+ PreviousRunID : prevSnapshot .ExecutionState .RunId ,
257
+ PreviousLastWriteVersion : prevLastWriteVersion ,
258
+
259
+ NewWorkflowSnapshot : * newSnapshot ,
260
+ NewWorkflowEvents : newEvents ,
261
+ })
262
+ s .NoError (err )
263
+
264
+ s .AssertMSEqualWithDB (newSnapshot )
265
+ }
266
+
226
267
func (s * ExecutionMutableStateSuite ) TestCreate_Reuse_CurrentConflict () {
227
268
prevLastWriteVersion := rand .Int63 ()
228
269
branchToken , prevSnapshot , prevEvents := s .CreateWorkflow (
@@ -1403,6 +1444,105 @@ func (s *ExecutionMutableStateSuite) TestConflictResolve_SuppressCurrent_WithNew
1403
1444
s .AssertHEEqualWithDB (branchToken , currentEvents1 , currentEvents2 )
1404
1445
}
1405
1446
1447
+ func (s * ExecutionMutableStateSuite ) TestConflictResolve_SuppressCurrent_WithNew_CHASM () {
1448
+ currentSnapshot := s .CreateCHASMSnapshot (
1449
+ rand .Int63 (),
1450
+ enumsspb .WORKFLOW_EXECUTION_STATE_CREATED ,
1451
+ enumspb .WORKFLOW_EXECUTION_STATUS_RUNNING ,
1452
+ rand .Int63 (),
1453
+ )
1454
+
1455
+ baseRunID := uuid .New ().String ()
1456
+ baseSnapshot , baseEvents := RandomSnapshot (
1457
+ s .T (),
1458
+ s .NamespaceID ,
1459
+ s .WorkflowID ,
1460
+ baseRunID ,
1461
+ common .FirstEventID ,
1462
+ rand .Int63 (),
1463
+ enumsspb .WORKFLOW_EXECUTION_STATE_ZOMBIE ,
1464
+ enumspb .WORKFLOW_EXECUTION_STATUS_RUNNING ,
1465
+ rand .Int63 (),
1466
+ nil ,
1467
+ )
1468
+ s .Empty (baseEvents )
1469
+ _ , err := s .ExecutionManager .CreateWorkflowExecution (s .Ctx , & p.CreateWorkflowExecutionRequest {
1470
+ ShardID : s .ShardID ,
1471
+ RangeID : s .RangeID ,
1472
+ Mode : p .CreateWorkflowModeBypassCurrent ,
1473
+
1474
+ PreviousRunID : "" ,
1475
+ PreviousLastWriteVersion : 0 ,
1476
+
1477
+ NewWorkflowSnapshot : * baseSnapshot ,
1478
+ NewWorkflowEvents : baseEvents ,
1479
+ })
1480
+ s .NoError (err )
1481
+
1482
+ resetSnapshot , resetEvents := RandomSnapshot (
1483
+ s .T (),
1484
+ s .NamespaceID ,
1485
+ s .WorkflowID ,
1486
+ baseRunID ,
1487
+ baseSnapshot .NextEventID ,
1488
+ rand .Int63 (),
1489
+ enumsspb .WORKFLOW_EXECUTION_STATE_COMPLETED ,
1490
+ enumspb .WORKFLOW_EXECUTION_STATUS_COMPLETED ,
1491
+ baseSnapshot .DBRecordVersion + 1 ,
1492
+ nil ,
1493
+ )
1494
+ s .Empty (resetEvents )
1495
+
1496
+ newRunID := uuid .New ().String ()
1497
+ newSnapshot , newEvents := RandomSnapshot (
1498
+ s .T (),
1499
+ s .NamespaceID ,
1500
+ s .WorkflowID ,
1501
+ newRunID ,
1502
+ common .FirstEventID ,
1503
+ rand .Int63 (),
1504
+ enumsspb .WORKFLOW_EXECUTION_STATE_RUNNING ,
1505
+ enumspb .WORKFLOW_EXECUTION_STATUS_RUNNING ,
1506
+ rand .Int63 (),
1507
+ nil ,
1508
+ )
1509
+ s .Empty (newEvents )
1510
+
1511
+ currentMutation , currentEvents := RandomMutation (
1512
+ s .T (),
1513
+ s .NamespaceID ,
1514
+ s .WorkflowID ,
1515
+ s .RunID ,
1516
+ newSnapshot .NextEventID ,
1517
+ rand .Int63 (),
1518
+ enumsspb .WORKFLOW_EXECUTION_STATE_ZOMBIE ,
1519
+ enumspb .WORKFLOW_EXECUTION_STATUS_RUNNING ,
1520
+ currentSnapshot .DBRecordVersion + 1 ,
1521
+ nil ,
1522
+ )
1523
+ s .Empty (currentEvents )
1524
+
1525
+ _ , err = s .ExecutionManager .ConflictResolveWorkflowExecution (s .Ctx , & p.ConflictResolveWorkflowExecutionRequest {
1526
+ ShardID : s .ShardID ,
1527
+ RangeID : s .RangeID ,
1528
+ Mode : p .ConflictResolveWorkflowModeUpdateCurrent ,
1529
+
1530
+ ResetWorkflowSnapshot : * resetSnapshot ,
1531
+ ResetWorkflowEvents : resetEvents ,
1532
+
1533
+ NewWorkflowSnapshot : newSnapshot ,
1534
+ NewWorkflowEvents : newEvents ,
1535
+
1536
+ CurrentWorkflowMutation : currentMutation ,
1537
+ CurrentWorkflowEvents : currentEvents ,
1538
+ })
1539
+ s .NoError (err )
1540
+
1541
+ s .AssertMSEqualWithDB (resetSnapshot )
1542
+ s .AssertMSEqualWithDB (newSnapshot )
1543
+ s .AssertMSEqualWithDB (currentSnapshot , currentMutation )
1544
+ }
1545
+
1406
1546
func (s * ExecutionMutableStateSuite ) TestConflictResolve_ResetCurrent () {
1407
1547
branchToken , baseSnapshot , baseEvents := s .CreateWorkflow (
1408
1548
rand .Int63 (),
@@ -1948,6 +2088,37 @@ func (s *ExecutionMutableStateSuite) TestSet() {
1948
2088
s .AssertHEEqualWithDB (branchToken , events )
1949
2089
}
1950
2090
2091
+ func (s * ExecutionMutableStateSuite ) TestSet_CHASM () {
2092
+ snapshot := s .CreateCHASMSnapshot (
2093
+ rand .Int63 (),
2094
+ enumsspb .WORKFLOW_EXECUTION_STATE_CREATED ,
2095
+ enumspb .WORKFLOW_EXECUTION_STATUS_RUNNING ,
2096
+ rand .Int63 (),
2097
+ )
2098
+
2099
+ setSnapshot , _ := RandomSnapshot (
2100
+ s .T (),
2101
+ s .NamespaceID ,
2102
+ s .WorkflowID ,
2103
+ s .RunID ,
2104
+ common .FirstEventID ,
2105
+ rand .Int63 (),
2106
+ enumsspb .WORKFLOW_EXECUTION_STATE_RUNNING ,
2107
+ enumspb .WORKFLOW_EXECUTION_STATUS_RUNNING ,
2108
+ snapshot .DBRecordVersion + 1 ,
2109
+ nil , // CHASM snapshot has no events
2110
+ )
2111
+ _ , err := s .ExecutionManager .SetWorkflowExecution (s .Ctx , & p.SetWorkflowExecutionRequest {
2112
+ ShardID : s .ShardID ,
2113
+ RangeID : s .RangeID ,
2114
+
2115
+ SetWorkflowSnapshot : * setSnapshot ,
2116
+ })
2117
+ s .NoError (err )
2118
+
2119
+ s .AssertMSEqualWithDB (setSnapshot )
2120
+ }
2121
+
1951
2122
func (s * ExecutionMutableStateSuite ) TestDeleteCurrent_IsCurrent () {
1952
2123
branchToken , newSnapshot , newEvents := s .CreateWorkflow (
1953
2124
rand .Int63 (),
0 commit comments