186
}
187
189
>
prevLastWriteVersion := rand.Int63()
190
>
_, prevSnapshot, _ := s.CreateWorkflow(
191
>
prevLastWriteVersion,
192
>
enumsspb.WORKFLOW_EXECUTION_STATE_COMPLETED,
193
>
enumspb.WORKFLOW_EXECUTION_STATUS_COMPLETED,
194
>
rand.Int63(),
195
>
)
196
>
197
>
newRunID := uuid.New().String()
198
>
newBranchToken := RandomBranchToken(s.NamespaceID, s.WorkflowID, newRunID, s.HistoryBranchUtil)
199
>
newSnapshot, newEvents := RandomSnapshot(
200
>
s.T(),
201
>
s.NamespaceID,
202
>
s.WorkflowID,
203
>
newRunID,
204
>
common.FirstEventID,
205
>
rand.Int63(),
206
>
enumsspb.WORKFLOW_EXECUTION_STATE_CREATED,
207
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
208
>
rand.Int63(),
209
>
newBranchToken,
210
>
)
211
>
212
>
_, err := s.ExecutionManager.CreateWorkflowExecution(s.Ctx, &p.CreateWorkflowExecutionRequest{
213
>
ShardID: s.ShardID,
214
>
RangeID: s.RangeID,
215
>
Mode: p.CreateWorkflowModeUpdateCurrent,
216
>
217
>
PreviousRunID: prevSnapshot.ExecutionState.RunId,
218
>
PreviousLastWriteVersion: prevLastWriteVersion,
219
>
220
>
ArchetypeID: chasm.WorkflowArchetypeID,
221
>
222
>
NewWorkflowSnapshot: *newSnapshot,
223
>
NewWorkflowEvents: newEvents,
224
>
})
225
>
s.NoError(err)
226
>
227
>
s.AssertMSEqualWithDB(chasm.WorkflowArchetypeID, newSnapshot)
228
>
s.AssertHEEqualWithDB(newBranchToken, newEvents)
229
>
}
230
231
func (s *ExecutionMutableStateSuite) TestCreate_Reuse_CHASM() {