914
915
// TestAdvancedVisibilityPagination test
917
>
testNamespaceUUID := namespace.ID(uuid.NewString())
918
>
919
>
// Generate 5 workflow records, keep 2 open and 3 closed.
920
>
var startReqs []*manager.RecordWorkflowExecutionStartedRequest
921
>
var closeReqs []*manager.RecordWorkflowExecutionClosedRequest
922
>
for i := range 5 {
923
>
startTime := time.Now()
924
>
startReq := s.createOpenWorkflowRecord(
925
>
testNamespaceUUID,
926
>
fmt.Sprintf("advanced-visibility-%v", i),
927
>
"visibility-workflow",
928
>
startTime,
929
>
startTime,
930
>
"test-queue",
931
>
)
932
>
if i <= 1 {
933
>
startReqs = append([]*manager.RecordWorkflowExecutionStartedRequest{startReq}, startReqs...)
934
>
} else {
935
>
closeReq := s.createClosedWorkflowRecord(
936
>
startReq,
937
>
time.Now(),
938
>
enumspb.WORKFLOW_EXECUTION_STATUS_COMPLETED,
939
>
)
940
>
closeReqs = append([]*manager.RecordWorkflowExecutionClosedRequest{closeReq}, closeReqs...)
941
>
}
942
}
943
945
>
executions := make(map[string]*workflowpb.WorkflowExecutionInfo)
946
>
for _, e := range s.listWithPagination(testNamespaceUUID, 5) {
947
>
executions[e.GetExecution().GetWorkflowId()] = e
948
>
}
949
950
// there is no order guarantee from the list method, so we have to find the right execution
952
>
id := r.Execution.GetWorkflowId()
953
>
e, ok := executions[id]
954
>
s.True(ok)
955
>
s.assertOpenExecutionEquals(r, e)
956
>
delete(executions, id)
957
>
}
958
>
for _, r := range closeReqs {
959
>
id := r.Execution.GetWorkflowId()
960
>
e, ok := executions[id]
961
>
s.True(ok)
962
>
s.assertClosedExecutionEquals(r, e)
963
>
delete(executions, id)
964
>
}
965
>
s.Empty(executions, "Unexpected executions returned from list method")
966
}
967
}