144
}
145
147
>
lastWriteVersion := rand.Int63()
148
>
branchToken, newSnapshot, newEvents := s.CreateWorkflow(
149
>
lastWriteVersion,
150
>
enumsspb.WORKFLOW_EXECUTION_STATE_COMPLETED,
151
>
enumspb.WORKFLOW_EXECUTION_STATUS_COMPLETED,
152
>
rand.Int63(),
153
>
)
154
>
155
>
_, err := s.ExecutionManager.CreateWorkflowExecution(s.Ctx, &p.CreateWorkflowExecutionRequest{
156
>
ShardID: s.ShardID,
157
>
RangeID: s.RangeID,
158
>
Mode: p.CreateWorkflowModeBrandNew,
159
>
160
>
PreviousRunID: "",
161
>
PreviousLastWriteVersion: 0,
162
>
163
>
ArchetypeID: chasm.WorkflowArchetypeID,
164
>
165
>
NewWorkflowSnapshot: *newSnapshot,
166
>
NewWorkflowEvents: newEvents,
167
>
})
168
>
if err, ok := err.(*p.CurrentWorkflowConditionFailedError); ok {
169
>
err.Msg = ""
170
>
}
171
>
s.DeepEqual(&p.CurrentWorkflowConditionFailedError{
172
>
Msg: "",
173
>
RequestIDs: newSnapshot.ExecutionState.RequestIds,
174
>
RunID: newSnapshot.ExecutionState.RunId,
175
>
State: newSnapshot.ExecutionState.State,
176
>
Status: newSnapshot.ExecutionState.Status,
177
>
LastWriteVersion: lastWriteVersion,
178
>
StartTime: timestamp.TimeValuePtr(newSnapshot.ExecutionState.StartTime),
179
>
}, err)
180
>
181
>
// A failed CreateWorkflowExecution must not mutate the caller's snapshot. It previously leaked
182
>
// its HistorySize increment into newSnapshot, which double-counted on a retry that reused it;
183
>
// AssertMSEqualWithDB fails if the snapshot diverges from the persisted state, guarding that.
184
>
s.AssertMSEqualWithDB(chasm.WorkflowArchetypeID, newSnapshot)
185
>
s.AssertHEEqualWithDB(branchToken, newEvents)
186
}
187