229
}
230
232
>
// CHASM snapshot has no events and empty current version history.
233
>
prevLastWriteVersion := rand.Int63()
234
>
archetypeID := rand.Uint32()
235
>
prevSnapshot := s.CreateCHASMExecution(
236
>
prevLastWriteVersion,
237
>
enumsspb.WORKFLOW_EXECUTION_STATE_COMPLETED,
238
>
enumspb.WORKFLOW_EXECUTION_STATUS_COMPLETED,
239
>
rand.Int63(),
240
>
archetypeID,
241
>
)
242
>
243
>
newRunID := uuid.New().String()
244
>
newSnapshot, newEvents := RandomSnapshot(
245
>
s.T(),
246
>
s.NamespaceID,
247
>
s.WorkflowID,
248
>
newRunID,
249
>
common.FirstEventID,
250
>
rand.Int63(),
251
>
enumsspb.WORKFLOW_EXECUTION_STATE_CREATED,
252
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
253
>
rand.Int63(),
254
>
nil, // CHASM snapshot has no events
255
>
)
256
>
s.Empty(newEvents)
257
>
258
>
_, err := s.ExecutionManager.CreateWorkflowExecution(s.Ctx, &p.CreateWorkflowExecutionRequest{
259
>
ShardID: s.ShardID,
260
>
RangeID: s.RangeID,
261
>
Mode: p.CreateWorkflowModeUpdateCurrent,
262
>
263
>
PreviousRunID: prevSnapshot.ExecutionState.RunId,
264
>
PreviousLastWriteVersion: prevLastWriteVersion,
265
>
266
>
ArchetypeID: archetypeID,
267
>
268
>
NewWorkflowSnapshot: *newSnapshot,
269
>
NewWorkflowEvents: newEvents,
270
>
})
271
>
s.NoError(err)
272
>
273
>
s.AssertMSEqualWithDB(archetypeID, newSnapshot)
274
>
}
275
276
func (s *ExecutionMutableStateSuite) TestCreate_Reuse_CurrentConflict() {