306
307
// TestVisibilityPagination test
309
>
testNamespaceUUID := namespace.ID(uuid.NewString())
310
>
311
>
// Create 2 executions
312
>
startTime1 := time.Now().UTC()
313
>
openRecord1 := s.createOpenWorkflowRecord(
314
>
testNamespaceUUID,
315
>
"visibility-pagination-test1",
316
>
"visibility-workflow",
317
>
startTime1,
318
>
startTime1,
319
>
"test-queue",
320
>
)
321
>
322
>
startTime2 := startTime1.Add(time.Second)
323
>
openRecord2 := s.createOpenWorkflowRecord(
324
>
testNamespaceUUID,
325
>
"visibility-pagination-test2",
326
>
"visibility-workflow",
327
>
startTime2,
328
>
startTime2,
329
>
"test-queue",
330
>
)
331
>
332
>
// Get the first one
333
>
resp, err2 := s.VisibilityMgr.ListWorkflowExecutions(s.ctx, &manager.ListWorkflowExecutionsRequestV2{
334
>
NamespaceID: testNamespaceUUID,
335
>
PageSize: 1,
336
>
Query: fmt.Sprintf("%s >= '%s' AND %s <= '%s' AND %s = '%s'",
337
>
sadefs.StartTime,
338
>
startTime1.Format(time.RFC3339Nano),
339
>
sadefs.StartTime,
340
>
startTime2.Format(time.RFC3339Nano),
341
>
sadefs.ExecutionStatus,
342
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
343
>
),
344
>
})
345
>
s.NoError(err2)
346
>
s.Len(resp.Executions, 1)
347
>
s.assertOpenExecutionEquals(openRecord2, resp.Executions[0])
348
>
349
>
// Use token to get the second one
350
>
resp, err3 := s.VisibilityMgr.ListWorkflowExecutions(s.ctx, &manager.ListWorkflowExecutionsRequestV2{
351
>
NamespaceID: testNamespaceUUID,
352
>
PageSize: 1,
353
>
Query: fmt.Sprintf("%s >= '%s' AND %s <= '%s' AND %s = '%s'",
354
>
sadefs.StartTime,
355
>
startTime1.Format(time.RFC3339Nano),
356
>
sadefs.StartTime,
357
>
startTime2.Format(time.RFC3339Nano),
358
>
sadefs.ExecutionStatus,
359
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
360
>
),
361
>
NextPageToken: resp.NextPageToken,
362
>
})
363
>
s.NoError(err3)
364
>
s.Len(resp.Executions, 1)
365
>
s.assertOpenExecutionEquals(openRecord1, resp.Executions[0])
366
>
367
>
// It is possible to not return non empty token which is going to return empty result
368
>
if len(resp.NextPageToken) != 0 {
369
>
// Now should get empty result by using token
370
>
resp, err4 := s.VisibilityMgr.ListWorkflowExecutions(s.ctx, &manager.ListWorkflowExecutionsRequestV2{
371
>
NamespaceID: testNamespaceUUID,
372
>
PageSize: 1,
373
>
Query: fmt.Sprintf("%s >= '%s' AND %s <= '%s' AND %s = '%s'",
374
>
sadefs.StartTime,
375
>
startTime1.Format(time.RFC3339Nano),
376
>
sadefs.StartTime,
377
>
startTime2.Format(time.RFC3339Nano),
378
>
sadefs.ExecutionStatus,
379
>
enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
380
>
),
381
>
NextPageToken: resp.NextPageToken,
382
>
})
383
>
s.NoError(err4)
384
>
s.Empty(resp.Executions)
385
>
}
386
}
387