2366
}
2367
2369
>
if !strings.HasPrefix(s.T().Name(), "TestCassandra") {
2370
s.T().Skip("ListConcreteExecutions is only implemented by cassandra persistence")
2371
}
2372
2374
>
rand.Int63(),
2375
>
enumsspb.WORKFLOW_EXECUTION_STATE_CREATED,
2376
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
2377
>
rand.Int63(),
2378
>
)
2379
>
2380
>
// Do NOT use CreateCHASMExecution() here, which uses the same runID as CreateWorkflow().
2381
>
chasmSnapshot, events := RandomSnapshot(
2382
>
s.T(),
2383
>
uuid.New().String(),
2384
>
uuid.New().String(),
2385
>
uuid.New().String(),
2386
>
common.FirstEventID,
2387
>
rand.Int63(),
2388
>
enumsspb.WORKFLOW_EXECUTION_STATE_CREATED,
2389
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
2390
>
rand.Int63(),
2391
>
nil,
2392
>
)
2393
>
_, err := s.ExecutionManager.CreateWorkflowExecution(s.Ctx, &p.CreateWorkflowExecutionRequest{
2394
>
ShardID: s.ShardID,
2395
>
RangeID: s.RangeID,
2396
>
Mode: p.CreateWorkflowModeBrandNew,
2397
>
2398
>
PreviousRunID: "",
2399
>
PreviousLastWriteVersion: 0,
2400
>
2401
>
ArchetypeID: rand.Uint32(),
2402
>
2403
>
NewWorkflowSnapshot: *chasmSnapshot,
2404
>
NewWorkflowEvents: events,
2405
>
})
2406
>
s.NoError(err)
2407
>
2408
>
var mutableStates []*persistencespb.WorkflowMutableState
2409
>
request := &p.ListConcreteExecutionsRequest{
2410
>
ShardID: s.ShardID,
2411
>
PageSize: 1,
2412
>
}
2413
>
for {
2414
>
resp, err := s.ExecutionManager.ListConcreteExecutions(s.Ctx, request)
2415
>
s.NoError(err)
2416
>
2417
>
mutableStates = append(mutableStates, resp.States...)
2418
>
if len(resp.PageToken) == 0 {
2419
>
break
2420
}
2421
2423
}
2424
2426
>
2427
>
// Move mutable state for the chasm execution to index 1
2428
>
if mutableStates[0].ExecutionState.RunId != s.RunID {
2429
>
mutableStates[0], mutableStates[1] = mutableStates[1], mutableStates[0]
2430
>
}
2431
2432
// ListConcreteExecutions only populates those three fields today.
2434
>
s.ProtoEqual(&persistencespb.WorkflowMutableState{
2435
>
ExecutionInfo: expectedWorkflowMutableState.ExecutionInfo,
2436
>
ExecutionState: expectedWorkflowMutableState.ExecutionState,
2437
>
NextEventId: expectedWorkflowMutableState.NextEventId,
2438
>
}, mutableStates[0])
2439
>
expectedCHASMMutableState, _ := s.Accumulate(chasmSnapshot)
2440
>
s.ProtoEqual(&persistencespb.WorkflowMutableState{
2441
>
ExecutionInfo: expectedCHASMMutableState.ExecutionInfo,
2442
>
ExecutionState: expectedCHASMMutableState.ExecutionState,
2443
>
NextEventId: expectedCHASMMutableState.NextEventId,
2444
>
}, mutableStates[1])
2445
}
2446